]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
Backport: PCI: allow pci_alloc_child_bus() to handle a NULL bridge
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 13 Mar 2009 07:41:52 +0000 (07:41 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 13 Mar 2009 07:41:52 +0000 (07:41 +0000)
    commit 3789fa8a2e534523c896a32a9f27f78d52ad7d82
    Author: Yu Zhao <yu.zhao@intel.com>
    Date:   Sat Nov 22 02:41:07 2008 +0800

    PCI: allow pci_alloc_child_bus() to handle a NULL bridge

    Allow pci_alloc_child_bus() to allocate buses without bridge
    devices.
    Some SR-IOV devices can occupy more than one bus number, but there
    is no
    explicit bridges because that have internal routing mechanism.

Signed-off-by: Yu Zhao <yu.zhao@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Yu Zhao <yu.zhao@intel.com>
drivers/pci/probe.c

index 68d5ddd5f8625886a6375f191e38a95382dd61e6..49062cc757878b62aa2be96970959a41be63045b 100644 (file)
@@ -392,12 +392,10 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr)
        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);
 
        child->class_dev.class = &pcibus_class;
        sprintf(child->class_dev.class_id, "%04x:%02x", pci_domain_nr(child), busnr);
@@ -412,6 +410,12 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr)
        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 < 4; i++) {
                child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i];