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

From: "Russell King (Oracle)" <[email-masked]>
Date: Tue, 15 Jun 2021 18:13:31 +0100

On Tue, Jun 15, 2021 at 06:44:01PM +0300, Ioana Ciornei wrote:
> From: Ioana Ciornei <[email-masked]>
> 
> By mistake, the of_node of the MDIO device was not setup in the patch
> linked below. As a consequence, any PHY driver that depends on the
> of_node in its probe callback was not be able to successfully finish its
> probe on a PHY, thus the Generic PHY driver was used instead.
> 
> Fix this by actually setting up the of_node.
> 
> Fixes: bc1bee3b87ee ("net: mdiobus: Introduce fwnode_mdiobus_register_phy()")
> Signed-off-by: Ioana Ciornei <[email-masked]>
> ---
>  drivers/net/mdio/fwnode_mdio.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
> index e96766da8de4..283ddb1185bd 100644
> --- a/drivers/net/mdio/fwnode_mdio.c
> +++ b/drivers/net/mdio/fwnode_mdio.c
> @@ -65,6 +65,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
>  	 * can be looked up later
>  	 */
>  	fwnode_handle_get(child);
> +	phy->mdio.dev.of_node = to_of_node(child);
>  	phy->mdio.dev.fwnode = child;

Yes, this is something that was missed, but let's first look at what
other places to when setting up a device:

        pdev->dev.fwnode = pdevinfo->fwnode;
        pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
        pdev->dev.of_node_reused = pdevinfo->of_node_reused;

        dev->dev.of_node = of_node_get(np);
        dev->dev.fwnode = &np->fwnode;

        dev->dev.of_node = of_node_get(node);
        dev->dev.fwnode = &node->fwnode;

That seems to be pretty clear that an of_node_get() is also needed.

Thanks.

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