提交 5a8d7f12 编写于 作者: F Florian Fainelli 提交者: David S. Miller

of: of_mdio: Correct loop scanning logic

Commit 209c65b6 ("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: 209c65b6 ("drivers/of/of_mdio.c:fix of_mdiobus_register()")
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6564cfef
......@@ -314,10 +314,15 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
child, addr);
if (of_mdiobus_child_is_phy(child)) {
/* -ENODEV is the return code that PHYLIB has
* standardized on to indicate that bus
* scanning should continue.
*/
rc = of_mdiobus_register_phy(mdio, child, addr);
if (rc && rc != -ENODEV)
if (!rc)
break;
if (rc != -ENODEV)
goto unregister;
break;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册