From patchwork Wed Apr 26 11:18:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9701287 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 380BE60245 for ; Wed, 26 Apr 2017 12:12:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E27326D08 for ; Wed, 26 Apr 2017 12:12:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1009328159; Wed, 26 Apr 2017 12:12:15 +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=ham 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 8740D26D08 for ; Wed, 26 Apr 2017 12:12:14 +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=viGgZNszhFsirlhCJBzhadsIg6ZizvDOqfjFd9Yi3yc=; b=fjFM8D2p+0IckIog1lnXGl2blU hlsJHGA3TUPIxqx3xwGnfZtOU7Wr7Pcgx66HzKNDBbzklaa1CsHPF5Oq3dxOS4m7fAciOPd7Ed2c9 8oAW93eOYfN82sBOXCLigiswyZOKVVYWPAZbVDl6JMeDHW97T1iV+M/BcvcYa1t9DBmFpSb8Oulbl L4p5pHGmkietDrCW8btmCJlky7XBLtxjKZSr3pLHps5ZY6wGoOu0pwWf6qK2fDH0212jc2Sm1ShQW nDQURqVHxYicDLYQzGUtHOpXQAwEGDgzlvsjTruwdYTW8MaJszETLMJRmrI1vyCOArVrchcVFbyX0 2/lBPmjw==; 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 1d3Lnp-0005ym-I3; Wed, 26 Apr 2017 12:12:13 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d3LnO-00050X-HU for linux-arm-kernel@bombadil.infradead.org; Wed, 26 Apr 2017 12:11:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=zl3K+r/OgF1Bzchzr7nfuhVX9gjKMiaV5lDfFrX5qcA=; b=UifrRtVOsuwVpf29sYHPPXXyx EC1dF2YhAOeEtF4SJNsd7tUy6zoz1Ju8yuy1B7Z2MEdLRLhxF1G85Mj8J4Ei94zLzkzIpNugKNtKV p8CfPWSWInVn1LnrkHPP8qyFHm0QOEUIDwc7XC9cToMkDoZdEuasDeWHwFS8vElvFiy6KSXwrOaaE wurXMiQsJSCQsDxeQQfKSeDBHghRn+7HTHtqSkKHXz01A2iVeHjPf28xJtjWOBMCTrDp0maTtqJKx 2vrW8yZ0mSzF86qKTVaz9gzlf7Zz2pDiD2u/QLEaCPeO5fkxTPJ8i77FkMNPZPBCC5CopOeZG9N6v Bsx2IL7Vg==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d3Kyc-0005HY-Ok for linux-arm-kernel@lists.infradead.org; Wed, 26 Apr 2017 11:19:29 +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 B908B19CC; Wed, 26 Apr 2017 04:18:14 -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 C78B13F3E1; Wed, 26 Apr 2017 04:18:10 -0700 (PDT) From: Lorenzo Pieralisi To: linux-pci@vger.kernel.org Subject: [RFC/RFT PATCH 10/18] PCI: rcar: Convert PCI scan API to pci_scan_root_bus_bridge() Date: Wed, 26 Apr 2017 12:18:01 +0100 Message-Id: <20170426111809.19922-11-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_121920_103156_DA109A5F X-CRM114-Status: GOOD ( 14.10 ) 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 , Rob Herring , Lorenzo Pieralisi , Pratyush Anand , Russell King , Murali Karicheri , Arnd Bergmann , Bharat Kumar Gogada , Joao Pinto , Bjorn Helgaas , Mingkai Hu , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Jingoo Han , Stanimir Varbanov , Minghuan Lian , Zhou Wang , Simon Horman , 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 rcar host code to pci_scan_root_bus_bridge() to improve the PCI root bus scanning interface. Signed-off-by: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Simon Horman --- drivers/pci/host/pcie-rcar.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index cb07c45..051b4db 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -451,27 +451,35 @@ static int rcar_pcie_enable(struct rcar_pcie *pcie) { struct device *dev = pcie->dev; struct pci_bus *bus, *child; - LIST_HEAD(res); + struct pci_host_bridge *bridge; + int ret; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return -ENOMEM; /* Try setting 5 GT/s link speed */ rcar_pcie_force_speedup(pcie); - rcar_pcie_setup(&res, pcie); + rcar_pcie_setup(&bridge->windows, pcie); pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); + bridge->dev.parent = dev; + bridge->sysdata = pcie; + bridge->busnr = pcie->root_bus_nr; + bridge->ops = &rcar_pcie_ops; if (IS_ENABLED(CONFIG_PCI_MSI)) - bus = pci_scan_root_bus_msi(dev, pcie->root_bus_nr, - &rcar_pcie_ops, pcie, &res, &pcie->msi.chip); - else - bus = pci_scan_root_bus(dev, pcie->root_bus_nr, - &rcar_pcie_ops, pcie, &res); + bridge->msi = &pcie->msi.chip; - if (!bus) { - dev_err(dev, "Scanning rootbus failed"); - return -ENODEV; + ret = pci_scan_root_bus_bridge(bridge); + if (ret < 0) { + kfree(bridge); + return ret; } + bus = bridge->bus; + pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); pci_bus_size_bridges(bus);