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 |
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
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 --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:
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(-)