Skip to content

Commit b2ffc75

Browse files
ffainellidavem330
authored andcommitted
net: phy: Check harder for errors in get_phy_id()
Commit 02a6efc ("net: phy: allow scanning busses with missing phys") added a special condition to return -ENODEV in case -ENODEV or -EIO was returned from the first read of the MII_PHYSID1 register. In case the MDIO bus data line pull-up is not strong enough, the MDIO bus controller will not flag this as a read error. This can happen when a pluggable daughter card is not connected and weak internal pull-ups are used (since that is the only option, otherwise the pins are floating). The second read of MII_PHYSID2 will be correctly flagged an error though, but now we will return -EIO which will be treated as a hard error, thus preventing MDIO bus scanning loops to continue succesfully. Apply the same logic to both register reads, thus allowing the scanning logic to proceed. Fixes: 02a6efc ("net: phy: allow scanning busses with missing phys") Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5a8d7f1 commit b2ffc75

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
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

0 commit comments

Comments
 (0)