forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/net/dsa/lan9303-core.c
....@@ -1,15 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2017 Pengutronix, Juergen Borleis <kernel@pengutronix.de>
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
12
- *
134 */
145 #include <linux/kernel.h>
156 #include <linux/module.h>
....@@ -898,7 +889,8 @@
898889 /* ---------------------------- DSA -----------------------------------*/
899890
900891 static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds,
901
- int port)
892
+ int port,
893
+ enum dsa_tag_protocol mp)
902894 {
903895 return DSA_TAG_PROTO_LAN9303;
904896 }
....@@ -966,7 +958,7 @@
966958 { .offset = LAN9303_MAC_TX_BRDCST_CNT_0, .name = "TxBroad", },
967959 { .offset = LAN9303_MAC_TX_PAUSE_CNT_0, .name = "TxPause", },
968960 { .offset = LAN9303_MAC_TX_MULCST_CNT_0, .name = "TxMulti", },
969
- { .offset = LAN9303_MAC_RX_UNDSZE_CNT_0, .name = "TxUnderRun", },
961
+ { .offset = LAN9303_MAC_RX_UNDSZE_CNT_0, .name = "RxShort", },
970962 { .offset = LAN9303_MAC_TX_64_CNT_0, .name = "Tx64Byte", },
971963 { .offset = LAN9303_MAC_TX_127_CNT_0, .name = "Tx128Byte", },
972964 { .offset = LAN9303_MAC_TX_255_CNT_0, .name = "Tx256Byte", },
....@@ -1056,7 +1048,7 @@
10561048 struct phy_device *phydev)
10571049 {
10581050 struct lan9303 *chip = ds->priv;
1059
- int ctl, res;
1051
+ int ctl;
10601052
10611053 if (!phy_is_pseudo_fixed_link(phydev))
10621054 return;
....@@ -1077,15 +1069,14 @@
10771069 else
10781070 ctl &= ~BMCR_FULLDPLX;
10791071
1080
- res = lan9303_phy_write(ds, port, MII_BMCR, ctl);
1072
+ lan9303_phy_write(ds, port, MII_BMCR, ctl);
10811073
10821074 if (port == chip->phy_addr_base) {
10831075 /* Virtual Phy: Remove Turbo 200Mbit mode */
10841076 lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl);
10851077
10861078 ctl &= ~LAN9303_VIRT_SPECIAL_TURBO;
1087
- res = regmap_write(chip->regmap,
1088
- LAN9303_VIRT_SPECIAL_CTRL, ctl);
1079
+ regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl);
10891080 }
10901081 }
10911082
....@@ -1094,13 +1085,18 @@
10941085 {
10951086 struct lan9303 *chip = ds->priv;
10961087
1088
+ if (!dsa_is_user_port(ds, port))
1089
+ return 0;
1090
+
10971091 return lan9303_enable_processing_port(chip, port);
10981092 }
10991093
1100
-static void lan9303_port_disable(struct dsa_switch *ds, int port,
1101
- struct phy_device *phy)
1094
+static void lan9303_port_disable(struct dsa_switch *ds, int port)
11021095 {
11031096 struct lan9303 *chip = ds->priv;
1097
+
1098
+ if (!dsa_is_user_port(ds, port))
1099
+ return;
11041100
11051101 lan9303_disable_processing_port(chip, port);
11061102 lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN);
....@@ -1291,10 +1287,12 @@
12911287 {
12921288 int base;
12931289
1294
- chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS);
1290
+ chip->ds = devm_kzalloc(chip->dev, sizeof(*chip->ds), GFP_KERNEL);
12951291 if (!chip->ds)
12961292 return -ENOMEM;
12971293
1294
+ chip->ds->dev = chip->dev;
1295
+ chip->ds->num_ports = LAN9303_NUM_PORTS;
12981296 chip->ds->priv = chip;
12991297 chip->ds->ops = &lan9303_switch_ops;
13001298 base = chip->phy_addr_base;