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>
This commit is contained in:
parent
af7460d5e1
commit
bd7b58681a
@ -338,7 +338,6 @@ static int of_platform_bus_create(struct device_node *bus,
|
|||||||
struct device *parent, bool strict)
|
struct device *parent, bool strict)
|
||||||
{
|
{
|
||||||
const struct of_dev_auxdata *auxdata;
|
const struct of_dev_auxdata *auxdata;
|
||||||
struct device_node *child;
|
|
||||||
struct platform_device *dev;
|
struct platform_device *dev;
|
||||||
const char *bus_id = NULL;
|
const char *bus_id = NULL;
|
||||||
void *platform_data = NULL;
|
void *platform_data = NULL;
|
||||||
@ -382,14 +381,12 @@ static int of_platform_bus_create(struct device_node *bus,
|
|||||||
if (!dev || !of_match_node(matches, bus))
|
if (!dev || !of_match_node(matches, bus))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for_each_child_of_node(bus, child) {
|
for_each_child_of_node_scoped(bus, child) {
|
||||||
pr_debug(" create child: %pOF\n", child);
|
pr_debug(" create child: %pOF\n", child);
|
||||||
rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);
|
rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);
|
||||||
if (rc) {
|
if (rc)
|
||||||
of_node_put(child);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
of_node_set_flag(bus, OF_POPULATED_BUS);
|
of_node_set_flag(bus, OF_POPULATED_BUS);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -459,7 +456,6 @@ int of_platform_populate(struct device_node *root,
|
|||||||
const struct of_dev_auxdata *lookup,
|
const struct of_dev_auxdata *lookup,
|
||||||
struct device *parent)
|
struct device *parent)
|
||||||
{
|
{
|
||||||
struct device_node *child;
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
root = root ? of_node_get(root) : of_find_node_by_path("/");
|
root = root ? of_node_get(root) : of_find_node_by_path("/");
|
||||||
@ -470,13 +466,11 @@ int of_platform_populate(struct device_node *root,
|
|||||||
pr_debug(" starting at: %pOF\n", root);
|
pr_debug(" starting at: %pOF\n", root);
|
||||||
|
|
||||||
device_links_supplier_sync_state_pause();
|
device_links_supplier_sync_state_pause();
|
||||||
for_each_child_of_node(root, child) {
|
for_each_child_of_node_scoped(root, child) {
|
||||||
rc = of_platform_bus_create(child, matches, lookup, parent, true);
|
rc = of_platform_bus_create(child, matches, lookup, parent, true);
|
||||||
if (rc) {
|
if (rc)
|
||||||
of_node_put(child);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
device_links_supplier_sync_state_resume();
|
device_links_supplier_sync_state_resume();
|
||||||
|
|
||||||
of_node_set_flag(root, OF_POPULATED_BUS);
|
of_node_set_flag(root, OF_POPULATED_BUS);
|
||||||
|
Loading…
Reference in New Issue
Block a user