Skip to contentSkip to conversation

net: renesas: rswitch: Convert to for_each_available_child_of_node()

PATCH Applied Geert Uytterhoeven 5 participants 5 messages Feb 5, 2025 – Feb 7, 2025

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

PATCH 1/1 net: renesas: rswitch: Convert to for_each_available_child_of_node()

Simplify rswitch_get_port_node() by using the for_each_available_child_of_node() helper instead of manually ignoring unavailable child nodes, and leaking a reference.

---
Tested on R-Car S4 Starter Kit, which has port 2 disabled.

---
 drivers/net/ethernet/renesas/rswitch.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/renesas/rswitch.c +2 -5
index 84d09a8973b78ee5..aba772e14555d308 100644
@@ -1287,17 +1287,14 @@ static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev)
 	if (!ports)
 		return NULL;
 
-	for_each_child_of_node(ports, port) {
+	for_each_available_child_of_node(ports, port) {
 		err = of_property_read_u32(port, "reg", &index);
 		if (err < 0) {
 			port = NULL;
 			goto out;
 		}
-		if (index == rdev->etha->index) {
-			if (!of_device_is_available(port))
-				port = NULL;
+		if (index == rdev->etha->index)
 			break;
-		}
 	}
 
 out:
Signature · 1 line
2.43.0
#1 lore raw

Hello Geert.

Quoted 3 lines

Simplify rswitch_get_port_node() by using the for_each_available_child_of_node() helper instead of manually ignoring unavailable child nodes, and leaking a reference.

FYI, I have a patch in my queue that replaces this code with traversing child nodes (via for_each_available_child_of_node()) and only creating devices for ports actually defined in the device tree.

Nikita

#2 lore raw

Hi Nikita,

Quoted 6 lines · Nikita Yushchenko
Quoted 3 lines

Simplify rswitch_get_port_node() by using the for_each_available_child_of_node() helper instead of manually ignoring unavailable child nodes, and leaking a reference.

FYI, I have a patch in my queue that replaces this code with traversing child nodes (via for_each_available_child_of_node()) and only creating devices for ports actually defined in the device tree.

OK, thanks for letting me know!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
reviewer Reviewed-by
#3 lore raw
Quoted 4 lines · Geert Uytterhoeven

Hi Nikita,

On Wed, 5 Feb 2025 at 17:15, Nikita Yushchenko
<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Simplify rswitch_get_port_node() by using the for_each_available_child_of_node() helper instead of manually ignoring unavailable child nodes, and leaking a reference.

FYI, I have a patch in my queue that replaces this code with traversing child nodes (via for_each_available_child_of_node()) and only creating devices for ports actually defined in the device tree.

OK, thanks for letting me know!

I am assuming that we can treat Nikita's patch as being orthogonal to this one.

#4 lore raw
In reply to Geert Uytterhoeven
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Wed, 5 Feb 2025 17:12:09 +0100 you wrote:

Simplify rswitch_get_port_node() by using the for_each_available_child_of_node() helper instead of manually ignoring unavailable child nodes, and leaking a reference.

---
Tested on R-Car S4 Starter Kit, which has port 2 disabled.

[...]

Here is the summary with links:
- [net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node()

    https://git.kernel.org/netdev/net-next/c/7bca2b2d5fcc

You are awesome, thank you!

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