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

From: David Miller
Date: Tue Oct 01 2019 - 13:27:57 EST


From: Andrew Lunn <andrew@xxxxxxx>
Date: Tue, 1 Oct 2019 18:43:40 +0200

> 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>

Aha I didn't think about it that way...

Ok I'll apply this thanks.