Skip to content

Commit bd7b586

Browse files
Jinjie Ruanrobherring
authored andcommitted
of/platform: Simplify with scoped for each OF child
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 af7460d commit bd7b586

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/of/platform.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ static int of_platform_bus_create(struct device_node *bus,
338338
struct device *parent, bool strict)
339339
{
340340
const struct of_dev_auxdata *auxdata;
341-
struct device_node *child;
342341
struct platform_device *dev;
343342
const char *bus_id = NULL;
344343
void *platform_data = NULL;
@@ -382,13 +381,11 @@ static int of_platform_bus_create(struct device_node *bus,
382381
if (!dev || !of_match_node(matches, bus))
383382
return 0;
384383

385-
for_each_child_of_node(bus, child) {
384+
for_each_child_of_node_scoped(bus, child) {
386385
pr_debug(" create child: %pOF\n", child);
387386
rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);
388-
if (rc) {
389-
of_node_put(child);
387+
if (rc)
390388
break;
391-
}
392389
}
393390
of_node_set_flag(bus, OF_POPULATED_BUS);
394391
return rc;
@@ -459,7 +456,6 @@ int of_platform_populate(struct device_node *root,
459456
const struct of_dev_auxdata *lookup,
460457
struct device *parent)
461458
{
462-
struct device_node *child;
463459
int rc = 0;
464460

465461
root = root ? of_node_get(root) : of_find_node_by_path("/");
@@ -470,12 +466,10 @@ int of_platform_populate(struct device_node *root,
470466
pr_debug(" starting at: %pOF\n", root);
471467

472468
device_links_supplier_sync_state_pause();
473-
for_each_child_of_node(root, child) {
469+
for_each_child_of_node_scoped(root, child) {
474470
rc = of_platform_bus_create(child, matches, lookup, parent, true);
475-
if (rc) {
476-
of_node_put(child);
471+
if (rc)
477472
break;
478-
}
479473
}
480474
device_links_supplier_sync_state_resume();
481475

0 commit comments

Comments
 (0)