All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next-2.6] macb: straighten out macb_mii_probe function
@ 2010-02-08 15:12 Jiri Pirko
  2010-02-10  9:47 ` Haavard Skinnemoen
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Pirko @ 2010-02-08 15:12 UTC (permalink / raw)
  To: netdev; +Cc: hskinnemoen, davem

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>
---
 drivers/net/macb.c |   29 +++++++++--------------------
 1 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 1d0d4d9..2b92c90 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)
 static int macb_mii_probe(struct net_device *dev)
 {
 	struct macb *bp = netdev_priv(dev);
-	struct phy_device *phydev = NULL;
+	struct phy_device *phydev;
 	struct eth_platform_data *pdata;
-	int phy_addr;
-
-	/* 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;
-		}
-	}
+	int ret;
 
+	phydev = phy_find_first(bp->mii_bus);
 	if (!phydev) {
 		printk (KERN_ERR "%s: no PHY found\n", dev->name);
 		return -1;
@@ -210,17 +203,13 @@ static int macb_mii_probe(struct net_device *dev)
 	/* TODO : add pin_irq */
 
 	/* attach the mac to the phy */
-	if (pdata && pdata->is_rmii) {
-		phydev = phy_connect(dev, dev_name(&phydev->dev),
-			&macb_handle_link_change, 0, PHY_INTERFACE_MODE_RMII);
-	} else {
-		phydev = phy_connect(dev, dev_name(&phydev->dev),
-			&macb_handle_link_change, 0, PHY_INTERFACE_MODE_MII);
-	}
-
-	if (IS_ERR(phydev)) {
+	ret = phy_connect_direct(dev, phydev, &macb_handle_link_change, 0,
+				 pdata && pdata->is_rmii ?
+				 PHY_INTERFACE_MODE_RMII :
+				 PHY_INTERFACE_MODE_MII);
+	if (ret) {
 		printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
-		return PTR_ERR(phydev);
+		return ret;
 	}
 
 	/* mask with MAC supported features */
-- 
1.6.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next-2.6] macb: straighten out macb_mii_probe function
  2010-02-08 15:12 [PATCH net-next-2.6] macb: straighten out macb_mii_probe function Jiri Pirko
@ 2010-02-10  9:47 ` Haavard Skinnemoen
  2010-02-12 19:39   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Haavard Skinnemoen @ 2010-02-10  9:47 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, hskinnemoen, davem

Jiri Pirko <jpirko@redhat.com> wrote:
> 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>

Looks reasonable as far as I can see.

Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next-2.6] macb: straighten out macb_mii_probe function
  2010-02-10  9:47 ` Haavard Skinnemoen
@ 2010-02-12 19:39   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2010-02-12 19:39 UTC (permalink / raw)
  To: haavard.skinnemoen; +Cc: jpirko, netdev, hskinnemoen

From: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Date: Wed, 10 Feb 2010 15:17:06 +0530

> Jiri Pirko <jpirko@redhat.com> wrote:
>> 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>
> 
> Looks reasonable as far as I can see.
> 
> Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>

Applied, thanks guys.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-12 19:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08 15:12 [PATCH net-next-2.6] macb: straighten out macb_mii_probe function Jiri Pirko
2010-02-10  9:47 ` Haavard Skinnemoen
2010-02-12 19:39   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.