From patchwork Wed Apr 26 11:18:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9701241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EEF3C60245 for ; Wed, 26 Apr 2017 11:37:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2FB628449 for ; Wed, 26 Apr 2017 11:37:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D624A28468; Wed, 26 Apr 2017 11:37:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4C6C828449 for ; Wed, 26 Apr 2017 11:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=R3dIH/3qkyfANyU2Z7hlCkZ+lmmAygRYn5rmpZwnIr0=; b=C7/wFcOtHQEbUno3LJy8bJXuv0 WzkDnNpwO0cN5ANNgzBKEoHeIgT/ALIVGe4zoRJ5zZUMXr7EQVAGBT6oNv3NZ/QzdbQz4SF7RiTin 6IrVOp1gKsOKQjKH+3DqF7tS9XRyxqaUFf6ju7mT1XnG96ojR9oTtnNoQdGks3fFXjATRBXOTS5E9 ttVVsaJjiqLlyTutbKdLmSHl+goVEbep2dnbB/8EdlgnLJiKzaya6D1KIl0f6LMHpaoOPR9LrU9mA xY3bvo8xyTDliRw5wwTBsRm7rcpyA/GiLpL4VjfkOcZUd7FSBXGO0nBBfLQL0Z2/1sVxZWc9Hhw4h 65uUW51w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d3LGV-0005kU-2P; Wed, 26 Apr 2017 11:37:47 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d3LDx-0001j9-P6 for linux-arm-kernel@bombadil.infradead.org; Wed, 26 Apr 2017 11:35:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f6wYcOPu81K3Ceeirxilo8RAwqqSQDzCPJ37T5zsVc4=; b=ChyQe6SsOJuM8ZceIE8KQOtWw ExWF+c5rE/7WeGXPNbOPQb8uTHgjGirqEc62UUVJnuRS0dI2p/wsz2E4BWSvhJZb6SuUzof0E3tHA Yd3Cgafks3sdYqRqtmFKiykaSdvXNhgzFmoNdE6dVY3spDfzFt2dcDlHqDwDJklFeJXS3Du8201On b87bw38coMtX7uPo0c1ArdshqPLFMWlFxCQ5wWl2fq5z8FY4pP+Eqwo4eUpyOgEI2GbzvyO9UCa02 e0kP3VFPG8U2Mk8snm0wOhgtgFeIMHXDqfiD9KXsMjrSlWShveN6Qbze6antOpid3hXw6Zs1HcyJU Wnpc69WOA==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d3Kxs-0003pa-Dz for linux-arm-kernel@lists.infradead.org; Wed, 26 Apr 2017 11:18:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 873BB19F6; Wed, 26 Apr 2017 04:18:10 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.206.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 953053F3E1; Wed, 26 Apr 2017 04:18:06 -0700 (PDT) From: Lorenzo Pieralisi To: linux-pci@vger.kernel.org Subject: [RFC/RFT PATCH 09/18] PCI: aardvark: Convert PCI scan API to pci_scan_root_bus_bridge() Date: Wed, 26 Apr 2017 12:18:00 +0100 Message-Id: <20170426111809.19922-10-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170426111809.19922-1-lorenzo.pieralisi@arm.com> References: <20170426111809.19922-1-lorenzo.pieralisi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170426_071832_678577_1ECF6608 X-CRM114-Status: GOOD ( 12.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wenrui Li , Gabriele Paoloni , Shawn Lin , Will Deacon , Michal Simek , Thierry Reding , Tanmay Inamdar , Matthew Minter , Lorenzo Pieralisi , Rob Herring , Joao Pinto , Pratyush Anand , Russell King , Murali Karicheri , Arnd Bergmann , Bharat Kumar Gogada , Simon Horman , Bjorn Helgaas , Mingkai Hu , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Jingoo Han , Stanimir Varbanov , Minghuan Lian , Zhou Wang , Roy Zang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The introduction of pci_scan_root_bus_bridge() provides a PCI core API to scan a PCI root bus backed by an already initialized struct pci_host_bridge object, which simplifies the bus scan interface and makes the PCI scan root bus interface easier to generalize as members are added to the struct pci_host_bridge(). Convert PCI aardvark host code to pci_scan_root_bus_bridge() to improve the PCI root bus scanning interface. Signed-off-by: Lorenzo Pieralisi Cc: Jingoo Han Cc: Bjorn Helgaas Cc: Joao Pinto --- drivers/pci/host/pci-aardvark.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c index 4fce494..ee6fd51 100644 --- a/drivers/pci/host/pci-aardvark.c +++ b/drivers/pci/host/pci-aardvark.c @@ -917,6 +917,7 @@ static int advk_pcie_probe(struct platform_device *pdev) struct advk_pcie *pcie; struct resource *res; struct pci_bus *bus, *child; + struct pci_host_bridge *bridge; struct msi_controller *msi; struct device_node *msi_node; int ret, irq; @@ -968,14 +969,25 @@ static int advk_pcie_probe(struct platform_device *pdev) else msi = NULL; - bus = pci_scan_root_bus_msi(dev, 0, &advk_pcie_ops, - pcie, &pcie->resources, &pcie->msi); - if (!bus) { - advk_pcie_remove_msi_irq_domain(pcie); - advk_pcie_remove_irq_domain(pcie); - return -ENOMEM; + bridge = pci_alloc_host_bridge(0); + if (!bridge) { + ret = -ENOMEM; + goto error; } + list_splice_init(&pcie->resources, &bridge->windows); + bridge->dev.parent = dev; + bridge->sysdata = pcie; + bridge->busnr = 0; + bridge->ops = &advk_pcie_ops; + bridge->msi = &pcie->msi; + + ret = pci_scan_root_bus_bridge(bridge); + if (ret < 0) + goto error_bridge; + + bus = bridge->bus; + pci_bus_assign_resources(bus); list_for_each_entry(child, &bus->children, node) @@ -983,6 +995,15 @@ static int advk_pcie_probe(struct platform_device *pdev) pci_bus_add_devices(bus); return 0; + + error_bridge: + pci_free_host_bridge(bridge); + + error: + advk_pcie_remove_msi_irq_domain(pcie); + advk_pcie_remove_irq_domain(pcie); + + return ret; } static const struct of_device_id advk_pcie_of_match_table[] = {