Subject: Re: [PATCH 2/3] net: of_mdio: add of_mdiobus_link_phydev()

From: Daniel Mack <[email-masked]>
Date: Sat, 24 May 2014 09:25:57 +0200

On 05/23/2014 09:35 PM, Florian Fainelli wrote:
> 2014-05-10 9:37 GMT-07:00 Daniel Mack <[email-masked]>:

>> +/**
>> + * of_mdiobus_link_phydev - Find a device node for a phy
>> + * @mdio: pointer to mii_bus structure
>> + * @phydev: phydev for which the of_node pointer should be set
>> + *
>> + * Walk the list of subnodes of a mdio bus and look for a node that matches the
>> + * phy's address with its 'reg' property. If found, set the of_node pointer for
>> + * the phy. This allows auto-probed pyh devices to be supplied with information
>> + * passed in via DT.
>> + */
>> +void of_mdiobus_link_phydev(struct mii_bus *mdio,
>> +                           struct phy_device *phydev)
>> +{
>> +       struct device *dev = &phydev->dev;
>> +       struct device_node *child;
>> +
>> +       if (dev->of_node)
>> +               return;
> 
> This should be:
> 
>             if (dev->of_node || !mdio->dev_of_node)
>                     return;
> 
> a system with for instance non-DT probed MDIO busses such as the
> special fixed MDIO bus will not have such an of_node pointer and we
> will have a null pointer during the first iteration of the for_each_*
> loop.
> 
> arguably of_get_next_available_child() could be updated to handle a
> NULL parent device_node, but I think it clearer to add this check
> here.

Good catch! I'll change that, add your Reviewed-by and resend!

Thanks,
Daniel