From patchwork Wed Jun 1 06:52:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 68967 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2365240qge; Tue, 31 May 2016 23:47:44 -0700 (PDT) X-Received: by 10.98.155.76 with SMTP id r73mr5337974pfd.89.1464763661751; Tue, 31 May 2016 23:47:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sz10si2567390pab.78.2016.05.31.23.47.41; Tue, 31 May 2016 23:47:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757549AbcFAGre (ORCPT + 30 others); Wed, 1 Jun 2016 02:47:34 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:50490 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752209AbcFAGrb (ORCPT ); Wed, 1 Jun 2016 02:47:31 -0400 Received: from 172.24.1.137 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CCN07306; Wed, 01 Jun 2016 14:45:55 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Wed, 1 Jun 2016 14:45:45 +0800 From: Kefeng Wang To: , , CC: , , , , , , , , , Frank Rowand Subject: [PATCH v5 01/18] of/platform: Add common method to populate default bus Date: Wed, 1 Jun 2016 14:52:54 +0800 Message-ID: <1464763991-26634-2-git-send-email-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.6.0.GIT In-Reply-To: <1464763991-26634-1-git-send-email-wangkefeng.wang@huawei.com> References: <1464763991-26634-1-git-send-email-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.574E84A4.0074, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 77d4297ec9197926690559c4f1e92602 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Frank Rowand Cc: Grant Likely Signed-off-by: Kefeng Wang --- drivers/of/platform.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) -- 1.7.12.4 diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 16e8daf..c559ef8 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -363,6 +363,12 @@ static int of_platform_bus_create(struct device_node *bus, 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); if (auxdata) { bus_id = auxdata->name; @@ -414,7 +420,7 @@ int of_platform_bus_probe(struct device_node *root, if (!root) return -EINVAL; - pr_debug("of_platform_bus_probe()\n"); + pr_debug("%s()\n", __func__); pr_debug(" starting at: %s\n", root->full_name); /* 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, if (!root) return -EINVAL; + pr_debug("%s()\n", __func__); + pr_debug(" starting at: %s\n", root->full_name); + for_each_child_of_node(root, child) { rc = of_platform_bus_create(child, matches, lookup, parent, true); if (rc) { @@ -489,6 +498,15 @@ int of_platform_default_populate(struct device_node *root, } 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) { /* Do not touch devices not populated from the device tree */