aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/macb.c
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2010-02-08 00:12:08 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-12 14:38:58 -0500
commit7455a76f170f794498d26081a5f15b797ef1a2aa (patch)
tree5a746de142377240d8cd0cbe7ac469ccab5171a2 /drivers/net/macb.c
parent4cd24eaf0c6ee7f0242e34ee77ec899f255e66b5 (diff)
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: Jiri Pirko <jpirko@redhat.com> Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macb.c')
-rw-r--r--drivers/net/macb.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index fbc371fa19b5..7a5f89728a81 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -189,18 +189,11 @@ static void macb_handle_link_change(struct net_device *dev)
189static int macb_mii_probe(struct net_device *dev) 189static int macb_mii_probe(struct net_device *dev)
190{ 190{
191 struct macb *bp = netdev_priv(dev); 191 struct macb *bp = netdev_priv(dev);
192 struct phy_device *phydev = NULL; 192 struct phy_device *phydev;
193 struct eth_platform_data *pdata; 193 struct eth_platform_data *pdata;
194 int phy_addr; 194 int ret;
195
196 /* find the first phy */
197 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
198 if (bp->mii_bus->phy_map[phy_addr]) {
199 phydev = bp->mii_bus->phy_map[phy_addr];
200 break;
201 }
202 }
203 195
196 phydev = phy_find_first(bp->mii_bus);
204 if (!phydev) { 197 if (!phydev) {
205 printk (KERN_ERR "%s: no PHY found\n", dev->name); 198 printk (KERN_ERR "%s: no PHY found\n", dev->name);
206 return -1; 199 return -1;
@@ -210,17 +203,13 @@ static int macb_mii_probe(struct net_device *dev)
210 /* TODO : add pin_irq */ 203 /* TODO : add pin_irq */
211 204
212 /* attach the mac to the phy */ 205 /* attach the mac to the phy */
213 if (pdata && pdata->is_rmii) { 206 ret = phy_connect_direct(dev, phydev, &macb_handle_link_change, 0,
214 phydev = phy_connect(dev, dev_name(&phydev->dev), 207 pdata && pdata->is_rmii ?
215 &macb_handle_link_change, 0, PHY_INTERFACE_MODE_RMII); 208 PHY_INTERFACE_MODE_RMII :
216 } else { 209 PHY_INTERFACE_MODE_MII);
217 phydev = phy_connect(dev, dev_name(&phydev->dev), 210 if (ret) {
218 &macb_handle_link_change, 0, PHY_INTERFACE_MODE_MII);
219 }
220
221 if (IS_ERR(phydev)) {
222 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 211 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
223 return PTR_ERR(phydev); 212 return ret;
224 } 213 }
225 214
226 /* mask with MAC supported features */ 215 /* mask with MAC supported features */