Commit 637f33b8 authored by Jonas Bonn's avatar Jonas Bonn Committed by David S. Miller

ethoc: Clean up PHY probing

- No need to iterate over all possible addresses on bus
- Use helper function phy_find_first
- Use phy_connect_direct as we already have the relevant structure
Signed-off-by: default avatarJonas Bonn <jonas@southpole.se>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ee4f56b9
...@@ -635,21 +635,13 @@ static int ethoc_mdio_probe(struct net_device *dev) ...@@ -635,21 +635,13 @@ static int ethoc_mdio_probe(struct net_device *dev)
{ {
struct ethoc *priv = netdev_priv(dev); struct ethoc *priv = netdev_priv(dev);
struct phy_device *phy; struct phy_device *phy;
int err;
int i; int i;
for (i = 0; i < PHY_MAX_ADDR; i++) { if (priv->phy_id != -1) {
phy = priv->mdio->phy_map[i]; phy = priv->mdio->phy_map[priv->phy_id];
if (phy) { } else {
if (priv->phy_id != -1) { phy = phy_find_first(priv->mdio);
/* attach to specified PHY */
if (priv->phy_id == phy->addr)
break;
} else {
/* autoselect PHY if none was specified */
if (phy->addr != 0)
break;
}
}
} }
if (!phy) { if (!phy) {
...@@ -657,11 +649,11 @@ static int ethoc_mdio_probe(struct net_device *dev) ...@@ -657,11 +649,11 @@ static int ethoc_mdio_probe(struct net_device *dev)
return -ENXIO; return -ENXIO;
} }
phy = phy_connect(dev, dev_name(&phy->dev), ethoc_mdio_poll, 0, err = phy_connect_direct(dev, phy, ethoc_mdio_poll, 0,
PHY_INTERFACE_MODE_GMII); PHY_INTERFACE_MODE_GMII);
if (IS_ERR(phy)) { if (err) {
dev_err(&dev->dev, "could not attach to PHY\n"); dev_err(&dev->dev, "could not attach to PHY\n");
return PTR_ERR(phy); return err;
} }
priv->phy = phy; priv->phy = phy;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment