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@xxxxxxxxx> --- 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