Skip to content

Commit

Permalink
of: resolver: Simplify with scoped for each OF child loop
Browse files Browse the repository at this point in the history
Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20240826062408.2406734-4-ruanjinjie@huawei.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
  • Loading branch information
Jinjie Ruan authored and Rob Herring (Arm) committed Aug 26, 2024
1 parent bd7b586 commit 97c5aac
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/of/resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
struct device_node *overlay, int phandle_delta)
{
struct device_node *child, *overlay_child;
struct device_node *overlay_child;
struct property *prop_fix, *prop;
int err, i, count;
unsigned int off;
Expand Down Expand Up @@ -194,25 +194,21 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,
* The roots of the subtrees are the overlay's __local_fixups__ 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)
if (!node_name_cmp(child, overlay_child)) {
of_node_put(overlay_child);
break;
}

if (!overlay_child) {
of_node_put(child);
if (!overlay_child)
return -EINVAL;
}

err = adjust_local_phandle_references(child, overlay_child,
phandle_delta);
if (err) {
of_node_put(child);
if (err)
return err;
}
}

return 0;
Expand Down

0 comments on commit 97c5aac

Please sign in to comment.