Skip to content

Commit 97c5aac

Browse files
Jinjie Ruanrobherring
authored andcommitted
of: resolver: 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent bd7b586 commit 97c5aac

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/of/resolver.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static int node_name_cmp(const struct device_node *dn1,
150150
static int adjust_local_phandle_references(struct device_node *local_fixups,
151151
struct device_node *overlay, int phandle_delta)
152152
{
153-
struct device_node *child, *overlay_child;
153+
struct device_node *overlay_child;
154154
struct property *prop_fix, *prop;
155155
int err, i, count;
156156
unsigned int off;
@@ -194,25 +194,21 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,
194194
* The roots of the subtrees are the overlay's __local_fixups__ node
195195
* and the overlay's root node.
196196
*/
197-
for_each_child_of_node(local_fixups, child) {
197+
for_each_child_of_node_scoped(local_fixups, child) {
198198

199199
for_each_child_of_node(overlay, overlay_child)
200200
if (!node_name_cmp(child, overlay_child)) {
201201
of_node_put(overlay_child);
202202
break;
203203
}
204204

205-
if (!overlay_child) {
206-
of_node_put(child);
205+
if (!overlay_child)
207206
return -EINVAL;
208-
}
209207

210208
err = adjust_local_phandle_references(child, overlay_child,
211209
phandle_delta);
212-
if (err) {
213-
of_node_put(child);
210+
if (err)
214211
return err;
215-
}
216212
}
217213

218214
return 0;

0 commit comments

Comments
 (0)