Skip to content

Commit 02a6efc

Browse files
alexandrebellonidavem330
authored andcommitted
net: phy: allow scanning busses with missing phys
Some MDIO busses will error out when trying to read a phy address with no phy present at that address. In that case, probing the bus will fail because __mdiobus_register() is scanning the bus for all possible phys addresses. In case MII_PHYSID1 returns -EIO or -ENODEV, consider there is no phy at this address and set the phy ID to 0xffffffff which is then properly handled in get_phy_device(). Suggested-by: Andrew Lunn <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3be4aaf commit 02a6efc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/net/phy/phy_device.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,17 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
535535

536536
/* Grab the bits from PHYIR1, and put them in the upper half */
537537
phy_reg = mdiobus_read(bus, addr, MII_PHYSID1);
538-
if (phy_reg < 0)
538+
if (phy_reg < 0) {
539+
/* if there is no device, return without an error so scanning
540+
* the bus works properly
541+
*/
542+
if (phy_reg == -EIO || phy_reg == -ENODEV) {
543+
*phy_id = 0xffffffff;
544+
return 0;
545+
}
546+
539547
return -EIO;
548+
}
540549

541550
*phy_id = (phy_reg & 0xffff) << 16;
542551

0 commit comments

Comments
 (0)