]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/probe.c
PCI: replace cfg space size (256/4096) by macros.
[linux-2.6-omap-h63xx.git] / drivers / pci / probe.c
index cce2f4cb1fbf37985d7303ec2e34d9f507d92aee..f6754e87f046e5145e8ec4f576061382954c8576 100644 (file)
@@ -14,8 +14,6 @@
 
 #define CARDBUS_LATENCY_TIMER  176     /* secondary latency timer */
 #define CARDBUS_RESERVE_BUSNR  3
-#define PCI_CFG_SPACE_SIZE     256
-#define PCI_CFG_SPACE_EXP_SIZE 4096
 
 /* Ugh.  Need to stop exporting this to modules. */
 LIST_HEAD(pci_root_buses);
@@ -304,6 +302,8 @@ static int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
                } else {
                        res->start = l64;
                        res->end = l64 + sz64;
+                       printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: %pR\n",
+                               pci_name(dev), pos, res);
                }
        } else {
                sz = pci_size(l, sz, mask);
@@ -313,6 +313,10 @@ static int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 
                res->start = l;
                res->end = l + sz;
+               printk(KERN_DEBUG "PCI: %s reg %x %s: %pR\n",
+                      pci_name(dev), pos,
+                      (res->flags & IORESOURCE_IO) ? "io port":"32bit mmio",
+                      res);
        }
 
  out:
@@ -383,7 +387,8 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
                        res->start = base;
                if (!res->end)
                        res->end = limit + 0xfff;
-               printk(KERN_INFO "PCI: bridge %s io port: [%llx, %llx]\n", pci_name(dev), res->start, res->end);
+               printk(KERN_DEBUG "PCI: bridge %s io port: %pR\n",
+                      pci_name(dev), res);
        }
 
        res = child->resource[1];
@@ -395,7 +400,8 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
                res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM;
                res->start = base;
                res->end = limit + 0xfffff;
-               printk(KERN_INFO "PCI: bridge %s 32bit mmio: [%llx, %llx]\n", pci_name(dev), res->start, res->end);
+               printk(KERN_DEBUG "PCI: bridge %s 32bit mmio: %pR\n",
+                      pci_name(dev), res);
        }
 
        res = child->resource[2];
@@ -431,7 +437,9 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
                res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH;
                res->start = base;
                res->end = limit + 0xfffff;
-               printk(KERN_INFO "PCI: bridge %s %sbit mmio pref: [%llx, %llx]\n", pci_name(dev), (res->flags & PCI_PREF_RANGE_TYPE_64)?"64":"32",res->start, res->end);
+               printk(KERN_DEBUG "PCI: bridge %s %sbit mmio pref: %pR\n",
+                      pci_name(dev),
+                      (res->flags & PCI_PREF_RANGE_TYPE_64) ? "64":"32", res);
        }
 }
 
@@ -752,7 +760,7 @@ static int pci_setup_device(struct pci_dev * dev)
        dev->class = class;
        class >>= 8;
 
-       dev_dbg(&dev->dev, "found [%04x/%04x] class %06x header type %02x\n",
+       dev_dbg(&dev->dev, "found [%04x:%04x] class %06x header type %02x\n",
                 dev->vendor, dev->device, class, dev->hdr_type);
 
        /* "Unknown power state" */
@@ -877,8 +885,9 @@ static void set_pcie_port_type(struct pci_dev *pdev)
 int pci_cfg_space_size_ext(struct pci_dev *dev)
 {
        u32 status;
+       int pos = PCI_CFG_SPACE_SIZE;
 
-       if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL)
+       if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
                goto fail;
        if (status == 0xffffffff)
                goto fail;
@@ -939,6 +948,7 @@ EXPORT_SYMBOL(alloc_pci_dev);
 static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
 {
        struct pci_dev *dev;
+       struct pci_slot *slot;
        u32 l;
        u8 hdr_type;
        int delay = 1;
@@ -987,6 +997,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
        dev->error_state = pci_channel_io_normal;
        set_pcie_port_type(dev);
 
+       list_for_each_entry(slot, &bus->slots, list)
+               if (PCI_SLOT(devfn) == slot->number)
+                       dev->slot = slot;
+
        /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer)
           set this higher, assuming the system even supports it.  */
        dev->dma_mask = 0xffffffff;
@@ -1225,8 +1239,11 @@ EXPORT_SYMBOL(pci_scan_bridge);
 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 #endif
 
-static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev *b)
+static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b)
 {
+       const struct pci_dev *a = to_pci_dev(d_a);
+       const struct pci_dev *b = to_pci_dev(d_b);
+
        if      (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1;
        else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return  1;
 
@@ -1239,50 +1256,7 @@ static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev
        return 0;
 }
 
-/*
- * Yes, this forcably breaks the klist abstraction temporarily.  It
- * just wants to sort the klist, not change reference counts and
- * take/drop locks rapidly in the process.  It does all this while
- * holding the lock for the list, so objects can't otherwise be
- * added/removed while we're swizzling.
- */
-static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head *list)
-{
-       struct list_head *pos;
-       struct klist_node *n;
-       struct device *dev;
-       struct pci_dev *b;
-
-       list_for_each(pos, list) {
-               n = container_of(pos, struct klist_node, n_node);
-               dev = container_of(n, struct device, knode_bus);
-               b = to_pci_dev(dev);
-               if (pci_sort_bf_cmp(a, b) <= 0) {
-                       list_move_tail(&a->dev.knode_bus.n_node, &b->dev.knode_bus.n_node);
-                       return;
-               }
-       }
-       list_move_tail(&a->dev.knode_bus.n_node, list);
-}
-
 void __init pci_sort_breadthfirst(void)
 {
-       LIST_HEAD(sorted_devices);
-       struct list_head *pos, *tmp;
-       struct klist_node *n;
-       struct device *dev;
-       struct pci_dev *pdev;
-       struct klist *device_klist;
-
-       device_klist = bus_get_device_klist(&pci_bus_type);
-
-       spin_lock(&device_klist->k_lock);
-       list_for_each_safe(pos, tmp, &device_klist->k_list) {
-               n = container_of(pos, struct klist_node, n_node);
-               dev = container_of(n, struct device, knode_bus);
-               pdev = to_pci_dev(dev);
-               pci_insertion_sort_klist(pdev, &sorted_devices);
-       }
-       list_splice(&sorted_devices, &device_klist->k_list);
-       spin_unlock(&device_klist->k_lock);
+       bus_sort_breadthfirst(&pci_bus_type, &pci_sort_bf_cmp);
 }