Re: [PATCH net v2] net: ag71xx: fix mdio subnode support

From: Andrew Lunn
Date: Tue Oct 01 2019 - 12:52:04 EST


On Tue, Oct 01, 2019 at 09:03:20AM -0700, David Miller wrote:
> From: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
> Date: Tue, 1 Oct 2019 08:41:47 +0200
>
> > @@ -571,7 +571,9 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
> > msleep(200);
> > }
> >
> > - err = of_mdiobus_register(mii_bus, np);
> > + mnp = of_get_child_by_name(np, "mdio");
> > + err = of_mdiobus_register(mii_bus, mnp);
>
> of_get_child_by_name() can fail, so error checking is necessary
> before you pass mnp into of_mdiobus_register().

Hi David

/**
* of_get_child_by_name - Find the child node by name for a given parent
* @node: parent node
* @name: child name to look for.
*
* This function looks for child node for given matching name
*
* Returns a node pointer if found, with refcount incremented, use
* of_node_put() on it when done.
* Returns NULL if node is not found.
*/

So on error, it returns NULL. And passing NULL to
of_mdiobus_register() is the correct thing to do if there is no DT
node. of_node_put() is also O.K. with NULL.

So this is all O.K. as is.

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Andrew