]> Pileus Git - ~andy/linux/commitdiff
x86/PCI: Factor out pcibios_allocate_dev_rom_resource()
authorYinghai Lu <yinghai@kernel.org>
Sun, 4 Nov 2012 04:39:27 +0000 (21:39 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 7 Jan 2013 22:58:34 +0000 (15:58 -0700)
Factor pcibios_allocate_rom_resources() and
pcibios_allocate_dev_rom_resource() out of pcibios_assign_resources().
This will allow us to allocate ROM resources for hot-added root buses.

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

index 84696ed1f0e9767b418d395bce7a77441026b4d4..42dd75552351898b906dd936f7f85155318960b6 100644 (file)
@@ -298,27 +298,45 @@ static void __init pcibios_allocate_resources(struct pci_bus *bus, int pass)
        }
 }
 
-static int __init pcibios_assign_resources(void)
+static void __init pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
 {
-       struct pci_dev *dev = NULL;
        struct resource *r;
 
-       if (!(pci_probe & PCI_ASSIGN_ROMS)) {
-               /*
-                * Try to use BIOS settings for ROMs, otherwise let
-                * pci_assign_unassigned_resources() allocate the new
-                * addresses.
-                */
-               for_each_pci_dev(dev) {
-                       r = &dev->resource[PCI_ROM_RESOURCE];
-                       if (!r->flags || !r->start)
-                               continue;
-                       if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
-                               r->end -= r->start;
-                               r->start = 0;
-                       }
-               }
+       /*
+        * Try to use BIOS settings for ROMs, otherwise let
+        * pci_assign_unassigned_resources() allocate the new
+        * addresses.
+        */
+       r = &dev->resource[PCI_ROM_RESOURCE];
+       if (!r->flags || !r->start)
+               return;
+
+       if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
+               r->end -= r->start;
+               r->start = 0;
        }
+}
+static void __init pcibios_allocate_rom_resources(struct pci_bus *bus)
+{
+       struct pci_dev *dev;
+       struct pci_bus *child;
+
+       list_for_each_entry(dev, &bus->devices, bus_list) {
+               pcibios_allocate_dev_rom_resource(dev);
+
+               child = dev->subordinate;
+               if (child)
+                       pcibios_allocate_rom_resources(child);
+       }
+}
+
+static int __init pcibios_assign_resources(void)
+{
+       struct pci_bus *bus;
+
+       if (!(pci_probe & PCI_ASSIGN_ROMS))
+               list_for_each_entry(bus, &pci_root_buses, node)
+                       pcibios_allocate_rom_resources(bus);
 
        pci_assign_unassigned_resources();
        pcibios_fw_addr_list_del();