]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - net/dsa/slave.c
dsa: use an unique and non conflicting bus name for the slave MII bus
authorFlorian Fainelli <florian@openwrt.org>
Mon, 21 Jan 2013 09:58:50 +0000 (09:58 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Jan 2013 20:40:11 +0000 (15:40 -0500)
commitf490be049ba0a3b194bed3a0dfbdcab1ef0ae063
tree8d94713e891c56c70c040b53b1ac3e800d5d291d
parent441d9d327f1e770f5aa76fd91735851ac6e1e236
dsa: use an unique and non conflicting bus name for the slave MII bus

The slave MII bus registered by the DSA code is using the parent MII bus
as part of its name (ds->master_mii_bus_id), in case the parent MII bus
name is already 16 characters long (such as d0072004.mdio-mi) we will
get the following WARN_ON in dsa_switch_setup() when calling
mdiobus_register():

[   79.088782] ------------[ cut here ]------------
[   79.093448] WARNING: at fs/sysfs/dir.c:536 sysfs_add_one+0x80/0xa0()
[   79.099831] sysfs: cannot create duplicate filename
'/class/mdio_bus/d0072004.mdio-mi'

This is a genuine warning, because the DSA slave MII bus will also be
named d0072004.mdio-mi, and since MII_BUS_ID_SIZE is 17 characters long
(with null-terminator) the following will truncate the slave MII bus id:

snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "%s-%d:%.2x",
                        ds->master_mii_bus->id, ds->pd->sw_addr);

Fix this by using dsa-<switch index->:<sw_add> which is guaranteed to be
unique.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/slave.c