]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: turris-omnia: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Fri, 16 Aug 2024 15:31:48 +0000 (17:31 +0200)
committerLee Jones <lee@kernel.org>
Thu, 22 Aug 2024 13:23:11 +0000 (14:23 +0100)
Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Marek BehĂșn <kabel@kernel.org>
Link: https://lore.kernel.org/r/20240816-cleanup-h-of-node-put-var-v1-16-1d0292802470@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-turris-omnia.c

index 39f740be058f1464cbd60919da658f524da8f829..1ef942b5cefadc6525f7855e4e6bb8791f56bc12 100644 (file)
@@ -452,7 +452,7 @@ static int omnia_mcu_get_features(const struct i2c_client *client)
 static int omnia_leds_probe(struct i2c_client *client)
 {
        struct device *dev = &client->dev;
-       struct device_node *np = dev_of_node(dev), *child;
+       struct device_node *np = dev_of_node(dev);
        struct omnia_leds *leds;
        struct omnia_led *led;
        int ret, count;
@@ -497,12 +497,10 @@ static int omnia_leds_probe(struct i2c_client *client)
        }
 
        led = &leds->leds[0];
-       for_each_available_child_of_node(np, child) {
+       for_each_available_child_of_node_scoped(np, child) {
                ret = omnia_led_register(client, led, child);
-               if (ret < 0) {
-                       of_node_put(child);
+               if (ret < 0)
                        return ret;
-               }
 
                led += ret;
        }