]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
hwmon: (lm90): Simplify with scoped for each OF child loop
authorJinjie Ruan <ruanjinjie@huawei.com>
Thu, 22 Aug 2024 06:29:52 +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-5-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lm90.c

index ca5c52b38c0f3765c3402d4f0a10e875973bad91..511d95a0efb36ae1f409fb6319eb1f6e5436c375 100644 (file)
@@ -2674,19 +2674,16 @@ static int lm90_parse_dt_channel_info(struct i2c_client *client,
                                      struct lm90_data *data)
 {
        int err;
-       struct device_node *child;
        struct device *dev = &client->dev;
        const struct device_node *np = dev->of_node;
 
-       for_each_child_of_node(np, child) {
+       for_each_child_of_node_scoped(np, child) {
                if (strcmp(child->name, "channel"))
                        continue;
 
                err = lm90_probe_channel_from_dt(client, child, data);
-               if (err) {
-                       of_node_put(child);
+               if (err)
                        return err;
-               }
        }
 
        return 0;