diff options
author | David S. Miller <davem@davemloft.net> | 2020-06-19 13:39:01 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-06-19 13:39:01 -0700 |
commit | cc26c9f5ace29d00ccedd79ffa1ee90b2439fe55 (patch) | |
tree | b9c89e939d75d3feed38ea407fa6be77cc8de514 | |
parent | net: ethernet: oki-semi: pch_gbe: fix spelling mistake (diff) | |
parent | net: phy: Check harder for errors in get_phy_id() (diff) | |
download | wireguard-linux-cc26c9f5ace29d00ccedd79ffa1ee90b2439fe55.tar.xz wireguard-linux-cc26c9f5ace29d00ccedd79ffa1ee90b2439fe55.zip |
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 <davem@davemloft.net>
-rw-r--r-- | drivers/net/phy/phy_device.c | 6 | ||||
-rw-r--r-- | drivers/of/of_mdio.c | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 04946de74fa0..85ba95b598b5 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -794,8 +794,10 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id, /* Grab the bits from PHYIR2, and put them in the lower half */ phy_reg = mdiobus_read(bus, addr, MII_PHYSID2); - if (phy_reg < 0) - return -EIO; + if (phy_reg < 0) { + /* returning -ENODEV doesn't stop bus scanning */ + return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; + } *phy_id |= phy_reg; diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index a04afe79529c..ef6f818ce5b3 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -314,10 +314,15 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) child, addr); if (of_mdiobus_child_is_phy(child)) { + /* -ENODEV is the return code that PHYLIB has + * standardized on to indicate that bus + * scanning should continue. + */ rc = of_mdiobus_register_phy(mdio, child, addr); - if (rc && rc != -ENODEV) + if (!rc) + break; + if (rc != -ENODEV) goto unregister; - break; } } } |