Subject: Re: [PATCH net-next] mdio: mdiobus: setup of_node for the MDIO device

From: "Russell King (Oracle)" <[email-masked]>
Date: Wed, 16 Jun 2021 10:40:12 +0100

On Wed, Jun 16, 2021 at 11:20:52AM +0300, Ioana Ciornei wrote:
> On Tue, Jun 15, 2021 at 11:31:47PM +0200, Andrew Lunn wrote:
> > > The fwnode_operations declared in drivers/acpi/property.c also suggest
> > > the ACPI fwnodes are not refcounted.
> > 
> > Is this because ACPI is not dynamic, unlike DT, where you can
> > add/remove overlays at runtime?
> > 
> 
> I am really not an expert here but the git history suggests so, yes.
> 
> Without the CONFIG_OF_DYNAMIC enabled, the fwnode_handle_get() call is
> actually a no-op even in the OF case.

More accurately, of_node_get() is a no-op if CONFIG_OF_DYNAMIC is
disabled, which in turn makes fwnode_handle_get() also a no-op.

I'm wondering whether we would need two helpers to assign these, or
just a single helper that takes a fwnode and assigns both pointers.
to_of_node() returns NULL if the fwnode is not a DT node, so would
be safe to use even with ACPI.

Then there's the cleanup side when the device is released. I haven't
yet found where we release the reference to the fwnode/of_node when
we release the phy_device. I would have expected it in
phy_device_release() but that does nothing. We could only add that
when we are certain that all users who assign the firmware node to
the phy device has properly refcounted it in the DT case.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!