Skip to content

Commit af7460d

Browse files
Jinjie Ruanrobherring
authored andcommitted
of: overlay: 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 39ab331 commit af7460d

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/of/overlay.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ static int add_changeset_node(struct overlay_changeset *ovcs,
472472
static int build_changeset_next_level(struct overlay_changeset *ovcs,
473473
struct target *target, const struct device_node *overlay_node)
474474
{
475-
struct device_node *child;
476475
struct property *prop;
477476
int ret;
478477

@@ -485,12 +484,11 @@ static int build_changeset_next_level(struct overlay_changeset *ovcs,
485484
}
486485
}
487486

488-
for_each_child_of_node(overlay_node, child) {
487+
for_each_child_of_node_scoped(overlay_node, child) {
489488
ret = add_changeset_node(ovcs, target, child);
490489
if (ret) {
491490
pr_debug("Failed to apply node @%pOF/%pOFn, err=%d\n",
492491
target->np, child, ret);
493-
of_node_put(child);
494492
return ret;
495493
}
496494
}
@@ -1078,16 +1076,12 @@ EXPORT_SYMBOL_GPL(of_overlay_fdt_apply);
10781076
*/
10791077
static int find_node(struct device_node *tree, struct device_node *np)
10801078
{
1081-
struct device_node *child;
1082-
10831079
if (tree == np)
10841080
return 1;
10851081

1086-
for_each_child_of_node(tree, child) {
1087-
if (find_node(child, np)) {
1088-
of_node_put(child);
1082+
for_each_child_of_node_scoped(tree, child) {
1083+
if (find_node(child, np))
10891084
return 1;
1090-
}
10911085
}
10921086

10931087
return 0;

0 commit comments

Comments
 (0)