Commit 97c5aac4 authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Rob Herring (Arm)

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: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20240826062408.2406734-4-ruanjinjie@huawei.comSigned-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
parent bd7b5868
...@@ -150,7 +150,7 @@ static int node_name_cmp(const struct device_node *dn1, ...@@ -150,7 +150,7 @@ static int node_name_cmp(const struct device_node *dn1,
static int adjust_local_phandle_references(struct device_node *local_fixups, static int adjust_local_phandle_references(struct device_node *local_fixups,
struct device_node *overlay, int phandle_delta) struct device_node *overlay, int phandle_delta)
{ {
struct device_node *child, *overlay_child; struct device_node *overlay_child;
struct property *prop_fix, *prop; struct property *prop_fix, *prop;
int err, i, count; int err, i, count;
unsigned int off; unsigned int off;
...@@ -194,7 +194,7 @@ static int adjust_local_phandle_references(struct device_node *local_fixups, ...@@ -194,7 +194,7 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,
* The roots of the subtrees are the overlay's __local_fixups__ node * The roots of the subtrees are the overlay's __local_fixups__ node
* and the overlay's root node. * and the overlay's root node.
*/ */
for_each_child_of_node(local_fixups, child) { for_each_child_of_node_scoped(local_fixups, child) {
for_each_child_of_node(overlay, overlay_child) for_each_child_of_node(overlay, overlay_child)
if (!node_name_cmp(child, overlay_child)) { if (!node_name_cmp(child, overlay_child)) {
...@@ -202,17 +202,13 @@ static int adjust_local_phandle_references(struct device_node *local_fixups, ...@@ -202,17 +202,13 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,
break; break;
} }
if (!overlay_child) { if (!overlay_child)
of_node_put(child);
return -EINVAL; return -EINVAL;
}
err = adjust_local_phandle_references(child, overlay_child, err = adjust_local_phandle_references(child, overlay_child,
phandle_delta); phandle_delta);
if (err) { if (err)
of_node_put(child);
return err; return err;
}
} }
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