Skip to content

Commit

Permalink
stmmac: mdio register has to fail if the phy is not found
Browse files Browse the repository at this point in the history
With this patch the stmmac fails in case of the phy device
is not found; w/o this fix the mdio can be register twice when
do down/up the iface and this is not correct.

Reported-by: Stas <stsp@list.ru>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Giuseppe CAVALLARO authored and David S. Miller committed Feb 11, 2013
1 parent de53d55 commit 3955b22
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ int stmmac_mdio_register(struct net_device *ndev)
goto bus_register_fail;
}

priv->mii = new_bus;

found = 0;
for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
struct phy_device *phydev = new_bus->phy_map[addr];
Expand Down Expand Up @@ -237,8 +235,14 @@ int stmmac_mdio_register(struct net_device *ndev)
}
}

if (!found)
if (!found) {
pr_warning("%s: No PHY found\n", ndev->name);
mdiobus_unregister(new_bus);
mdiobus_free(new_bus);
return -ENODEV;
}

priv->mii = new_bus;

return 0;

Expand Down

0 comments on commit 3955b22

Please sign in to comment.