Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20240826062408.2406734-2-ruanjinjie@huawei.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

authored by

Jinjie Ruan and committed by
Rob Herring (Arm)
af7460d5 39ab331a

+3 -9
+3 -9
drivers/of/overlay.c
··· 472 472 static int build_changeset_next_level(struct overlay_changeset *ovcs, 473 473 struct target *target, const struct device_node *overlay_node) 474 474 { 475 - struct device_node *child; 476 475 struct property *prop; 477 476 int ret; 478 477 ··· 484 485 } 485 486 } 486 487 487 - for_each_child_of_node(overlay_node, child) { 488 + for_each_child_of_node_scoped(overlay_node, child) { 488 489 ret = add_changeset_node(ovcs, target, child); 489 490 if (ret) { 490 491 pr_debug("Failed to apply node @%pOF/%pOFn, err=%d\n", 491 492 target->np, child, ret); 492 - of_node_put(child); 493 493 return ret; 494 494 } 495 495 } ··· 1076 1078 */ 1077 1079 static int find_node(struct device_node *tree, struct device_node *np) 1078 1080 { 1079 - struct device_node *child; 1080 - 1081 1081 if (tree == np) 1082 1082 return 1; 1083 1083 1084 - for_each_child_of_node(tree, child) { 1085 - if (find_node(child, np)) { 1086 - of_node_put(child); 1084 + for_each_child_of_node_scoped(tree, child) { 1085 + if (find_node(child, np)) 1087 1086 return 1; 1088 - } 1089 1087 } 1090 1088 1091 1089 return 0;