]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: microchip: Make MDIO bus name unique
authorJesse Van Gavere <jesseevg@gmail.com>
Fri, 6 Dec 2024 20:42:02 +0000 (21:42 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 9 Dec 2024 22:32:00 +0000 (14:32 -0800)
In configurations with 2 or more DSA clusters it will fail to allocate
unique MDIO bus names as only the switch ID is used, fix this by using
a combination of the tree ID and switch ID when needed

Signed-off-by: Jesse Van Gavere <jesse.vangavere@scioteq.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20241206204202.649912-1-jesse.vangavere@scioteq.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/microchip/ksz_common.c

index 920443ee8ffd02380da64cd9e14e867d6210e890..f5822c57be32e77dd75464216877a05635750daa 100644 (file)
@@ -2550,7 +2550,11 @@ static int ksz_mdio_register(struct ksz_device *dev)
                bus->read = ksz_sw_mdio_read;
                bus->write = ksz_sw_mdio_write;
                bus->name = "ksz user smi";
-               snprintf(bus->id, MII_BUS_ID_SIZE, "SMI-%d", ds->index);
+               if (ds->dst->index != 0) {
+                       snprintf(bus->id, MII_BUS_ID_SIZE, "SMI-%d-%d", ds->dst->index, ds->index);
+               } else {
+                       snprintf(bus->id, MII_BUS_ID_SIZE, "SMI-%d", ds->index);
+               }
        }
 
        ret = ksz_parse_dt_phy_config(dev, bus, mdio_np);