From: Jinjie Ruan Date: Thu, 22 Aug 2024 06:29:56 +0000 (+0800) Subject: hwmon: (tmp464): Simplify with scoped for each OF child loop X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d5b07232868b69414d1e540e7b96a60fbcab3409;p=users%2Fjedix%2Flinux-maple.git hwmon: (tmp464): Simplify with scoped for each OF child loop Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan Message-ID: <20240822062956.3490387-9-ruanjinjie@huawei.com> Signed-off-by: Guenter Roeck --- diff --git a/drivers/hwmon/tmp464.c b/drivers/hwmon/tmp464.c index 0a7c0448835b4..0f629c6d7695e 100644 --- a/drivers/hwmon/tmp464.c +++ b/drivers/hwmon/tmp464.c @@ -562,18 +562,15 @@ static int tmp464_probe_child_from_dt(struct device *dev, static int tmp464_probe_from_dt(struct device *dev, struct tmp464_data *data) { const struct device_node *np = dev->of_node; - struct device_node *child; int err; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (strcmp(child->name, "channel")) continue; err = tmp464_probe_child_from_dt(dev, child, data); - if (err) { - of_node_put(child); + if (err) return err; - } } return 0;