hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
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", },
....@@ -1010,9 +1002,11 @@
10101002 ret = lan9303_read_switch_port(
10111003 chip, port, lan9303_mib[u].offset, &reg);
10121004
1013
- if (ret)
1005
+ if (ret) {
10141006 dev_warn(chip->dev, "Reading status port %d reg %u failed\n",
10151007 port, lan9303_mib[u].offset);
1008
+ reg = 0;
1009
+ }
10161010 data[u] = reg;
10171011 }
10181012 }
....@@ -1056,7 +1050,7 @@
10561050 struct phy_device *phydev)
10571051 {
10581052 struct lan9303 *chip = ds->priv;
1059
- int ctl, res;
1053
+ int ctl;
10601054
10611055 if (!phy_is_pseudo_fixed_link(phydev))
10621056 return;
....@@ -1077,15 +1071,14 @@
10771071 else
10781072 ctl &= ~BMCR_FULLDPLX;
10791073
1080
- res = lan9303_phy_write(ds, port, MII_BMCR, ctl);
1074
+ lan9303_phy_write(ds, port, MII_BMCR, ctl);
10811075
10821076 if (port == chip->phy_addr_base) {
10831077 /* Virtual Phy: Remove Turbo 200Mbit mode */
10841078 lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl);
10851079
10861080 ctl &= ~LAN9303_VIRT_SPECIAL_TURBO;
1087
- res = regmap_write(chip->regmap,
1088
- LAN9303_VIRT_SPECIAL_CTRL, ctl);
1081
+ regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl);
10891082 }
10901083 }
10911084
....@@ -1094,13 +1087,18 @@
10941087 {
10951088 struct lan9303 *chip = ds->priv;
10961089
1090
+ if (!dsa_is_user_port(ds, port))
1091
+ return 0;
1092
+
10971093 return lan9303_enable_processing_port(chip, port);
10981094 }
10991095
1100
-static void lan9303_port_disable(struct dsa_switch *ds, int port,
1101
- struct phy_device *phy)
1096
+static void lan9303_port_disable(struct dsa_switch *ds, int port)
11021097 {
11031098 struct lan9303 *chip = ds->priv;
1099
+
1100
+ if (!dsa_is_user_port(ds, port))
1101
+ return;
11041102
11051103 lan9303_disable_processing_port(chip, port);
11061104 lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN);
....@@ -1189,8 +1187,6 @@
11891187 struct lan9303 *chip = ds->priv;
11901188
11911189 dev_dbg(chip->dev, "%s(%d, %pM, %d)\n", __func__, port, addr, vid);
1192
- if (vid)
1193
- return -EOPNOTSUPP;
11941190
11951191 return lan9303_alr_add_port(chip, addr, port, false);
11961192 }
....@@ -1202,8 +1198,6 @@
12021198 struct lan9303 *chip = ds->priv;
12031199
12041200 dev_dbg(chip->dev, "%s(%d, %pM, %d)\n", __func__, port, addr, vid);
1205
- if (vid)
1206
- return -EOPNOTSUPP;
12071201 lan9303_alr_del_port(chip, addr, port);
12081202
12091203 return 0;
....@@ -1291,10 +1285,12 @@
12911285 {
12921286 int base;
12931287
1294
- chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS);
1288
+ chip->ds = devm_kzalloc(chip->dev, sizeof(*chip->ds), GFP_KERNEL);
12951289 if (!chip->ds)
12961290 return -ENOMEM;
12971291
1292
+ chip->ds->dev = chip->dev;
1293
+ chip->ds->num_ports = LAN9303_NUM_PORTS;
12981294 chip->ds->priv = chip;
12991295 chip->ds->ops = &lan9303_switch_ops;
13001296 base = chip->phy_addr_base;