Skip to content

Commit 5a8d7f1

Browse files
ffainellidavem330
authored andcommitted
of: of_mdio: Correct loop scanning logic
Commit 209c65b ("drivers/of/of_mdio.c:fix of_mdiobus_register()") introduced a break of the loop on the premise that a successful registration should exit the loop. The premise is correct but not to code, because rc && rc != -ENODEV is just a special error condition, that means we would exit the loop even with rc == -ENODEV which is absolutely not correct since this is the error code to indicate to the MDIO bus layer that scanning should continue. Fix this by explicitly checking for rc = 0 as the only valid condition to break out of the loop. Fixes: 209c65b ("drivers/of/of_mdio.c:fix of_mdiobus_register()") Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6564cfe commit 5a8d7f1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/of/of_mdio.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,15 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
314314
child, addr);
315315

316316
if (of_mdiobus_child_is_phy(child)) {
317+
/* -ENODEV is the return code that PHYLIB has
318+
* standardized on to indicate that bus
319+
* scanning should continue.
320+
*/
317321
rc = of_mdiobus_register_phy(mdio, child, addr);
318-
if (rc && rc != -ENODEV)
322+
if (!rc)
323+
break;
324+
if (rc != -ENODEV)
319325
goto unregister;
320-
break;
321326
}
322327
}
323328
}

0 commit comments

Comments
 (0)