]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
hwmon: (npcm750-pwm-fan): Simplify with scoped for each OF child loop
authorJinjie Ruan <ruanjinjie@huawei.com>
Thu, 22 Aug 2024 06:29:54 +0000 (14:29 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 27 Aug 2024 15:11:15 +0000 (08:11 -0700)
Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Message-ID: <20240822062956.3490387-7-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/npcm750-pwm-fan.c

index bc8db1dc595db1164a28fc9c54a12c632a518a9a..db3b551828ebd2aadfd5c53bc168ba5656e0f92f 100644 (file)
@@ -927,7 +927,7 @@ static int npcm7xx_en_pwm_fan(struct device *dev,
 static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np, *child;
+       struct device_node *np;
        struct npcm7xx_pwm_fan_data *data;
        struct resource *res;
        struct device *hwmon;
@@ -1004,11 +1004,10 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)
                }
        }
 
-       for_each_child_of_node(np, child) {
+       for_each_child_of_node_scoped(np, child) {
                ret = npcm7xx_en_pwm_fan(dev, child, data);
                if (ret) {
                        dev_err(dev, "enable pwm and fan failed\n");
-                       of_node_put(child);
                        return ret;
                }
        }