x86/PCI: MMCONFIG: manage pci_mmcfg_region as a list, not a table
[pandora-kernel.git] / arch / x86 / pci / mmconfig_32.c
index 8b2d561..c04523e 100644 (file)
@@ -11,9 +11,9 @@
 
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <linux/acpi.h>
 #include <asm/e820.h>
 #include <asm/pci_x86.h>
+#include <acpi/acpi.h>
 
 /* Assume systems with more busses have correct MCFG */
 #define mmcfg_virt_addr ((void __iomem *) fix_to_virt(FIX_PCIE_MCFG))
@@ -27,16 +27,13 @@ static int mmcfg_last_accessed_cpu;
  */
 static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
 {
-       struct acpi_mcfg_allocation *cfg;
-       int cfg_num;
-
-       for (cfg_num = 0; cfg_num < pci_mmcfg_config_num; cfg_num++) {
-               cfg = &pci_mmcfg_config[cfg_num];
-               if (cfg->pci_segment == seg &&
-                   (cfg->start_bus_number <= bus) &&
-                   (cfg->end_bus_number >= bus))
+       struct pci_mmcfg_region *cfg;
+
+       list_for_each_entry(cfg, &pci_mmcfg_list, list)
+               if (cfg->segment == seg &&
+                   (cfg->start_bus <= bus) &&
+                   (cfg->end_bus >= bus))
                        return cfg->address;
-       }
 
        /* Fall back to type 0 */
        return 0;
@@ -47,7 +44,7 @@ static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
  */
 static void pci_exp_set_dev_base(unsigned int base, int bus, int devfn)
 {
-       u32 dev_base = base | (bus << 20) | (devfn << 12);
+       u32 dev_base = base | PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12);
        int cpu = smp_processor_id();
        if (dev_base != mmcfg_last_accessed_device ||
            cpu != mmcfg_last_accessed_cpu) {