Commit 44a7185c authored by Kefeng Wang's avatar Kefeng Wang Committed by Rob Herring

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: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent bb8e15d6
...@@ -363,6 +363,12 @@ static int of_platform_bus_create(struct device_node *bus, ...@@ -363,6 +363,12 @@ static int of_platform_bus_create(struct device_node *bus,
return 0; return 0;
} }
if (of_node_check_flag(bus, OF_POPULATED_BUS)) {
pr_debug("%s() - skipping %s, already populated\n",
__func__, bus->full_name);
return 0;
}
auxdata = of_dev_lookup(lookup, bus); auxdata = of_dev_lookup(lookup, bus);
if (auxdata) { if (auxdata) {
bus_id = auxdata->name; bus_id = auxdata->name;
...@@ -414,7 +420,7 @@ int of_platform_bus_probe(struct device_node *root, ...@@ -414,7 +420,7 @@ int of_platform_bus_probe(struct device_node *root,
if (!root) if (!root)
return -EINVAL; return -EINVAL;
pr_debug("of_platform_bus_probe()\n"); pr_debug("%s()\n", __func__);
pr_debug(" starting at: %s\n", root->full_name); pr_debug(" starting at: %s\n", root->full_name);
/* Do a self check of bus type, if there's a match, create children */ /* 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, ...@@ -466,6 +472,9 @@ int of_platform_populate(struct device_node *root,
if (!root) if (!root)
return -EINVAL; return -EINVAL;
pr_debug("%s()\n", __func__);
pr_debug(" starting at: %s\n", root->full_name);
for_each_child_of_node(root, child) { for_each_child_of_node(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) {
...@@ -489,6 +498,15 @@ int of_platform_default_populate(struct device_node *root, ...@@ -489,6 +498,15 @@ int of_platform_default_populate(struct device_node *root,
} }
EXPORT_SYMBOL_GPL(of_platform_default_populate); EXPORT_SYMBOL_GPL(of_platform_default_populate);
static int __init of_platform_default_populate_init(void)
{
if (of_have_populated_dt())
of_platform_default_populate(NULL, NULL, NULL);
return 0;
}
arch_initcall_sync(of_platform_default_populate_init);
static int of_platform_device_destroy(struct device *dev, void *data) static int of_platform_device_destroy(struct device *dev, void *data)
{ {
/* Do not touch devices not populated from the device tree */ /* Do not touch devices not populated from the device tree */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment