Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965357Ab2B2XJV (ORCPT ); Wed, 29 Feb 2012 18:09:21 -0500 Received: from rcsinet15.oracle.com ([148.87.113.117]:25777 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932387Ab2B2XId (ORCPT ); Wed, 29 Feb 2012 18:08:33 -0500 From: Yinghai Lu To: Jesse Barnes , Benjamin Herrenschmidt , Tony Luck , David Miller , x86 Cc: Bjorn Helgaas , Dominik Brodowski , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yinghai Lu Subject: [PATCH 21/39] PCI: Add busn_res operation functions Date: Wed, 29 Feb 2012 15:07:20 -0800 Message-Id: <1330556858-11768-22-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1330556858-11768-1-git-send-email-yinghai@kernel.org> References: <1330556858-11768-1-git-send-email-yinghai@kernel.org> X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-CT-RefId: str=0001.0A090202.4F4EAFE6.00D7,ss=1,re=0.000,fgs=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2753 Lines: 91 will use them insert/update busn res in pci_bus Signed-off-by: Yinghai Lu --- drivers/pci/probe.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 53 insertions(+), 0 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index a4a20d6..5efcf1a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1687,6 +1687,56 @@ err_out: return NULL; } +void pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) +{ + struct resource *res = &b->busn_res; + struct resource *parent_res; + int ret; + + res->start = bus; + res->end = bus_max; + res->flags = IORESOURCE_BUS; + + /* no parent for root bus' busn_res */ + if (!pci_is_root_bus(b)) { + parent_res = &b->parent->busn_res; + + ret = insert_resource(parent_res, res); + + dev_printk(KERN_DEBUG, &b->dev, + "busn_res: %pR %s inserted under %pR\n", + res, ret ? "can not be" : "is", parent_res); + } else + dev_printk(KERN_DEBUG, &b->dev, + "busn_res: %pR for root bus\n", + res); +} + +void pci_bus_update_busn_res_end(struct pci_bus *b, int bus_max) +{ + struct resource *res = &b->busn_res; + struct resource old_res = *res; + + res->end = bus_max; + dev_printk(KERN_DEBUG, &b->dev, + "busn_res: %pR end updated to %pR\n", + &old_res, res); +} + +void pci_bus_release_busn_res(struct pci_bus *b) +{ + struct resource *res = &b->busn_res; + int ret; + + if (!res->flags) + return; + + ret = release_resource(res); + dev_printk(KERN_DEBUG, &b->dev, + "busn_res: %pR %s released\n", + res, ret ? "can not be" : "is"); +} + struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 84eedff..40606c1 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -671,6 +671,9 @@ 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); +void pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); +void pci_bus_update_busn_res_end(struct pci_bus *b, int busmax); +void pci_bus_release_busn_res(struct pci_bus *b); struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources); -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/