]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpuidle: dt_idle_genpd: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Fri, 16 Aug 2024 15:09:31 +0000 (17:09 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 20 Aug 2024 09:30:39 +0000 (11:30 +0200)
Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20240816150931.142208-4-krzysztof.kozlowski@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/cpuidle/dt_idle_genpd.c

index 1af63c189039e9d40d3fd0863b37585feca271a9..203e9b754aeac0279c0f6d3b3524cb4fe89ca356 100644 (file)
@@ -130,11 +130,10 @@ out:
 
 int dt_idle_pd_init_topology(struct device_node *np)
 {
-       struct device_node *node;
        struct of_phandle_args child, parent;
        int ret;
 
-       for_each_child_of_node(np, node) {
+       for_each_child_of_node_scoped(np, node) {
                if (of_parse_phandle_with_args(node, "power-domains",
                                        "#power-domain-cells", 0, &parent))
                        continue;
@@ -143,10 +142,8 @@ int dt_idle_pd_init_topology(struct device_node *np)
                child.args_count = 0;
                ret = of_genpd_add_subdomain(&parent, &child);
                of_node_put(parent.np);
-               if (ret) {
-                       of_node_put(node);
+               if (ret)
                        return ret;
-               }
        }
 
        return 0;
@@ -154,11 +151,10 @@ int dt_idle_pd_init_topology(struct device_node *np)
 
 int dt_idle_pd_remove_topology(struct device_node *np)
 {
-       struct device_node *node;
        struct of_phandle_args child, parent;
        int ret;
 
-       for_each_child_of_node(np, node) {
+       for_each_child_of_node_scoped(np, node) {
                if (of_parse_phandle_with_args(node, "power-domains",
                                        "#power-domain-cells", 0, &parent))
                        continue;
@@ -167,10 +163,8 @@ int dt_idle_pd_remove_topology(struct device_node *np)
                child.args_count = 0;
                ret = of_genpd_remove_subdomain(&parent, &child);
                of_node_put(parent.np);
-               if (ret) {
-                       of_node_put(node);
+               if (ret)
                        return ret;
-               }
        }
 
        return 0;