]> www.infradead.org Git - users/willy/xarray.git/commitdiff
hwmon: (aspeed-g6-pwm-tacho): Simplify with scoped for each OF child loop
authorJinjie Ruan <ruanjinjie@huawei.com>
Thu, 22 Aug 2024 06:29:49 +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-2-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/aspeed-g6-pwm-tach.c

index 08a2ded95e45c378d6a9fec024f2e83712d7284b..75eadda738ab671eb38af1b2feac0ee8abd830b3 100644 (file)
@@ -456,7 +456,6 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev, *hwmon;
        int ret;
-       struct device_node *child;
        struct aspeed_pwm_tach_data *priv;
        struct pwm_chip *chip;
 
@@ -498,10 +497,9 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev)
        if (ret)
                return dev_err_probe(dev, ret, "Failed to add PWM chip\n");
 
-       for_each_child_of_node(dev->of_node, child) {
+       for_each_child_of_node_scoped(dev->of_node, child) {
                ret = aspeed_create_fan_monitor(dev, child, priv);
                if (ret) {
-                       of_node_put(child);
                        dev_warn(dev, "Failed to create fan %d", ret);
                        return 0;
                }