]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
hwmon: (aspeed-pwm-tacho): Simplify with scoped for each OF child loop
authorJinjie Ruan <ruanjinjie@huawei.com>
Thu, 22 Aug 2024 06:29:50 +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>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Message-ID: <20240822062956.3490387-3-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/aspeed-pwm-tacho.c

index 4acc1858d8acf799c20e5c2061431d35adc8db10..aa159bf158a37f0298dadda1ffc6975169b36a87 100644 (file)
@@ -907,7 +907,7 @@ static void aspeed_pwm_tacho_remove(void *data)
 static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np, *child;
+       struct device_node *np;
        struct aspeed_pwm_tacho_data *priv;
        void __iomem *regs;
        struct device *hwmon;
@@ -951,12 +951,10 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
 
        aspeed_create_type(priv);
 
-       for_each_child_of_node(np, child) {
+       for_each_child_of_node_scoped(np, child) {
                ret = aspeed_create_fan(dev, child, priv);
-               if (ret) {
-                       of_node_put(child);
+               if (ret)
                        return ret;
-               }
        }
 
        priv->groups[0] = &pwm_dev_group;