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

authored by

Jinjie Ruan and committed by
Rob Herring (Arm)
97c5aac4 bd7b5868

+4 -8
+4 -8
drivers/of/resolver.c
··· 150 150 static int adjust_local_phandle_references(struct device_node *local_fixups, 151 151 struct device_node *overlay, int phandle_delta) 152 152 { 153 - struct device_node *child, *overlay_child; 153 + struct device_node *overlay_child; 154 154 struct property *prop_fix, *prop; 155 155 int err, i, count; 156 156 unsigned int off; ··· 194 194 * The roots of the subtrees are the overlay's __local_fixups__ node 195 195 * and the overlay's root node. 196 196 */ 197 - for_each_child_of_node(local_fixups, child) { 197 + for_each_child_of_node_scoped(local_fixups, child) { 198 198 199 199 for_each_child_of_node(overlay, overlay_child) 200 200 if (!node_name_cmp(child, overlay_child)) { ··· 202 202 break; 203 203 } 204 204 205 - if (!overlay_child) { 206 - of_node_put(child); 205 + if (!overlay_child) 207 206 return -EINVAL; 208 - } 209 207 210 208 err = adjust_local_phandle_references(child, overlay_child, 211 209 phandle_delta); 212 - if (err) { 213 - of_node_put(child); 210 + if (err) 214 211 return err; 215 - } 216 212 } 217 213 218 214 return 0;