From patchwork Fri Aug 17 10:26:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144470 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600507ljj; Fri, 17 Aug 2018 03:32:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzCszazrbxoDoX/iR5n9PyINs5rJ4X/6I7xoXkdvnYRFfyqrwBmHfc/xc4nk9hGZp2qo9wN X-Received: by 2002:a62:5047:: with SMTP id e68-v6mr36450734pfb.157.1534501960758; Fri, 17 Aug 2018 03:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501960; cv=none; d=google.com; s=arc-20160816; b=AMI1a6CEMOnrEPnaQuxjq8gtAZVgaMat0awuDmcyz38/fF3lpqwjKISql6ZNf+v8cL pVA9y1zgaPGw45PNAiF/4qVVc/G07DlbXxNUpvZr27xsxXGzalQ7MhlMo/5QzJQGnoog 4pYrPbvuz4HKlGpNlOfTnZu0c40lnUaDYt5uiqhrI/nWDUCmOY+y/wDAa4IB9GRVranc HAHiigdqOisTh7Hvjo+EZc/s+qQrjxWE9JdjJMr07qjBJKhPCoeq3Q9AnglnGkujV42I ko5nLTSJR4qyYXwsmS3LF1bGRjsf6oDmkcsZkbDSLR3BJDSArpEfuXJzfWyzvBKGY0z3 gCEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=p8w09xVM9zhkVdyu4XW0cEIdqqulf4D5os1h1zs1Iv8=; b=Jnr1NIgd+UJqg7jDhGEgEy/iSQZ8R6eKl7F1tE/dz4/H4CZ0eeVSE4htWdUMTAY3GK ioW4aKIg2ebAqbQztsASFanOojjHi8VTrt9kwUbPrldnBpRcR+dE86rS+DQ+ykemy4eS cMqC/tq/AkIPDDT0eNQAL7VZauu1yM6jO/mWcr2FgiIGHyuXZrXnFdomggsuZTnnzybh E3yE0J4uiSHJvRATFwPMYb0ixxEPdTQyF2tB1kGZL6QTwoAJfl1HST+5RqUnmhaommjB +FdWeiJhNl/CXb43imYuW2ruX7VklKQF0VVVNU0jq5nsUD7HbzLPcJS9NqlKhU7i0Jf/ /Jdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si47820pgk.275.2018.08.17.03.32.40; Fri, 17 Aug 2018 03:32:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbeHQNfc (ORCPT + 32 others); Fri, 17 Aug 2018 09:35:32 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:56531 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbeHQNfb (ORCPT ); Fri, 17 Aug 2018 09:35:31 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M9oN6-1fjzDA0HrE-00B3KP; Fri, 17 Aug 2018 12:27:16 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 02/15] PCI: move pci_scan_bus into callers Date: Fri, 17 Aug 2018 12:26:32 +0200 Message-Id: <20180817102645.3839621-3-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:LWXnCU+7Z6xUjdeuzFbZ45bQvgVeaaHfbEf3zC3L26Zzk+q2P/M eBqWnJgU7gwLWWrQHzKtQNFZcb0iVWb27FKaSLk3FaYqvRDAS8Fc4O+kVUSdbViQeydnUMw h7NpiAMFG72dNFXfPHSVlJ0LvhHR19fn798oy2WXLztnZxxmtfjsh5iUmx/CcbOiGkUFKfA 9U53X0yWkPqyToR2KeuMw== X-UI-Out-Filterresults: notjunk:1; V01:K0:i52elxbByfA=:zby/nqAY9+e5yB3sPpAwYv XLGsWsbrJP8EnEyYsf7aWdz+YQwQ06Ay+C2xJ5V8q/Z5WbutiLIkDZsmtklPkwbb7VCHQtmNc htBAhFuY5icvQ7ZSlxEM+0cGgKZ6I3KOhTvVIAI1hTJZCc+BkIF9BYnyKn0Yp+PCGgxGDQc9M z2qGTvyaoqU2FTh0gNlCN4py088cSrcuWuOyS7lrUNN+yexf76tAyIai6J/Qpo1nTPKfX4UaC a/AVBf3VrEDHfcR6l+BV8i7N5LVgln2sjTmuo8Yg0ZW5xLMpvJQQ7LDbTff8GLoJHdL/v9vSL l9M5feuoSNoq08gOtnzB7oh0V9yrObBfHyHyzIj2cw4sWC9u++uFOAaRAtFMZN94PM8BJ3wos j9q5FETIOSk9yTticaNzrsQkjVgxSCp0V7yo94oM1lVcK9JZiJ//fG1W8/rU5B2Re2dDyMPqj z8OF1cfeU1Uk4B22sF2AA9+660U331pPJxrV17EIAM6i/2TpX8dlrUBkXabg7pquF9KiJOSFI iLwaWs2BlcB74LMmqnjgmIPZ9LpA2kF2IE9kVlqdkJ3iltoUzxWxMatjJZJTVH4aB0puA0L8Z 3E4j6jwjkz1DogegisuGl2kt9gbdDITkq6aqv9vgGww9e/6hPek/b5d4mHT/kyli11fgFtW4G 2bcIKPNIenX30apnEBsXNGgTE7pq3vgJD97ENKj+H4O9bz1RK2rxVEgLDfx8bQnPwmJE= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are only two remaining callers of the old pci_scan_bus() interface. Since we want to expose the pci_host_bridge structure everywhere and discourage users from calling the old interfaces, let's move the implementation into the respective callsites. While this duplicates the source code, it makes the object code smaller for all users by avoiding the global implementation, and it allows further cleanup of the two callers. Signed-off-by: Arnd Bergmann --- arch/sparc/kernel/pcic.c | 35 ++++++++++++++++++++++++++++++ drivers/pci/hotplug/ibmphp_core.c | 35 ++++++++++++++++++++++++++++++ drivers/pci/probe.c | 36 ------------------------------- include/linux/pci.h | 1 - 4 files changed, 70 insertions(+), 37 deletions(-) -- 2.18.0 diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index ee4c9a9a171c..0197b80fe590 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c @@ -387,6 +387,41 @@ int __init pcic_probe(void) return 0; } +static struct resource busn_resource = { + .name = "PCI busn", + .start = 0, + .end = 255, + .flags = IORESOURCE_BUS, +}; + +static struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, + void *sysdata) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + pci_add_resource(&bridge->windows, &ioport_resource); + pci_add_resource(&bridge->windows, &iomem_resource); + pci_add_resource(&bridge->windows, &busn_resource); + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err; + + return bridge->bus; + +err_res: + pci_free_host_bridge(bridge); + return NULL; +} + static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) { struct linux_pbm_info *pbm = &pcic->pbm; diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 4ea57e9019f1..d35463ee96ba 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c @@ -717,6 +717,41 @@ static void ibm_unconfigure_device(struct pci_func *func) pci_unlock_rescan_remove(); } +static struct resource busn_resource = { + .name = "pci busn", + .start = 0, + .end = 255, + .flags = IORESOURCE_BUS, +}; + +static struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, + void *sysdata) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + pci_add_resource(&bridge->windows, &ioport_resource); + pci_add_resource(&bridge->windows, &iomem_resource); + pci_add_resource(&bridge->windows, &busn_resource); + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err; + + return bridge->bus; + +err: + pci_free_host_bridge(bridge); + return NULL; +} + /* * The following function is to fix kernel bug regarding * getting bus entries, here we manually add those primary diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b0f666271245..12c3aa63c34d 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3078,42 +3078,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, } EXPORT_SYMBOL(pci_scan_root_bus); -static struct resource busn_resource = { - .name = "PCI busn", - .start = 0, - .end = 255, - .flags = IORESOURCE_BUS, -}; - -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, - void *sysdata) -{ - struct pci_host_bridge *bridge; - int error; - - bridge = pci_alloc_host_bridge(0); - if (!bridge) - goto err; - - pci_add_resource(&bridge->windows, &ioport_resource); - pci_add_resource(&bridge->windows, &iomem_resource); - pci_add_resource(&bridge->windows, &busn_resource); - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; - - error = pci_scan_root_bus_bridge(bridge); - if (error < 0) - goto err; - - return bridge->bus; - -err: - pci_free_host_bridge(bridge); - return NULL; -} -EXPORT_SYMBOL(pci_scan_bus); - /** * pci_rescan_bus_bridge_resize - Scan a PCI bus for devices * @bridge: PCI bridge for the bus to scan diff --git a/include/linux/pci.h b/include/linux/pci.h index e72ca8dd6241..d77ce35a2b33 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -905,7 +905,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, void pcibios_scan_specific_bus(int busn); struct pci_bus *pci_find_bus(int domain, int busnr); void pci_bus_add_devices(const struct pci_bus *bus); -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata); struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources);