From patchwork Mon Feb 8 15:12:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 44800 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8E38CB7D17 for ; Tue, 9 Feb 2010 02:13:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753169Ab0BHPNU (ORCPT ); Mon, 8 Feb 2010 10:13:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52269 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752499Ab0BHPNT (ORCPT ); Mon, 8 Feb 2010 10:13:19 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o18FCASe027232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Feb 2010 10:12:10 -0500 Received: from localhost (psychotron.englab.brq.redhat.com [10.34.32.135]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o18FC8AL014912; Mon, 8 Feb 2010 10:12:09 -0500 Date: Mon, 8 Feb 2010 16:12:08 +0100 From: Jiri Pirko To: netdev@vger.kernel.org Cc: hskinnemoen@atmel.com, davem@davemloft.net Subject: [PATCH net-next-2.6] macb: straighten out macb_mii_probe function Message-ID: <20100208151207.GE2601@psychotron.lab.eng.brq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Haavard Skinnemoen --- 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 */