]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: bcm6358: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Fri, 16 Aug 2024 15:31:40 +0000 (17:31 +0200)
committerLee Jones <lee@kernel.org>
Thu, 22 Aug 2024 13:23:05 +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>
Link: https://lore.kernel.org/r/20240816-cleanup-h-of-node-put-var-v1-8-1d0292802470@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-bcm6358.c

index 86e51d44a5a741eb72e51ba44adfbb906d1d8545..51fcff2a64fd10f2a233e41a34d2f8add37a4166 100644 (file)
@@ -147,7 +147,6 @@ static int bcm6358_leds_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *np = dev_of_node(&pdev->dev);
-       struct device_node *child;
        void __iomem *mem;
        spinlock_t *lock; /* memory lock */
        unsigned long val;
@@ -184,7 +183,7 @@ static int bcm6358_leds_probe(struct platform_device *pdev)
        }
        bcm6358_led_write(mem + BCM6358_REG_CTRL, val);
 
-       for_each_available_child_of_node(np, child) {
+       for_each_available_child_of_node_scoped(np, child) {
                int rc;
                u32 reg;
 
@@ -198,10 +197,8 @@ static int bcm6358_leds_probe(struct platform_device *pdev)
                }
 
                rc = bcm6358_led(dev, child, reg, mem, lock);
-               if (rc < 0) {
-                       of_node_put(child);
+               if (rc < 0)
                        return rc;
-               }
        }
 
        return 0;