From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-gx0-f157.google.com (mail-gx0-f157.google.com [209.85.217.157]) by ozlabs.org (Postfix) with ESMTP id 6D1F2DE17C for ; Sat, 18 Apr 2009 16:18:52 +1000 (EST) Received: by gxk1 with SMTP id 1so2466049gxk.9 for ; Fri, 17 Apr 2009 23:18:50 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20090331075537.1427.7819.stgit@localhost.localdomain> <20090331082709.1427.48689.stgit@localhost.localdomain> From: Grant Likely Date: Sat, 18 Apr 2009 00:18:35 -0600 Message-ID: Subject: Re: [PATCH 05/14] phylib: add *_direct() variants of phy_connect and phy_attach functions To: Andy Fleming Content-Type: text/plain; charset=ISO-8859-1 Cc: Joakim Tjernlund , netdev@vger.kernel.org, linuxppc-dev@ozlabs.org, olof@lixom.net List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Sat, Apr 18, 2009 at 12:08 AM, Grant Likely wrote: > On Wed, Apr 15, 2009 at 3:10 PM, Andy Fleming wr= ote: >> >> On Mar 31, 2009, at 3:27 AM, Grant Likely wrote: >> >>> From: Grant Likely >>> >>> Add phy_connect_direct() and phy_attach_direct() functions so that >>> drivers can use a pointer to the phy_device instead of trying to determ= ine >>> the phy's bus_id string. >>> >>> This patch is useful for OF device tree descriptions of phy devices whe= re >>> the driver doesn't need or know what the bus_id value in order to get a >>> phy_device pointer. >>> >>> Signed-off-by: Grant Likely >>> --- >>> @@ -312,18 +339,21 @@ struct phy_device * phy_connect(struct net_device >>> *dev, const char *bus_id, >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0phy_interface_t interface) >>> { >>> =A0 =A0 =A0 =A0struct phy_device *phydev; >>> + =A0 =A0 =A0 struct device *d; >>> + =A0 =A0 =A0 int rc; >>> >>> - =A0 =A0 =A0 phydev =3D phy_attach(dev, bus_id, flags, interface); >>> - >>> - =A0 =A0 =A0 if (IS_ERR(phydev)) >>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return phydev; >>> - >>> - =A0 =A0 =A0 phy_prepare_link(phydev, handler); >>> - >>> - =A0 =A0 =A0 phy_start_machine(phydev, NULL); >>> + =A0 =A0 =A0 /* Search the list of PHY devices on the mdio bus for the >>> + =A0 =A0 =A0 =A0* PHY with the requested name */ >>> + =A0 =A0 =A0 d =3D bus_find_device_by_name(&mdio_bus_type, NULL, bus_i= d); >>> + =A0 =A0 =A0 if (!d) { >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_err("PHY %s not found\n", bus_id); >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return ERR_PTR(-ENODEV); >>> + =A0 =A0 =A0 } >>> + =A0 =A0 =A0 phydev =3D to_phy_device(d); >>> >>> - =A0 =A0 =A0 if (phydev->irq > 0) >>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 phy_start_interrupts(phydev); >>> + =A0 =A0 =A0 rc =3D phy_attach_direct(dev, phydev, flags, interface); >>> + =A0 =A0 =A0 if (rc) >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return ERR_PTR(rc); >> >> >> Why not just invoke phy_attach(), here, and thereby avoid the duplicate >> search code? > > Yeah, you're right. =A0I had done it this way for symmetry, but calling > phy_attach_direct is probably better. Actually, no, my change is buggy. I should be calling phy_connect_direct() here, not phy_attach_direct(). Plus, either way I do it there will be a few lines of duplicate code. It will be fixed in the next version. g. --=20 Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.