From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yijing Wang Subject: [PATCH v8 13/30] PCI: Move pcibios_root_bridge_prepare() to pci_create_host_bridge() Date: Tue, 24 Mar 2015 11:34:07 +0800 Message-ID: <1427168064-8657-14-git-send-email-wangyijing__13001.0154135109$1427168695$gmane$org@huawei.com> References: <1427168064-8657-1-git-send-email-wangyijing@huawei.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1427168064-8657-1-git-send-email-wangyijing@huawei.com> Sender: linux-m68k-owner@vger.kernel.org List-Id: linux-m68k@vger.kernel.org To: Bjorn Helgaas Cc: Jiang Liu , linux-pci@vger.kernel.org, Yinghai Lu , linux-kernel@vger.kernel.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, Russell King , x86@kernel.org, Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , linux-ia64@vger.kernel.org, "David S. Miller" , Guan Xuetao , linux-alpha@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Liviu Dudau , Arnd Bergmann , Geert Uytterhoeven , Yijing Wang Move pcibios_root_bridge_prepare() to pci_create_host_bridge(). Signed-off-by: Yijing Wang --- drivers/pci/host-bridge.c | 16 +++++++++++++--- drivers/pci/probe.c | 3 --- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index b0ed8da..87c4fc5 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -92,9 +92,7 @@ struct pci_host_bridge *pci_create_host_bridge( pr_warn("pci host bridge pci%04x:%02x exist\n", host->domain, bus); mutex_unlock(&pci_host_mutex); - pci_free_resource_list(&host->windows); - kfree(host); - return NULL; + goto free_res; } } list_add_tail(&host->list, &pci_host_bridge_list); @@ -105,6 +103,10 @@ struct pci_host_bridge *pci_create_host_bridge( dev_set_name(&host->dev, "pci%04x:%02x", host->domain, bus); + error = pcibios_root_bridge_prepare(host); + if (error) + goto list_del; + error = device_register(&host->dev); if (error) { put_device(&host->dev); @@ -112,6 +114,14 @@ struct pci_host_bridge *pci_create_host_bridge( } return host; +list_del: + mutex_lock(&pci_host_mutex); + list_del(&host->list); + mutex_unlock(&pci_host_mutex); +free_res: + pci_free_resource_list(&host->windows); + kfree(host); + return NULL; } void pci_free_host_bridge(struct pci_host_bridge *host) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 418a426..ee17d9a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1893,9 +1893,6 @@ static struct pci_bus *__pci_create_root_bus( bridge->bus = b; b->bridge = get_device(&bridge->dev); - error = pcibios_root_bridge_prepare(bridge); - if (error) - goto put_dev; pcibios_set_root_bus_speed(bridge); device_enable_async_suspend(b->bridge); -- 1.7.1