Message ID | 20210527155959.3270478-1-olteanv@gmail.com |
---|---|
State | New |
Headers | show |
Series | [net-next] net: stmmac: the XPCS obscures a potential "PHY not found" error | expand |
Hello: This patch was applied to netdev/net-next.git (refs/heads/master): On Thu, 27 May 2021 18:59:59 +0300 you wrote: > From: Vladimir Oltean <vladimir.oltean@nxp.com> > > stmmac_mdio_register() has logic to search for PHYs on the MDIO bus and > assign them IRQ lines, as well as to set priv->plat->phy_addr. > > If no PHY is found, the "found" variable remains set to 0 and the > function errors out. > > [...] Here is the summary with links: - [net-next] net: stmmac: the XPCS obscures a potential "PHY not found" error https://git.kernel.org/netdev/net-next/c/4751d2aa321f You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index b750074f8f9c..e293bf1ce9f3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -503,6 +503,12 @@ int stmmac_mdio_register(struct net_device *ndev) found = 1; } + if (!found && !mdio_node) { + dev_warn(dev, "No PHY found\n"); + err = -ENODEV; + goto no_phy_found; + } + /* Try to probe the XPCS by scanning all addresses. */ if (priv->hw->xpcs) { struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; @@ -511,6 +517,7 @@ int stmmac_mdio_register(struct net_device *ndev) xpcs->bus = new_bus; + found = 0; for (addr = 0; addr < max_addr; addr++) { xpcs->addr = addr; @@ -520,13 +527,12 @@ int stmmac_mdio_register(struct net_device *ndev) break; } } - } - if (!found && !mdio_node) { - dev_warn(dev, "No PHY found\n"); - mdiobus_unregister(new_bus); - mdiobus_free(new_bus); - return -ENODEV; + if (!found && !mdio_node) { + dev_warn(dev, "No XPCS found\n"); + err = -ENODEV; + goto no_xpcs_found; + } } bus_register_done: @@ -534,6 +540,9 @@ int stmmac_mdio_register(struct net_device *ndev) return 0; +no_xpcs_found: +no_phy_found: + mdiobus_unregister(new_bus); bus_register_fail: mdiobus_free(new_bus); return err;