[PATCH net-next] net: dsa: mt7530: register OF node for internal MDIO bus

Andrew Lunn andrew at lunn.ch
Thu Dec 21 01:27:24 PST 2023


> > @@ -2177,7 +2180,9 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
> >  	if (priv->irq)
> >  		mt7530_setup_mdio_irq(priv);
> >  
> > -	ret = devm_mdiobus_register(dev, bus);
> > +	mnp = of_get_child_by_name(np, "mdio");
> 
> If the node is not found, then the return value would be NULL.
> Though devm_of_mdiobus_register() and of_node_put() take care of NULL references,
> other drivers that use devm_of_mdiobus_register() mostly perform a early exit if the node is NULL.

Actually, many don't as well. of_mdiobus_register() falls back to
mdiobus_register() is np==NULL. That causes a scan of the bus to find
all the PHYs and you can then use phy_find_first() to access them.

So this code is O.K.

   Andrew



More information about the linux-arm-kernel mailing list