Commit 0263ea5c authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: phy: mdio-boardinfo: Allow recursive mdiobus_register()

mdiobus_register will search for any mdiobus board info registered for
the bus being registered. If found, it will probe devices on the bus.
That device, if for example it is an ethernet switch, may then try to
register an mdio bus. Thus we need to allow recursive calls to
mdiobus_register.

Holding the mdio_board_lock will cause a deadlock during this
recursion. Release the lock and use list_for_each_entry_safe.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bda73d4e
...@@ -30,17 +30,20 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus, ...@@ -30,17 +30,20 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
struct mdio_board_info *bi)) struct mdio_board_info *bi))
{ {
struct mdio_board_entry *be; struct mdio_board_entry *be;
struct mdio_board_entry *tmp;
struct mdio_board_info *bi; struct mdio_board_info *bi;
int ret; int ret;
mutex_lock(&mdio_board_lock); mutex_lock(&mdio_board_lock);
list_for_each_entry(be, &mdio_board_list, list) { list_for_each_entry_safe(be, tmp, &mdio_board_list, list) {
bi = &be->board_info; bi = &be->board_info;
if (strcmp(bus->id, bi->bus_id)) if (strcmp(bus->id, bi->bus_id))
continue; continue;
mutex_unlock(&mdio_board_lock);
ret = cb(bus, bi); ret = cb(bus, bi);
mutex_lock(&mdio_board_lock);
if (ret) if (ret)
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment