Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754859Ab3HPWWP (ORCPT ); Fri, 16 Aug 2013 18:22:15 -0400 Received: from mail-bk0-f47.google.com ([209.85.214.47]:52680 "EHLO mail-bk0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751839Ab3HPWWL (ORCPT ); Fri, 16 Aug 2013 18:22:11 -0400 From: Thierry Reding To: Grant Likely Cc: Rob Herring , Greg Kroah-Hartman , Stephen Warren , Hiroshi Doyu , Lorenzo Pieralisi , Sebastian Hesselbarth , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 3/4] ARM: tegra: Call of_platform_populate() early Date: Fri, 16 Aug 2013 22:39:22 +0200 Message-Id: <1376685563-1053-4-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1376685563-1053-1-git-send-email-treding@nvidia.com> References: <1376685563-1053-1-git-send-email-treding@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3684 Lines: 125 Using the new early device registration functionality it is now possible to register devices much earlier in the boot process. Move the call to of_platform_populate() from tegra_dt_init() to tegra_dt_init_irq() and allow drivers that require to be run early to access the struct device associated with a device node. Signed-off-by: Thierry Reding --- arch/arm/mach-tegra/common.c | 33 +++++++++++++++++++++++++++++++++ arch/arm/mach-tegra/tegra.c | 32 -------------------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c index 94a119a..24dc09b 100644 --- a/arch/arm/mach-tegra/common.c +++ b/arch/arm/mach-tegra/common.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include @@ -61,6 +64,36 @@ u32 tegra_uart_config[4] = { #ifdef CONFIG_OF void __init tegra_dt_init_irq(void) { + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; + struct device *parent = NULL; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + goto out; + + soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra"); + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision); + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", tegra_chip_id); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr->family); + kfree(soc_dev_attr->revision); + kfree(soc_dev_attr->soc_id); + kfree(soc_dev_attr); + goto out; + } + + parent = soc_device_to_device(soc_dev); + + /* + * Finished with the static registrations now; fill in the missing + * devices + */ +out: + of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); + of_clk_init(NULL); tegra_pmc_init(); tegra_init_irq(); diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index 5b86055..9abb71e 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c @@ -27,11 +27,9 @@ #include #include #include -#include #include #include #include -#include #include #include @@ -47,37 +45,7 @@ static void __init tegra_dt_init(void) { - struct soc_device_attribute *soc_dev_attr; - struct soc_device *soc_dev; - struct device *parent = NULL; - tegra_clocks_apply_init_table(); - - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); - if (!soc_dev_attr) - goto out; - - soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra"); - soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision); - soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", tegra_chip_id); - - soc_dev = soc_device_register(soc_dev_attr); - if (IS_ERR(soc_dev)) { - kfree(soc_dev_attr->family); - kfree(soc_dev_attr->revision); - kfree(soc_dev_attr->soc_id); - kfree(soc_dev_attr); - goto out; - } - - parent = soc_device_to_device(soc_dev); - - /* - * Finished with the static registrations now; fill in the missing - * devices - */ -out: - of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); } static void __init paz00_init(void) -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/