const struct of_device_id *matches,
struct device *parent)
{
- struct device_node *child;
int rc = 0;
root = root ? of_node_get(root) : of_find_node_by_path("/");
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
rc = of_platform_bus_create(root, matches, NULL, parent, false);
- } else for_each_child_of_node(root, child) {
- if (!of_match_node(matches, child))
- continue;
- rc = of_platform_bus_create(child, matches, NULL, parent, false);
- if (rc) {
- of_node_put(child);
- break;
+ } else {
+ for_each_child_of_node_scoped(root, child) {
+ if (!of_match_node(matches, child))
+ continue;
+ rc = of_platform_bus_create(child, matches, NULL, parent, false);
+ if (rc)
+ break;
}
}