Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752670AbdF0JYh (ORCPT ); Tue, 27 Jun 2017 05:24:37 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:19053 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751569AbdF0JYU (ORCPT ); Tue, 27 Jun 2017 05:24:20 -0400 From: Ryder Lee To: Andrew Morton , Stephen Rothwell CC: Bjorn Helgaas , , , Ryder Lee Subject: [PATCH] PCI: mediatek: change to use the new host bridge interface Date: Tue, 27 Jun 2017 17:24:11 +0800 Message-ID: <1498555451-55073-2-git-send-email-ryder.lee@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498555451-55073-1-git-send-email-ryder.lee@mediatek.com> References: <1498555451-55073-1-git-send-email-ryder.lee@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1631 Lines: 47 With the introduction of pci_scan_root_bus_bridge() there is no need to export pci_register_host_bridge() to other kernel subsystems other than the PCI compilation unit that needs it. Make pci_register_host_bridge() static to its compilation unit and convert the existing drivers usage over to pci_scan_root_bus_bridge(). Also, when probing the PCI host controller driver, if an error occurs, the probe function code does not free memory allocated for the struct pci_host_bridge resulting in memory leakage. This patch fixes them by using the methods that introduces by Lorenzo. Signed-off-by: Ryder Lee --- drivers/pci/host/pcie-mediatek.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c index 3baafa8..514ef34 100644 --- a/drivers/pci/host/pcie-mediatek.c +++ b/drivers/pci/host/pcie-mediatek.c @@ -482,12 +482,10 @@ static int mtk_pcie_register_host(struct pci_host_bridge *host) host->dev.parent = pcie->dev; host->ops = &mtk_pcie_ops; - err = pci_register_host_bridge(host); + err = pci_scan_root_bus_bridge(host); if (err < 0) return err; - pci_scan_child_bus(host->bus); - pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); pci_bus_size_bridges(host->bus); pci_bus_assign_resources(host->bus); @@ -506,7 +504,7 @@ static int mtk_pcie_probe(struct platform_device *pdev) struct pci_host_bridge *host; int err; - host = pci_alloc_host_bridge(sizeof(*pcie)); + host = devm_pci_alloc_host_bridge(&pdev->dev, sizeof(*pcie)); if (!host) return -ENOMEM; -- 1.9.1