]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/pci/probe.c
PCI: deprecate pci_scan_bus_parented()
[karo-tx-linux.git] / drivers / pci / probe.c
index 04e74f4857146e4700669504de55a6ad632823a0..944ea2170f48c84f6be53a905c245aed1aa2de69 100644 (file)
@@ -1522,19 +1522,21 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
        return max;
 }
 
-struct pci_bus * pci_create_bus(struct device *parent,
-               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)
 {
-       int error;
+       int error, i;
        struct pci_bus *b, *b2;
        struct device *dev;
+       struct pci_bus_resource *bus_res, *n;
+       struct resource *res;
 
        b = pci_alloc_bus();
        if (!b)
                return NULL;
 
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (!dev){
+       if (!dev) {
                kfree(b);
                return NULL;
        }
@@ -1577,8 +1579,20 @@ struct pci_bus * pci_create_bus(struct device *parent,
        pci_create_legacy_files(b);
 
        b->number = b->secondary = bus;
-       b->resource[0] = &ioport_resource;
-       b->resource[1] = &iomem_resource;
+
+       /* Add initial resources to the bus */
+       list_for_each_entry_safe(bus_res, n, resources, list)
+               list_move_tail(&bus_res->list, &b->resources);
+
+       if (parent)
+               dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev));
+       else
+               printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
+
+       pci_bus_for_each_resource(b, res, i) {
+               if (res)
+                       dev_info(&b->dev, "root bus resource %pR\n", res);
+       }
 
        return b;
 
@@ -1594,18 +1608,72 @@ err_out:
        return NULL;
 }
 
+struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus,
+               struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+       struct pci_bus *b;
+
+       b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
+       if (!b)
+               return NULL;
+
+       b->subordinate = pci_scan_child_bus(b);
+       pci_bus_add_devices(b);
+       return b;
+}
+EXPORT_SYMBOL(pci_scan_root_bus);
+
+struct pci_bus *pci_create_bus(struct device *parent,
+               int bus, struct pci_ops *ops, void *sysdata)
+{
+       LIST_HEAD(resources);
+       struct pci_bus *b;
+
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
+       if (!b)
+               pci_free_resource_list(&resources);
+       return b;
+}
+
+/* Deprecated; use pci_scan_root_bus() instead */
 struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
                int bus, struct pci_ops *ops, void *sysdata)
 {
+       LIST_HEAD(resources);
        struct pci_bus *b;
 
-       b = pci_create_bus(parent, bus, ops, sysdata);
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
        if (b)
                b->subordinate = pci_scan_child_bus(b);
+       else
+               pci_free_resource_list(&resources);
        return b;
 }
 EXPORT_SYMBOL(pci_scan_bus_parented);
 
+struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
+                                       void *sysdata)
+{
+       LIST_HEAD(resources);
+       struct pci_bus *b;
+
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
+       if (b) {
+               b->subordinate = pci_scan_child_bus(b);
+               pci_bus_add_devices(b);
+       } else {
+               pci_free_resource_list(&resources);
+       }
+       return b;
+}
+EXPORT_SYMBOL(pci_scan_bus);
+
 #ifdef CONFIG_HOTPLUG
 /**
  * pci_rescan_bus - scan a PCI bus for devices.