]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
leds: lp55xx: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Wed, 24 Dec 2025 12:45:22 +0000 (13:45 +0100)
committerLee Jones <lee@kernel.org>
Wed, 4 Feb 2026 09:20:56 +0000 (09:20 +0000)
Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20251224124521.208635-2-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-lp55xx-common.c

index fd447eb7eb15e243f1c470085f7780a8da866286..ea131177de96423bf8243e8d39c9dcc5e3d5a3c9 100644 (file)
@@ -1204,7 +1204,6 @@ static struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
                                                             struct device_node *np,
                                                             struct lp55xx_chip *chip)
 {
-       struct device_node *child;
        struct lp55xx_platform_data *pdata;
        struct lp55xx_led_config *cfg;
        int num_channels;
@@ -1229,12 +1228,10 @@ static struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
        pdata->num_channels = num_channels;
        cfg->max_channel = chip->cfg->max_channel;
 
-       for_each_available_child_of_node(np, child) {
+       for_each_available_child_of_node_scoped(np, child) {
                ret = lp55xx_parse_logical_led(child, cfg, i);
-               if (ret) {
-                       of_node_put(child);
+               if (ret)
                        return ERR_PTR(-EINVAL);
-               }
                i++;
        }