1d055c02b257019129399507fa043fe2a648d7e2
[openwrt/staging/ldir.git] /
1 From 51c884291a94fd6598427d7d6c211f1f20780d57 Mon Sep 17 00:00:00 2001
2 From: Jinjie Ruan <ruanjinjie@huawei.com>
3 Date: Fri, 30 Aug 2024 11:13:19 +0800
4 Subject: [PATCH 02/12] net: dsa: realtek: Use for_each_child_of_node_scoped()
5
6 Avoid need to manually handle of_node_put() by using
7 for_each_child_of_node_scoped(), which can simplfy code.
8
9 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
10 Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
12 Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
13 Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
14 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
15 Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
16 ---
17 drivers/net/dsa/realtek/rtl8366rb.c | 8 +++-----
18 1 file changed, 3 insertions(+), 5 deletions(-)
19
20 --- a/drivers/net/dsa/realtek/rtl8366rb.c
21 +++ b/drivers/net/dsa/realtek/rtl8366rb.c
22 @@ -1013,8 +1013,8 @@ static int rtl8366rb_setup_all_leds_off(
23
24 static int rtl8366rb_setup_leds(struct realtek_priv *priv)
25 {
26 - struct device_node *leds_np, *led_np;
27 struct dsa_switch *ds = &priv->ds;
28 + struct device_node *leds_np;
29 struct dsa_port *dp;
30 int ret = 0;
31
32 @@ -1029,13 +1029,11 @@ static int rtl8366rb_setup_leds(struct r
33 continue;
34 }
35
36 - for_each_child_of_node(leds_np, led_np) {
37 + for_each_child_of_node_scoped(leds_np, led_np) {
38 ret = rtl8366rb_setup_led(priv, dp,
39 of_fwnode_handle(led_np));
40 - if (ret) {
41 - of_node_put(led_np);
42 + if (ret)
43 break;
44 - }
45 }
46
47 of_node_put(leds_np);