]> git.dujemihanovic.xyz Git - linux.git/commitdiff
mfd: max77620: Use for_each_child_of_node_scoped()
authorJinjie Ruan <ruanjinjie@huawei.com>
Mon, 26 Aug 2024 09:27:33 +0000 (17:27 +0800)
committerLee Jones <lee@kernel.org>
Mon, 23 Sep 2024 15:20:54 +0000 (16:20 +0100)
Avoids the need for manual cleanup of_node_put() in early exits
from the loop.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20240826092734.2899562-2-ruanjinjie@huawei.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/max77620.c

index 74ef3f6d576cca968d50fdf0130dc7991716fe9a..89b30ef91f4f112b06e0e055e75e480fab176f8f 100644 (file)
@@ -400,7 +400,7 @@ static int max77620_config_fps(struct max77620_chip *chip,
 static int max77620_initialise_fps(struct max77620_chip *chip)
 {
        struct device *dev = chip->dev;
-       struct device_node *fps_np, *fps_child;
+       struct device_node *fps_np;
        u8 config;
        int fps_id;
        int ret;
@@ -414,10 +414,9 @@ static int max77620_initialise_fps(struct max77620_chip *chip)
        if (!fps_np)
                goto skip_fps;
 
-       for_each_child_of_node(fps_np, fps_child) {
+       for_each_child_of_node_scoped(fps_np, fps_child) {
                ret = max77620_config_fps(chip, fps_child);
                if (ret < 0) {
-                       of_node_put(fps_child);
                        of_node_put(fps_np);
                        return ret;
                }