]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: microchip: implement get_phy_flags only if needed
authorBastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Mon, 8 Jun 2026 14:10:06 +0000 (16:10 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jun 2026 01:08:07 +0000 (18:08 -0700)
The common ksz_get_phy_flags() is used by all the switches to implement
the optional .get_phy_flags DSA operation. It always returns 0 except
for KSZ88X3 switches where an errata has to be handled.

Make ksz_get_phy_flags() ksz88xx-specific.
Remove the get_phy_flags implementation for the switches that don't need
it.

Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260608-clean-ksz-3rd-v2-3-6e61b7be23c4@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/microchip/ksz8.c
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/microchip/lan937x_main.c

index 9161326b34fd7d5511cf0da2fcbff3b3b4166671..ba708ad71c1ebc57a714c4b8070a97dde8526968 100644 (file)
@@ -2361,6 +2361,24 @@ static int ksz8463_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val
        return 0;
 }
 
+static u32 ksz88xx_get_phy_flags(struct dsa_switch *ds, int port)
+{
+       struct ksz_device *dev = ds->priv;
+
+       switch (dev->chip_id) {
+       case KSZ88X3_CHIP_ID:
+               /* Silicon Errata Sheet (DS80000830A):
+                * Port 1 does not work with LinkMD Cable-Testing.
+                * Port 1 does not respond to received PAUSE control frames.
+                */
+               if (!port)
+                       return MICREL_KSZ8_P1_ERRATA;
+               break;
+       }
+
+       return 0;
+}
+
 static int ksz8_switch_init(struct ksz_device *dev)
 {
        dev->cpu_port = fls(dev->info->cpu_ports) - 1;
@@ -2508,7 +2526,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = {
 const struct dsa_switch_ops ksz8463_switch_ops = {
        .get_tag_protocol       = ksz8463_get_tag_protocol,
        .connect_tag_protocol   = ksz8463_connect_tag_protocol,
-       .get_phy_flags          = ksz_get_phy_flags,
        .setup                  = ksz8_setup,
        .teardown               = ksz_teardown,
        .phy_read               = ksz8463_phy_read16,
@@ -2563,7 +2580,6 @@ const struct dsa_switch_ops ksz8463_switch_ops = {
 const struct dsa_switch_ops ksz87xx_switch_ops = {
        .get_tag_protocol       = ksz87xx_get_tag_protocol,
        .connect_tag_protocol   = ksz87xx_connect_tag_protocol,
-       .get_phy_flags          = ksz_get_phy_flags,
        .setup                  = ksz8_setup,
        .teardown               = ksz_teardown,
        .phy_read               = ksz8_phy_read16,
@@ -2621,7 +2637,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops = {
 const struct dsa_switch_ops ksz88xx_switch_ops = {
        .get_tag_protocol       = ksz88xx_get_tag_protocol,
        .connect_tag_protocol   = ksz88xx_connect_tag_protocol,
-       .get_phy_flags          = ksz_get_phy_flags,
+       .get_phy_flags          = ksz88xx_get_phy_flags,
        .setup                  = ksz8_setup,
        .teardown               = ksz_teardown,
        .phy_read               = ksz8_phy_read16,
index c18bad08a508edd9dadf157d18057be86874b13b..a39541d29ad5baf2ac2390f55d9f638a69d298b0 100644 (file)
@@ -1952,7 +1952,6 @@ const struct ksz_dev_ops ksz9477_dev_ops = {
 const struct dsa_switch_ops ksz9477_switch_ops = {
        .get_tag_protocol       = ksz9477_get_tag_protocol,
        .connect_tag_protocol   = ksz9477_connect_tag_protocol,
-       .get_phy_flags          = ksz_get_phy_flags,
        .setup                  = ksz9477_setup,
        .teardown               = ksz_teardown,
        .phy_read               = ksz9477_phy_read16,
index 81d3ec88e436083af1a6df22673ba072c96773b0..5fb151fbf4f306f3119398c1da64f4f4667c5cec 100644 (file)
@@ -2838,24 +2838,6 @@ void ksz_init_mib_timer(struct ksz_device *dev)
        }
 }
 
-u32 ksz_get_phy_flags(struct dsa_switch *ds, int port)
-{
-       struct ksz_device *dev = ds->priv;
-
-       switch (dev->chip_id) {
-       case KSZ88X3_CHIP_ID:
-               /* Silicon Errata Sheet (DS80000830A):
-                * Port 1 does not work with LinkMD Cable-Testing.
-                * Port 1 does not respond to received PAUSE control frames.
-                */
-               if (!port)
-                       return MICREL_KSZ8_P1_ERRATA;
-               break;
-       }
-
-       return 0;
-}
-
 void ksz_phylink_mac_link_down(struct phylink_config *config,
                               unsigned int mode,
                               phy_interface_t interface)
index 1c22d10eff841556a0b37b313e51e5ce4998f54b..de47498db483c01b4885605532605032195fe774 100644 (file)
@@ -444,8 +444,6 @@ void ksz_switch_macaddr_put(struct dsa_switch *ds);
 void ksz_switch_shutdown(struct ksz_device *dev);
 int ksz_handle_wake_reason(struct ksz_device *dev, int port);
 
-u32 ksz_get_phy_flags(struct dsa_switch *ds, int port);
-
 int ksz_sset_count(struct dsa_switch *ds, int port, int sset);
 void ksz_get_ethtool_stats(struct dsa_switch *ds, int port,
                           uint64_t *buf);
index 731737fd58d1f0d5b10cea5be48965d97363315c..57e289637193fff72966314358256205990c4353 100644 (file)
@@ -846,7 +846,6 @@ const struct ksz_dev_ops lan937x_dev_ops = {
 const struct dsa_switch_ops lan937x_switch_ops = {
        .get_tag_protocol       = lan937x_get_tag_protocol,
        .connect_tag_protocol   = lan937x_connect_tag_protocol,
-       .get_phy_flags          = ksz_get_phy_flags,
        .setup                  = lan937x_setup,
        .teardown               = ksz_teardown,
        .phy_read               = lan937x_phy_read16,