netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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).