x86/PCI: Factor out pcibios_allocate_bridge_resources()
authorYinghai Lu <yinghai@kernel.org>
Sun, 4 Nov 2012 04:39:24 +0000 (21:39 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 7 Jan 2013 19:18:36 +0000 (12:18 -0700)
Thus pcibios_allocate_bus_resources() could more simple and clean.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
arch/x86/pci/i386.c

index dd8ca6f7223be11ad7900649e699a35f147e2da1..980036286909b893d30e865b1fbf9837605f205b 100644 (file)
@@ -193,34 +193,36 @@ EXPORT_SYMBOL(pcibios_align_resource);
  *         as well.
  */
 
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 {
-       struct pci_bus *bus;
-       struct pci_dev *dev;
        int idx;
        struct resource *r;
 
+       for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
+               r = &dev->resource[idx];
+               if (!r->flags)
+                       continue;
+               if (!r->start || pci_claim_resource(dev, idx) < 0) {
+                       /*
+                        * Something is wrong with the region.
+                        * Invalidate the resource to prevent
+                        * child resource allocations in this
+                        * range.
+                        */
+                       r->start = r->end = 0;
+                       r->flags = 0;
+               }
+       }
+}
+
+static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+{
+       struct pci_bus *bus;
+
        /* Depth-First Search on bus tree */
        list_for_each_entry(bus, bus_list, node) {
-               if ((dev = bus->self)) {
-                       for (idx = PCI_BRIDGE_RESOURCES;
-                           idx < PCI_NUM_RESOURCES; idx++) {
-                               r = &dev->resource[idx];
-                               if (!r->flags)
-                                       continue;
-                               if (!r->start ||
-                                   pci_claim_resource(dev, idx) < 0) {
-                                       /*
-                                        * Something is wrong with the region.
-                                        * Invalidate the resource to prevent
-                                        * child resource allocations in this
-                                        * range.
-                                        */
-                                       r->start = r->end = 0;
-                                       r->flags = 0;
-                               }
-                       }
-               }
+               if (bus->self)
+                       pcibios_allocate_bridge_resources(bus->self);
                pcibios_allocate_bus_resources(&bus->children);
        }
 }