Skip to content

Commit cc26c9f

Browse files
committed
Merge branch 'net-phy-MDIO-bus-scanning-fixes'
Florian Fainelli says: ==================== net: phy: MDIO bus scanning fixes This patch series fixes two problems with the current MDIO bus scanning logic which was identified while moving from 4.9 to 5.4 on devices that do rely on scanning the MDIO bus at runtime because they use pluggable cards. Changes in v2: - added comment explaining the special value of -ENODEV - added Andrew's Reviewed-by tag ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 6564cfe + b2ffc75 commit cc26c9f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

drivers/net/phy/phy_device.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,10 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
794794

795795
/* Grab the bits from PHYIR2, and put them in the lower half */
796796
phy_reg = mdiobus_read(bus, addr, MII_PHYSID2);
797-
if (phy_reg < 0)
798-
return -EIO;
797+
if (phy_reg < 0) {
798+
/* returning -ENODEV doesn't stop bus scanning */
799+
return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO;
800+
}
799801

800802
*phy_id |= phy_reg;
801803

drivers/of/of_mdio.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,15 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
314314
child, addr);
315315

316316
if (of_mdiobus_child_is_phy(child)) {
317+
/* -ENODEV is the return code that PHYLIB has
318+
* standardized on to indicate that bus
319+
* scanning should continue.
320+
*/
317321
rc = of_mdiobus_register_phy(mdio, child, addr);
318-
if (rc && rc != -ENODEV)
322+
if (!rc)
323+
break;
324+
if (rc != -ENODEV)
319325
goto unregister;
320-
break;
321326
}
322327
}
323328
}

0 commit comments

Comments
 (0)