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

authored by

Jinjie Ruan and committed by
Rob Herring (Arm)
bd7b5868 af7460d5

+4 -10
+4 -10
drivers/of/platform.c
··· 338 338 struct device *parent, bool strict) 339 339 { 340 340 const struct of_dev_auxdata *auxdata; 341 - struct device_node *child; 342 341 struct platform_device *dev; 343 342 const char *bus_id = NULL; 344 343 void *platform_data = NULL; ··· 381 382 if (!dev || !of_match_node(matches, bus)) 382 383 return 0; 383 384 384 - for_each_child_of_node(bus, child) { 385 + for_each_child_of_node_scoped(bus, child) { 385 386 pr_debug(" create child: %pOF\n", child); 386 387 rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict); 387 - if (rc) { 388 - of_node_put(child); 388 + if (rc) 389 389 break; 390 - } 391 390 } 392 391 of_node_set_flag(bus, OF_POPULATED_BUS); 393 392 return rc; ··· 456 459 const struct of_dev_auxdata *lookup, 457 460 struct device *parent) 458 461 { 459 - struct device_node *child; 460 462 int rc = 0; 461 463 462 464 root = root ? of_node_get(root) : of_find_node_by_path("/"); ··· 466 470 pr_debug(" starting at: %pOF\n", root); 467 471 468 472 device_links_supplier_sync_state_pause(); 469 - for_each_child_of_node(root, child) { 473 + for_each_child_of_node_scoped(root, child) { 470 474 rc = of_platform_bus_create(child, matches, lookup, parent, true); 471 - if (rc) { 472 - of_node_put(child); 475 + if (rc) 473 476 break; 474 - } 475 477 } 476 478 device_links_supplier_sync_state_resume(); 477 479