From patchwork Fri Jun 24 14:10:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 916352 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5OEMLmF030767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 24 Jun 2011 14:22:41 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qa7Gh-0001bF-Ld; Fri, 24 Jun 2011 14:22:00 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qa7Gh-0005rv-48; Fri, 24 Jun 2011 14:21:59 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qa76i-0005ha-Ep for linux-arm-kernel@canuck.infradead.org; Fri, 24 Jun 2011 14:11:40 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by casper.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qa76f-0002dk-Ka for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2011 14:11:39 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 24 Jun 2011 15:10:59 +0100 Received: from localhost.localdomain ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 24 Jun 2011 15:10:54 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, devicetree-discuss@lists.ozlabs.org Subject: [RFC PATCH 1/4] dt: early platform devices support Date: Fri, 24 Jun 2011 15:10:56 +0100 Message-Id: <1308924659-31894-2-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1308924659-31894-1-git-send-email-marc.zyngier@arm.com> References: <1308924659-31894-1-git-send-email-marc.zyngier@arm.com> X-OriginalArrivalTime: 24 Jun 2011 14:10:54.0675 (UTC) FILETIME=[880A6A30:01CC3278] X-MC-Unique: 111062415105901901 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110624_151137_823052_D9FE049B X-CRM114-Status: GOOD ( 13.58 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2-r929478 on casper.infradead.org summary: Content analysis details: (-2.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [94.185.240.25 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Grant Likely X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 24 Jun 2011 14:22:41 +0000 (UTC) Add support for populating early platform devices from the device tree, by walking the tree and adding nodes whose 'compatible' property matches the 'class' string passed as a parameter. This allows devices to be probed long before the whole device infrastructure is available. Signed-off-by: Marc Zyngier --- drivers/of/platform.c | 26 ++++++++++++++++++++++++++ include/linux/of_platform.h | 1 + 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index e75af39..2a323ee 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -458,4 +458,30 @@ int of_platform_populate(struct device_node *root, of_node_put(root); return rc; } + +/** + * of_early_platform_populate() - Populate early platform devices from DT + * @class: string to compare to the 'compatible' attributes + * + * This function walks the device tree and register devices whose + * 'compatible' property matches the 'class' parameter. + * + * Returns 0 on success, < 0 on failure. + */ +int of_early_platform_populate(const char *class) +{ + struct platform_device *pdev; + struct device_node *np = NULL; + + while ((np = of_find_compatible_node(np, NULL, class))) { + pdev = of_device_alloc(np, NULL, NULL); + if (!pdev) + return -ENOMEM; + list_del(&pdev->dev.devres_head); + memset(&pdev->dev.devres_head, 0, sizeof(pdev->dev.devres_head)); + early_platform_add_devices(&pdev, 1); + } + + return 0; +} #endif /* !CONFIG_SPARC */ diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 5a6f458..dd1dc90 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -95,6 +95,7 @@ extern int of_platform_populate(struct device_node *root, const struct of_device_id *matches, const struct of_dev_auxdata *lookup, struct device *parent); +extern int of_early_platform_populate(const char *class); #endif /* !CONFIG_SPARC */ #endif /* CONFIG_OF_DEVICE */