[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGXr9JFGD6TXvOszghKJqchTsb9_xbm76U98sgWCUeg8dfP0yA@mail.gmail.com>
Date: Tue, 7 Oct 2014 09:48:40 -0700
From: Petri Gynther <pgynther@...gle.com>
To: David Miller <davem@...emloft.net>
Cc: netdev@...r.kernel.org, Florian Fainelli <f.fainelli@...il.com>,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
Subject: Re: [PATCH v2 net-next] net: phy: adjust fixed_phy_register() return value
Hi David,
On Mon, Oct 6, 2014 at 9:07 PM, David Miller <davem@...emloft.net> wrote:
> From: Petri Gynther <pgynther@...gle.com>
> Date: Mon, 6 Oct 2014 11:38:30 -0700 (PDT)
>
>> Adjust fixed_phy_register() to return struct phy_device *, so that
>> it becomes easy to use fixed PHYs without device tree support:
>>
>> phydev = fixed_phy_register(PHY_POLL, &fixed_phy_status, NULL);
>> fixed_phy_set_link_update(phydev, fixed_phy_link_update);
>> phy_connect_direct(netdev, phydev, handler_fn, phy_interface);
>>
>> This change is a prerequisite for modifying bcmgenet driver to work
>> without a device tree on Broadcom's MIPS-based 7xxx platforms.
>>
>> Signed-off-by: Petri Gynther <pgynther@...gle.com>
>
> If the caller gets this 'phy' pointer and does something with it,
> something seems amiss.
>
> We don't hold an extra reference to the 'phy' object for the caller,
> so another thread of control can unregister it and kill that last
> reference and therefore free it up.
>
> I think to be legitimate, you have to hold an extra reference on
> 'phy' for the caller. And now that means that code paths that
> don't need to do anything with 'phy' now will need to release
> that reference.
I'm not sure if I understand your comment. The caller of
fixed_phy_register() now gets the pointer to the phydev created by
get_phy_device(). What other thread is aware of this pointer and how
could they free it? Isn't the caller of fixed_phy_register()
exclusively in charge of the created phydev?
I'm trying to make fixed_phy_device() more convenient to use, so that
drivers don't need to make separate calls to fixed_phy_add() +
get_phy_device() + phy_device_register().
-- Petri
--
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