[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fa686aa40904172308l38919bc0jfffbeb3a4106f582@mail.gmail.com>
Date: Sat, 18 Apr 2009 00:08:32 -0600
From: Grant Likely <grant.likely@...retlab.ca>
To: Andy Fleming <afleming@...escale.com>
Cc: netdev@...r.kernel.org, linuxppc-dev@...abs.org, olof@...om.net,
galak@...nel.crashing.org,
Anton Vorontsov <avorontsov@...mvista.com>,
Joakim Tjernlund <Joakim.Tjernlund@...nsmode.se>
Subject: Re: [PATCH 05/14] phylib: add *_direct() variants of phy_connect and
phy_attach functions
On Wed, Apr 15, 2009 at 3:10 PM, Andy Fleming <afleming@...escale.com> wrote:
>
> On Mar 31, 2009, at 3:27 AM, Grant Likely wrote:
>
>> From: Grant Likely <grant.likely@...retlab.ca>
>>
>> Add phy_connect_direct() and phy_attach_direct() functions so that
>> drivers can use a pointer to the phy_device instead of trying to determine
>> the phy's bus_id string.
>>
>> This patch is useful for OF device tree descriptions of phy devices where
>> 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 <grant.likely@...retlab.ca>
>> ---
>> @@ -312,18 +339,21 @@ struct phy_device * phy_connect(struct net_device
>> *dev, const char *bus_id,
>> phy_interface_t interface)
>> {
>> struct phy_device *phydev;
>> + struct device *d;
>> + int rc;
>>
>> - phydev = phy_attach(dev, bus_id, flags, interface);
>> -
>> - if (IS_ERR(phydev))
>> - return phydev;
>> -
>> - phy_prepare_link(phydev, handler);
>> -
>> - phy_start_machine(phydev, NULL);
>> + /* Search the list of PHY devices on the mdio bus for the
>> + * PHY with the requested name */
>> + d = bus_find_device_by_name(&mdio_bus_type, NULL, bus_id);
>> + if (!d) {
>> + pr_err("PHY %s not found\n", bus_id);
>> + return ERR_PTR(-ENODEV);
>> + }
>> + phydev = to_phy_device(d);
>>
>> - if (phydev->irq > 0)
>> - phy_start_interrupts(phydev);
>> + rc = phy_attach_direct(dev, phydev, flags, interface);
>> + if (rc)
>> + return ERR_PTR(rc);
>
>
> Why not just invoke phy_attach(), here, and thereby avoid the duplicate
> search code?
Yeah, you're right. I had done it this way for symmetry, but calling
phy_attach_direct is probably better.
g.
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists