]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: mdio-mux: be compatible with parent buses which only support C45
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 13 Dec 2023 15:27:12 +0000 (17:27 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 Dec 2023 02:55:38 +0000 (18:55 -0800)
After the mii_bus API conversion to a split read() / read_c45(), there
might be MDIO parent buses which only populate the read_c45() and
write_c45() function pointers but not the C22 variants.

We haven't seen these in the wild paired with MDIO multiplexers, but
Andrew points out we should treat the corner case.

Link: https://lore.kernel.org/netdev/4ccd7dc9-b611-48aa-865f-68d3a1327ce8@lunn.ch/
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20231213152712.320842-3-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/mdio/mdio-mux.c

index e5dee7ad7c09d71bbd30afed71b65c9bff5990ec..fe0e46bd7964f6da9850cbefe0d028f9495214ca 100644 (file)
@@ -214,8 +214,10 @@ int mdio_mux_init(struct device *dev,
                snprintf(cb->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x.%x",
                         cb->mii_bus->name, pb->parent_id, v);
                cb->mii_bus->parent = dev;
-               cb->mii_bus->read = mdio_mux_read;
-               cb->mii_bus->write = mdio_mux_write;
+               if (parent_bus->read)
+                       cb->mii_bus->read = mdio_mux_read;
+               if (parent_bus->write)
+                       cb->mii_bus->write = mdio_mux_write;
                if (parent_bus->read_c45)
                        cb->mii_bus->read_c45 = mdio_mux_read_c45;
                if (parent_bus->write_c45)