Commit 157519c0 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Ulf Hansson

cpuidle: dt_idle_genpd: 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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20240816150931.142208-4-krzysztof.kozlowski@linaro.orgSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 7aa1204d
...@@ -130,11 +130,10 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np, ...@@ -130,11 +130,10 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
int dt_idle_pd_init_topology(struct device_node *np) int dt_idle_pd_init_topology(struct device_node *np)
{ {
struct device_node *node;
struct of_phandle_args child, parent; struct of_phandle_args child, parent;
int ret; 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", if (of_parse_phandle_with_args(node, "power-domains",
"#power-domain-cells", 0, &parent)) "#power-domain-cells", 0, &parent))
continue; continue;
...@@ -143,10 +142,8 @@ int dt_idle_pd_init_topology(struct device_node *np) ...@@ -143,10 +142,8 @@ int dt_idle_pd_init_topology(struct device_node *np)
child.args_count = 0; child.args_count = 0;
ret = of_genpd_add_subdomain(&parent, &child); ret = of_genpd_add_subdomain(&parent, &child);
of_node_put(parent.np); of_node_put(parent.np);
if (ret) { if (ret)
of_node_put(node);
return ret; return ret;
}
} }
return 0; return 0;
...@@ -154,11 +151,10 @@ int dt_idle_pd_init_topology(struct device_node *np) ...@@ -154,11 +151,10 @@ int dt_idle_pd_init_topology(struct device_node *np)
int dt_idle_pd_remove_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; struct of_phandle_args child, parent;
int ret; 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", if (of_parse_phandle_with_args(node, "power-domains",
"#power-domain-cells", 0, &parent)) "#power-domain-cells", 0, &parent))
continue; continue;
...@@ -167,10 +163,8 @@ int dt_idle_pd_remove_topology(struct device_node *np) ...@@ -167,10 +163,8 @@ int dt_idle_pd_remove_topology(struct device_node *np)
child.args_count = 0; child.args_count = 0;
ret = of_genpd_remove_subdomain(&parent, &child); ret = of_genpd_remove_subdomain(&parent, &child);
of_node_put(parent.np); of_node_put(parent.np);
if (ret) { if (ret)
of_node_put(node);
return ret; return ret;
}
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment