From patchwork Tue Nov 26 09:55:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: shaohui xie X-Patchwork-Id: 294301 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 841AB2C0097 for ; Tue, 26 Nov 2013 22:15:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756634Ab3KZLO5 (ORCPT ); Tue, 26 Nov 2013 06:14:57 -0500 Received: from co1ehsobe005.messaging.microsoft.com ([216.32.180.188]:8737 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756597Ab3KZLOz (ORCPT ); Tue, 26 Nov 2013 06:14:55 -0500 Received: from mail216-co1-R.bigfish.com (10.243.78.225) by CO1EHSOBE030.bigfish.com (10.243.66.95) with Microsoft SMTP Server id 14.1.225.22; Tue, 26 Nov 2013 11:14:55 +0000 Received: from mail216-co1 (localhost [127.0.0.1]) by mail216-co1-R.bigfish.com (Postfix) with ESMTP id EC14EC4069C; Tue, 26 Nov 2013 11:14:54 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(z1039mz13e6Kzz1f42h1ee6h1ce5h1fdah201ch2073h2146h1202h1fd0h1e76h1d1ah1cabh1d2ah1fc6hzz1de098h8275bh1de097hz31h87h2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h15a8h162dh1631h1758h17eeh1898h18e1h1946h19b5h1ad9h1b0ah1b2fh224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h129fi1151h1155h) Received-SPF: softfail (mail216-co1: transitioning domain of gmail.com does not designate 70.37.183.190 as permitted sender) client-ip=70.37.183.190; envelope-from=shh.xie@gmail.com; helo=mail.freescale.net ; reescale.net ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail216-co1 (localhost.localdomain [127.0.0.1]) by mail216-co1 (MessageSwitch) id 138546449373702_25616; Tue, 26 Nov 2013 11:14:53 +0000 (UTC) Received: from CO1EHSMHS008.bigfish.com (unknown [10.243.78.242]) by mail216-co1.bigfish.com (Postfix) with ESMTP id 0D4DC700060; Tue, 26 Nov 2013 11:14:53 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS008.bigfish.com (10.243.66.18) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 26 Nov 2013 11:14:52 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.3.158.2; Tue, 26 Nov 2013 11:14:51 +0000 Received: from Tank.am.freescale.net (tank.ap.freescale.net [10.193.20.104]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id rAQBEm5T024565; Tue, 26 Nov 2013 04:14:48 -0700 From: To: , , , , , CC: , Subject: [PATCH 4/5] phylib: Support attaching to generic 10g driver Date: Tue, 26 Nov 2013 17:55:07 +0800 Message-ID: <1385459707-32467-1-git-send-email-shh.xie@gmail.com> X-Mailer: git-send-email 1.8.4.1 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Andy Fleming phy_attach_direct() may now attach to a generic 10G driver. It can also be used exactly as phy_connect_direct(), which will be useful when using of_mdio, as phy_connect (and therefore of_phy_connect) start the PHY state machine, which is currently irrelevant for 10G PHYs. Signed-off-by: Andy Fleming Signed-off-by: Shaohui Xie Acked-by: Florian Fainelli --- v2: align with the array genphy_driver. drivers/net/phy/phy_device.c | 22 ++++++++++------------ include/linux/phy.h | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 96a5e03..a6b4ce0 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -61,9 +61,6 @@ extern void mdio_bus_exit(void); static LIST_HEAD(phy_fixup_list); static DEFINE_MUTEX(phy_fixup_lock); -static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, - u32 flags, phy_interface_t interface); - /* * Creates a new phy_fixup and adds it to the list * @bus_id: A string which matches phydev->dev.bus_id (or PHY_ANY_ID) @@ -521,12 +518,12 @@ int phy_init_hw(struct phy_device *phydev) * * Description: Called by drivers to attach to a particular PHY * device. The phy_device is found, and properly hooked up - * to the phy_driver. If no driver is attached, then the - * genphy_driver is used. The phy_device is given a ptr to + * to the phy_driver. If no driver is attached, then a + * generic driver is used. The phy_device is given a ptr to * the attaching device, and given a callback for link status * change. The phy_device is returned to the attaching driver. */ -static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, +int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, u32 flags, phy_interface_t interface) { struct device *d = &phydev->dev; @@ -535,12 +532,10 @@ static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, /* Assume that if there is no driver, that it doesn't * exist, and we should use the genphy driver. */ if (NULL == d->driver) { - if (phydev->is_c45) { - pr_err("No driver for phy %x\n", phydev->phy_id); - return -ENODEV; - } - - d->driver = &genphy_driver[0].driver; + if (phydev->is_c45) + d->driver = &genphy_driver[1].driver; + else + d->driver = &genphy_driver[0].driver; err = d->driver->probe(d); if (err >= 0) @@ -573,6 +568,7 @@ static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, return err; } +EXPORT_SYMBOL(phy_attach_direct); /** * phy_attach - attach a network device to a particular PHY device @@ -623,6 +619,8 @@ void phy_detach(struct phy_device *phydev) * real driver could be loaded */ if (phydev->dev.driver == &genphy_driver[0].driver) device_release_driver(&phydev->dev); + else if (phydev->dev.driver == &genphy_driver[1].driver) + device_release_driver(&phydev->dev); } EXPORT_SYMBOL(phy_detach); diff --git a/include/linux/phy.h b/include/linux/phy.h index 2606599..00abc35 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -575,6 +575,8 @@ int phy_init_hw(struct phy_device *phydev); struct phy_device * phy_attach(struct net_device *dev, const char *bus_id, phy_interface_t interface); struct phy_device *phy_find_first(struct mii_bus *bus); +int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, + u32 flags, phy_interface_t interface); int phy_connect_direct(struct net_device *dev, struct phy_device *phydev, void (*handler)(struct net_device *), phy_interface_t interface);