Skip to content

Commit

Permalink
net: renesas: rswitch: Convert to for_each_available_child_of_node()
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/54f544d573a64b96e01fd00d3481b10806f4d110.1738771798.git.geert+renesas@glider.be
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Geert Uytterhoeven authored and Jakub Kicinski committed Feb 7, 2025
1 parent 02c9722 commit 7bca2b2
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/net/ethernet/renesas/rswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7bca2b2

Please sign in to comment.