Commit 7455a76f authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

macb: straighten out macb_mii_probe function

Use "phy_find_first" instead of manual lookup. Also use "phy_connect_direct"
instead of "phy_connect" since we already have phy_device pointer here.
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Acked-by: default avatarHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4cd24eaf
...@@ -189,18 +189,11 @@ static void macb_handle_link_change(struct net_device *dev) ...@@ -189,18 +189,11 @@ static void macb_handle_link_change(struct net_device *dev)
static int macb_mii_probe(struct net_device *dev) static int macb_mii_probe(struct net_device *dev)
{ {
struct macb *bp = netdev_priv(dev); struct macb *bp = netdev_priv(dev);
struct phy_device *phydev = NULL; struct phy_device *phydev;
struct eth_platform_data *pdata; struct eth_platform_data *pdata;
int phy_addr; int ret;
/* find the first phy */
for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
if (bp->mii_bus->phy_map[phy_addr]) {
phydev = bp->mii_bus->phy_map[phy_addr];
break;
}
}
phydev = phy_find_first(bp->mii_bus);
if (!phydev) { if (!phydev) {
printk (KERN_ERR "%s: no PHY found\n", dev->name); printk (KERN_ERR "%s: no PHY found\n", dev->name);
return -1; return -1;
...@@ -210,17 +203,13 @@ static int macb_mii_probe(struct net_device *dev) ...@@ -210,17 +203,13 @@ static int macb_mii_probe(struct net_device *dev)
/* TODO : add pin_irq */ /* TODO : add pin_irq */
/* attach the mac to the phy */ /* attach the mac to the phy */
if (pdata && pdata->is_rmii) { ret = phy_connect_direct(dev, phydev, &macb_handle_link_change, 0,
phydev = phy_connect(dev, dev_name(&phydev->dev), pdata && pdata->is_rmii ?
&macb_handle_link_change, 0, PHY_INTERFACE_MODE_RMII); PHY_INTERFACE_MODE_RMII :
} else { PHY_INTERFACE_MODE_MII);
phydev = phy_connect(dev, dev_name(&phydev->dev), if (ret) {
&macb_handle_link_change, 0, PHY_INTERFACE_MODE_MII);
}
if (IS_ERR(phydev)) {
printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
return PTR_ERR(phydev); return ret;
} }
/* mask with MAC supported features */ /* mask with MAC supported features */
......
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