Skip to content

Commit 44a7185

Browse files
Kefeng Wangrobherring
authored andcommitted
of/platform: Add common method to populate default bus
The arch code calls of_platform_populate() with default match table when it wants to populate default bus. This patch introduce a new of_platform_default_populate_init() and make it arch_initcall_sync(it should be later than some iommu configration, eg, of_iommu_init() and swiotlb_late_init in arm64), then we can finish above job in common method. In order to avoid the default bus being populated twice, simply checking the flag of bus node whether has be set OF_POPULATED_BUS or not. After that, we can safely remove the caller in arch code. Btw, add debug print in of_platform_populate(), and use __func__ to print function's name of of_platform_bus_create(). Cc: Rob Herring <robh+dt@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Grant Likely <grant.likely@linaro.org> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Rob Herring <robh@kernel.org>
1 parent bb8e15d commit 44a7185

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

drivers/of/platform.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ static int of_platform_bus_create(struct device_node *bus,
363363
return 0;
364364
}
365365

366+
if (of_node_check_flag(bus, OF_POPULATED_BUS)) {
367+
pr_debug("%s() - skipping %s, already populated\n",
368+
__func__, bus->full_name);
369+
return 0;
370+
}
371+
366372
auxdata = of_dev_lookup(lookup, bus);
367373
if (auxdata) {
368374
bus_id = auxdata->name;
@@ -414,7 +420,7 @@ int of_platform_bus_probe(struct device_node *root,
414420
if (!root)
415421
return -EINVAL;
416422

417-
pr_debug("of_platform_bus_probe()\n");
423+
pr_debug("%s()\n", __func__);
418424
pr_debug(" starting at: %s\n", root->full_name);
419425

420426
/* Do a self check of bus type, if there's a match, create children */
@@ -466,6 +472,9 @@ int of_platform_populate(struct device_node *root,
466472
if (!root)
467473
return -EINVAL;
468474

475+
pr_debug("%s()\n", __func__);
476+
pr_debug(" starting at: %s\n", root->full_name);
477+
469478
for_each_child_of_node(root, child) {
470479
rc = of_platform_bus_create(child, matches, lookup, parent, true);
471480
if (rc) {
@@ -489,6 +498,15 @@ int of_platform_default_populate(struct device_node *root,
489498
}
490499
EXPORT_SYMBOL_GPL(of_platform_default_populate);
491500

501+
static int __init of_platform_default_populate_init(void)
502+
{
503+
if (of_have_populated_dt())
504+
of_platform_default_populate(NULL, NULL, NULL);
505+
506+
return 0;
507+
}
508+
arch_initcall_sync(of_platform_default_populate_init);
509+
492510
static int of_platform_device_destroy(struct device *dev, void *data)
493511
{
494512
/* Do not touch devices not populated from the device tree */

0 commit comments

Comments
 (0)