Skip to content

Commit 157519c

Browse files
krzkstorulf
authored andcommitted
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: Krzysztof Kozlowski <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 7aa1204 commit 157519c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/cpuidle/dt_idle_genpd.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,10 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
130130

131131
int dt_idle_pd_init_topology(struct device_node *np)
132132
{
133-
struct device_node *node;
134133
struct of_phandle_args child, parent;
135134
int ret;
136135

137-
for_each_child_of_node(np, node) {
136+
for_each_child_of_node_scoped(np, node) {
138137
if (of_parse_phandle_with_args(node, "power-domains",
139138
"#power-domain-cells", 0, &parent))
140139
continue;
@@ -143,22 +142,19 @@ int dt_idle_pd_init_topology(struct device_node *np)
143142
child.args_count = 0;
144143
ret = of_genpd_add_subdomain(&parent, &child);
145144
of_node_put(parent.np);
146-
if (ret) {
147-
of_node_put(node);
145+
if (ret)
148146
return ret;
149-
}
150147
}
151148

152149
return 0;
153150
}
154151

155152
int dt_idle_pd_remove_topology(struct device_node *np)
156153
{
157-
struct device_node *node;
158154
struct of_phandle_args child, parent;
159155
int ret;
160156

161-
for_each_child_of_node(np, node) {
157+
for_each_child_of_node_scoped(np, node) {
162158
if (of_parse_phandle_with_args(node, "power-domains",
163159
"#power-domain-cells", 0, &parent))
164160
continue;
@@ -167,10 +163,8 @@ int dt_idle_pd_remove_topology(struct device_node *np)
167163
child.args_count = 0;
168164
ret = of_genpd_remove_subdomain(&parent, &child);
169165
of_node_put(parent.np);
170-
if (ret) {
171-
of_node_put(node);
166+
if (ret)
172167
return ret;
173-
}
174168
}
175169

176170
return 0;

0 commit comments

Comments
 (0)