diff mbox series

[net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node()

Message ID 54f544d573a64b96e01fd00d3481b10806f4d110.1738771798.git.geert+renesas@glider.be (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: renesas: rswitch: Convert to for_each_available_child_of_node() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2025-02-05--21-00 (tests: 891)

Commit Message

Geert Uytterhoeven Feb. 5, 2025, 4:12 p.m. UTC
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(-)

Comments

Nikita Yushchenko Feb. 5, 2025, 4:15 p.m. UTC | #1
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
Geert Uytterhoeven Feb. 5, 2025, 4:18 p.m. UTC | #2
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
diff mbox series

Patch

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: