From patchwork Fri Jan 16 01:44:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 5645121 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A55FCC058D for ; Fri, 16 Jan 2015 03:54:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB02520172 for ; Fri, 16 Jan 2015 03:54:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD76D200CF for ; Fri, 16 Jan 2015 03:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752602AbbAPDyc (ORCPT ); Thu, 15 Jan 2015 22:54:32 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:41174 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754189AbbAPDre (ORCPT ); Thu, 15 Jan 2015 22:47:34 -0500 Received: from 172.24.2.119 (EHLO szxeml407-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CHY77877; Fri, 16 Jan 2015 11:47:25 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml407-hub.china.huawei.com (10.82.67.94) with Microsoft SMTP Server id 14.3.158.1; Fri, 16 Jan 2015 11:47:18 +0800 From: Yijing Wang To: Bjorn Helgaas CC: Jiang Liu , , Yinghai Lu , , Marc Zyngier , , Russell King , , Thomas Gleixner , Tony Luck , , "David S. Miller" , "Guan Xuetao" , , , Liviu Dudau , "Arnd Bergmann" , Geert Uytterhoeven , "Yijing Wang" Subject: [PATCH 19/28] PCI: Introduce pci_bus_child_max_busnr() Date: Fri, 16 Jan 2015 09:44:17 +0800 Message-ID: <1421372666-12288-20-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1421372666-12288-1-git-send-email-wangyijing@huawei.com> References: <1421372666-12288-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes, we need to know the highest reserved busnr for children bus. Because parent's bus->busn_res could have padding in it. This function return the max child busnr as pci_scan_child_bus(). Signed-off-by: Yijing Wang --- drivers/pci/hotplug/acpiphp_glue.c | 29 +---------------------------- drivers/pci/pci.c | 25 ++++++++++++++++++++++++- include/linux/pci.h | 2 +- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index bcb90e4..84f2584 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) acpi_unlock_hp_context(); } -/** - * acpiphp_max_busnr - return the highest reserved bus number under the given bus. - * @bus: bus to start search with - */ -static unsigned char acpiphp_max_busnr(struct pci_bus *bus) -{ - struct pci_bus *tmp; - unsigned char max, n; - - /* - * pci_bus_max_busnr will return the highest - * reserved busnr for all these children. - * that is equivalent to the bus->subordinate - * value. We don't want to use the parent's - * bus->subordinate value because it could have - * padding in it. - */ - max = bus->busn_res.start; - - list_for_each_entry(tmp, &bus->children, node) { - n = pci_bus_max_busnr(tmp); - if (n > max) - max = n; - } - return max; -} - static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) { struct acpiphp_func *func; @@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot) LIST_HEAD(add_list); acpiphp_rescan_slot(slot); - max = acpiphp_max_busnr(bus); + max = pci_bus_child_max_busnr(bus); for (pass = 0; pass < 2; pass++) { list_for_each_entry(dev, &bus->devices, bus_list) { if (PCI_SLOT(dev->devfn) != slot->device) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8b35e8e..a05f406 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus) } return max; } -EXPORT_SYMBOL_GPL(pci_bus_max_busnr); + +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus) +{ + struct pci_bus *tmp; + unsigned char max, n; + + /* + * pci_bus_max_busnr will return the highest + * reserved busnr for all these children. + * that is equivalent to the bus->subordinate + * value. We don't want to use the parent's + * bus->subordinate value because it could have + * padding in it. + */ + max = bus->busn_res.start; + + list_for_each_entry(tmp, &bus->children, node) { + n = pci_bus_max_busnr(tmp); + if (n > max) + max = n; + } + return max; +} +EXPORT_SYMBOL_GPL(pci_bus_child_max_busnr); #ifdef CONFIG_HAS_IOMEM void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) diff --git a/include/linux/pci.h b/include/linux/pci.h index da3a071..2970a84 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1176,7 +1176,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), void *userdata); int pci_cfg_space_size(struct pci_dev *dev); -unsigned char pci_bus_max_busnr(struct pci_bus *bus); +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus); void pci_setup_bridge(struct pci_bus *bus); resource_size_t pcibios_window_alignment(struct pci_bus *bus, unsigned long type);