From: Yu Zhao Subject: [PATCH 4/15 v5] PCI: make pci_alloc_child_bus() be able to handle NULL bridge Date: Tue, 21 Oct 2008 19:47:35 +0800 Message-ID: <20081021114735.GE3185@yzhao12-linux.sh.intel.com> References: <20081021114056.GA3185@yzhao12-linux.sh.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "jbarnes@virtuousgeek.org" , "randy.dunlap@oracle.com" , "grundler@parisc-linux.org" , "achiang@hp.com" , "matthew@wil.cx" , "rdreier@cisco.com" , "greg@kroah.com" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" To: "linux-pci@vger.kernel.org" Return-path: Content-Disposition: inline In-Reply-To: <20081021114056.GA3185@yzhao12-linux.sh.intel.com> Sender: linux-pci-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Make pci_alloc_child_bus() be able to handle buses without bridge devices. Some devices such as SR-IOV devices use more than one bus number while there is no explicit bridge devices since they have internal routing mechanism. Cc: Jesse Barnes Cc: Randy Dunlap Cc: Grant Grundler Cc: Alex Chiang Cc: Matthew Wilcox Cc: Roland Dreier Cc: Greg KH Signed-off-by: Yu Zhao --- drivers/pci/probe.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index db3e5a7..4b12b58 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -401,12 +401,10 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, if (!child) return NULL; - child->self = bridge; child->parent = parent; child->ops = parent->ops; child->sysdata = parent->sysdata; child->bus_flags = parent->bus_flags; - child->bridge = get_device(&bridge->dev); /* initialize some portions of the bus device, but don't register it * now as the parent is not properly set up yet. This device will get @@ -423,6 +421,11 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, child->primary = parent->secondary; child->subordinate = 0xff; + if (!bridge) + return child; + + child->self = bridge; + child->bridge = get_device(&bridge->dev); /* Set up default resource pointers and names.. */ for (i = 0; i < PCI_BRIDGE_RES_NUM; i++) { child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i]; -- 1.5.6.4