* [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node()
@ 2025-02-05 16:12 Geert Uytterhoeven
2025-02-05 16:15 ` Nikita Yushchenko
2025-02-07 20:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2025-02-05 16:12 UTC (permalink / raw)
To: Yoshihiro Shimoda, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Nikita Yushchenko,
Niklas Söderlund
Cc: netdev, linux-renesas-soc, Geert Uytterhoeven
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.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
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(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 84d09a8973b78ee5..aba772e14555d308 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -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:
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node()
2025-02-05 16:12 [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node() Geert Uytterhoeven
@ 2025-02-05 16:15 ` Nikita Yushchenko
2025-02-05 16:18 ` Geert Uytterhoeven
2025-02-07 20:10 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Nikita Yushchenko @ 2025-02-05 16:15 UTC (permalink / raw)
To: Geert Uytterhoeven, Yoshihiro Shimoda, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Niklas Söderlund
Cc: netdev, linux-renesas-soc
Hello Geert.
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node()
2025-02-05 16:15 ` Nikita Yushchenko
@ 2025-02-05 16:18 ` Geert Uytterhoeven
2025-02-06 16:31 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2025-02-05 16:18 UTC (permalink / raw)
To: Nikita Yushchenko
Cc: Yoshihiro Shimoda, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Niklas Söderlund, netdev,
linux-renesas-soc
Hi Nikita,
On Wed, 5 Feb 2025 at 17:15, Nikita Yushchenko
<nikita.yoush@cogentembedded.com> 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.
>
> 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
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node()
2025-02-05 16:18 ` Geert Uytterhoeven
@ 2025-02-06 16:31 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2025-02-06 16:31 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Nikita Yushchenko, Yoshihiro Shimoda, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Niklas Söderlund, netdev, linux-renesas-soc
On Wed, Feb 05, 2025 at 05:18:14PM +0100, Geert Uytterhoeven wrote:
> Hi Nikita,
>
> On Wed, 5 Feb 2025 at 17:15, Nikita Yushchenko
> <nikita.yoush@cogentembedded.com> 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.
> >
> > 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.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node()
2025-02-05 16:12 [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node() Geert Uytterhoeven
2025-02-05 16:15 ` Nikita Yushchenko
@ 2025-02-07 20:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-07 20:10 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: yoshihiro.shimoda.uh, andrew+netdev, davem, edumazet, kuba,
pabeni, nikita.yoush, niklas.soderlund+renesas, netdev,
linux-renesas-soc
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
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.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> 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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-07 20:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 16:12 [PATCH net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node() Geert Uytterhoeven
2025-02-05 16:15 ` Nikita Yushchenko
2025-02-05 16:18 ` Geert Uytterhoeven
2025-02-06 16:31 ` Simon Horman
2025-02-07 20:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).