Skip to contentSkip to conversation

net: macb: Fix mdio child node detection

PATCH Applied Guenter Roeck 5 participants 5 messages Oct 26, 2021 – Oct 28, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: macb: Fix mdio child node detection

Commit 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists") added code to detect if a 'mdio' child node exists to the macb driver. Ths added code does, however, not actually check if the child node exists, but if the parent node exists. This results in errors such as

macb 10090000.ethernet eth0: Could not attach PHY (-19)

if there is no 'mdio' child node. Fix the code to actually check for the child node.

Fixes 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists")
Cc Sean Anderson <[email protected]>
Cc Andrew Lunn <[email protected]>
---
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -1
index 309371abfe23..ffce528aa00e 100644
@@ -901,7 +901,7 @@ static int macb_mdiobus_register(struct macb *bp)
 	 * directly under the MAC node
 	 */
 	child = of_get_child_by_name(np, "mdio");
-	if (np) {
+	if (child) {
 		int ret = of_mdiobus_register(bp->mii_bus, child);
 
 		of_node_put(child);
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Guenter Roeck

Commit 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists") added code to detect if a 'mdio' child node exists to the macb driver. Ths added code does, however, not actually check if the child node exists, but if the parent node exists. This results in errors such as

macb 10090000.ethernet eth0: Could not attach PHY (-19)

if there is no 'mdio' child node. Fix the code to actually check for the child node.

Fixes 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists")
Cc Sean Anderson <[email protected]>
Cc Andrew Lunn <[email protected]>
---
  drivers/net/ethernet/cadence/macb_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index 309371abfe23..ffce528aa00e 100644

drivers/net/ethernet/cadence/macb_main.c static int macb_mdiobus_register(struct macb *bp) · line 907

Quoted 8 lines
drivers/net/ethernet/cadence/macb_main.c +1 -1
@@ -901,7 +901,7 @@ static int macb_mdiobus_register(struct macb *bp)
  	 * directly under the MAC node
  	 */
  	child = of_get_child_by_name(np, "mdio");
-	if (np) {
+	if (child) {
  		int ret = of_mdiobus_register(bp->mii_bus, child);
 
  		of_node_put(child);

Thanks for catching this.

Tested-by on v1 1/1
#2 lore raw
In reply to Guenter Roeck
Quoted 9 lines · Guenter Roeck

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Commit 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists") added code to detect if a 'mdio' child node exists to the macb driver. Ths added code does, however, not actually check if the child node exists, but if the parent node exists. This results in errors such as

macb 10090000.ethernet eth0: Could not attach PHY (-19)

Quoted 7 lines

if there is no 'mdio' child node. Fix the code to actually check for the child node.

Fixes 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists")
Cc Sean Anderson <[email protected]>
Cc Andrew Lunn <[email protected]>

Patch solves the failure also on sama5d2_xplained. You can add:

Thank you,
Claudiu Beznea

Quoted 19 lines
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -2
index 309371abfe23..ffce528aa00e 100644
@@ -901,7 +901,7 @@ static int macb_mdiobus_register(struct macb *bp)
         * directly under the MAC node
         */
        child = of_get_child_by_name(np, "mdio");
-       if (np) {
+       if (child) {
                int ret = of_mdiobus_register(bp->mii_bus, child);
 
                of_node_put(child);
--

2.33.0

Acked-by
#3 lore raw
Quoted 11 lines · On 27/10/2021 at 10:38, Claudiu Beznea - M18063 wrote:
Quoted 10 lines · Guenter Roeck

Commit 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists") added code to detect if a 'mdio' child node exists to the macb driver. Ths added code does, however, not actually check if the child node exists, but if the parent node exists. This results in errors such as

macb 10090000.ethernet eth0: Could not attach PHY (-19)

if there is no 'mdio' child node. Fix the code to actually check for the child node.

Quoted 8 lines
Quoted 4 lines
Fixes 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists")
Cc Sean Anderson <[email protected]>
Cc Andrew Lunn <[email protected]>

Patch solves the failure also on sama5d2_xplained. You can add:

Guener, Claudiu, thanks so much!

Best regards,
Nicolas

Quoted 20 lines
Quoted 19 lines
  drivers/net/ethernet/cadence/macb_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -2
index 309371abfe23..ffce528aa00e 100644
@@ -901,7 +901,7 @@ static int macb_mdiobus_register(struct macb *bp)
          * directly under the MAC node
          */
         child = of_get_child_by_name(np, "mdio");
-       if (np) {
+       if (child) {
                 int ret = of_mdiobus_register(bp->mii_bus, child);
 
                 of_node_put(child);
--

2.33.0

Signature · 1 line
Nicolas Ferre
#4 lore raw
In reply to Guenter Roeck
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 26 Oct 2021 10:39:50 -0700 you wrote:

Commit 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO bus if it exists") added code to detect if a 'mdio' child node exists to the macb driver. Ths added code does, however, not actually check if the child node exists, but if the parent node exists. This results in errors such as

macb 10090000.ethernet eth0: Could not attach PHY (-19)

[...]

Here is the summary with links:
- net: macb: Fix mdio child node detection

    https://git.kernel.org/netdev/net-next/c/8db3cbc50748

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html