Merge branch 'linus' into x86/amd-iommu
[pandora-kernel.git] / drivers / pci / probe.c
index f991359..b1724cf 100644 (file)
@@ -277,8 +277,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
                        res->end = res->start + sz64;
 #else
                        if (sz64 > 0x100000000ULL) {
-                               printk(KERN_ERR "PCI: Unable to handle 64-bit "
-                                       "BAR for device %s\n", pci_name(dev));
+                               dev_err(&dev->dev, "BAR %d: can't handle 64-bit"
+                                       " BAR\n", pos);
                                res->start = 0;
                                res->flags = 0;
                        } else if (lhi) {
@@ -329,7 +329,7 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
                return;
 
        if (dev->transparent) {
-               printk(KERN_INFO "PCI: Transparent bridge - %s\n", pci_name(dev));
+               dev_info(&dev->dev, "transparent bridge\n");
                for(i = 3; i < PCI_BUS_NUM_RESOURCES; i++)
                        child->resource[i] = child->parent->resource[i - 3];
        }
@@ -392,7 +392,8 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
                        limit |= ((long) mem_limit_hi) << 32;
 #else
                        if (mem_base_hi || mem_limit_hi) {
-                               printk(KERN_ERR "PCI: Unable to handle 64-bit address space for bridge %s\n", pci_name(dev));
+                               dev_err(&dev->dev, "can't handle 64-bit "
+                                       "address space for bridge\n");
                                return;
                        }
 #endif
@@ -414,6 +415,7 @@ static struct pci_bus * pci_alloc_bus(void)
                INIT_LIST_HEAD(&b->node);
                INIT_LIST_HEAD(&b->children);
                INIT_LIST_HEAD(&b->devices);
+               INIT_LIST_HEAD(&b->slots);
        }
        return b;
 }
@@ -511,8 +513,8 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
 
        pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
 
-       pr_debug("PCI: Scanning behind PCI bridge %s, config %06x, pass %d\n",
-                pci_name(dev), buses & 0xffffff, pass);
+       dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
+               buses & 0xffffff, pass);
 
        /* Disable MasterAbortMode during probing to avoid reporting
           of bus errors (in some architectures) */ 
@@ -535,8 +537,8 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
                 * ignore it.  This can happen with the i450NX chipset.
                 */
                if (pci_find_bus(pci_domain_nr(bus), busnr)) {
-                       printk(KERN_INFO "PCI: Bus %04x:%02x already known\n",
-                                       pci_domain_nr(bus), busnr);
+                       dev_info(&dev->dev, "bus %04x:%02x already known\n",
+                                pci_domain_nr(bus), busnr);
                        goto out;
                }
 
@@ -711,8 +713,9 @@ static int pci_setup_device(struct pci_dev * dev)
 {
        u32 class;
 
-       sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus),
-               dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
+       dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus),
+                    dev->bus->number, PCI_SLOT(dev->devfn),
+                    PCI_FUNC(dev->devfn));
 
        pci_read_config_dword(dev, PCI_CLASS_REVISION, &class);
        dev->revision = class & 0xff;
@@ -720,7 +723,7 @@ static int pci_setup_device(struct pci_dev * dev)
        dev->class = class;
        class >>= 8;
 
-       pr_debug("PCI: Found %s [%04x/%04x] %06x %02x\n", pci_name(dev),
+       dev_dbg(&dev->dev, "found [%04x/%04x] class %06x header type %02x\n",
                 dev->vendor, dev->device, class, dev->hdr_type);
 
        /* "Unknown power state" */
@@ -788,13 +791,13 @@ static int pci_setup_device(struct pci_dev * dev)
                break;
 
        default:                                    /* unknown header */
-               printk(KERN_ERR "PCI: device %s has unknown header type %02x, ignoring.\n",
-                       pci_name(dev), dev->hdr_type);
+               dev_err(&dev->dev, "unknown header type %02x, "
+                       "ignoring device\n", dev->hdr_type);
                return -1;
 
        bad:
-               printk(KERN_ERR "PCI: %s: class %x doesn't match header type %02x. Ignoring class.\n",
-                      pci_name(dev), class, dev->hdr_type);
+               dev_err(&dev->dev, "ignoring class %02x (doesn't match header "
+                       "type %02x)\n", class, dev->hdr_type);
                dev->class = PCI_CLASS_NOT_DEFINED;
        }
 
@@ -842,6 +845,21 @@ static void set_pcie_port_type(struct pci_dev *pdev)
  * reading the dword at 0x100 which must either be 0 or a valid extended
  * capability header.
  */
+int pci_cfg_space_size_ext(struct pci_dev *dev)
+{
+       u32 status;
+
+       if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL)
+               goto fail;
+       if (status == 0xffffffff)
+               goto fail;
+
+       return PCI_CFG_SPACE_EXP_SIZE;
+
+ fail:
+       return PCI_CFG_SPACE_SIZE;
+}
+
 int pci_cfg_space_size(struct pci_dev *dev)
 {
        int pos;
@@ -858,12 +876,7 @@ int pci_cfg_space_size(struct pci_dev *dev)
                        goto fail;
        }
 
-       if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL)
-               goto fail;
-       if (status == 0xffffffff)
-               goto fail;
-
-       return PCI_CFG_SPACE_EXP_SIZE;
+       return pci_cfg_space_size_ext(dev);
 
  fail:
        return PCI_CFG_SPACE_SIZE;
@@ -917,7 +930,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
                        return NULL;
                /* Card hasn't responded in 60 seconds?  Must be stuck. */
                if (delay > 60 * 1000) {
-                       printk(KERN_WARNING "Device %04x:%02x:%02x.%d not "
+                       printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not "
                                        "responding\n", pci_domain_nr(bus),
                                        bus->number, PCI_SLOT(devfn),
                                        PCI_FUNC(devfn));
@@ -964,7 +977,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
        dev->dev.release = pci_release_dev;
        pci_dev_get(dev);
 
-       set_dev_node(&dev->dev, pcibus_to_node(bus));
        dev->dev.dma_mask = &dev->dma_mask;
        dev->dev.dma_parms = &dev->dma_parms;
        dev->dev.coherent_dma_mask = 0xffffffffull;
@@ -975,6 +987,9 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
        /* Fix up broken headers */
        pci_fixup_device(pci_fixup_header, dev);
 
+       /* Initialize power management of the device */
+       pci_pm_init(dev);
+
        /*
         * Add the device to our list of discovered devices
         * and the bus list for fixup functions, etc.
@@ -1080,6 +1095,10 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
        return max;
 }
 
+void __attribute__((weak)) set_pci_bus_resources_arch_default(struct pci_bus *b)
+{
+}
+
 struct pci_bus * pci_create_bus(struct device *parent,
                int bus, struct pci_ops *ops, void *sysdata)
 {
@@ -1119,6 +1138,9 @@ struct pci_bus * pci_create_bus(struct device *parent,
                goto dev_reg_err;
        b->bridge = get_device(dev);
 
+       if (!parent)
+               set_dev_node(b->bridge, pcibus_to_node(b));
+
        b->dev.class = &pcibus_class;
        b->dev.parent = b->bridge;
        sprintf(b->dev.bus_id, "%04x:%02x", pci_domain_nr(b), bus);
@@ -1136,6 +1158,8 @@ struct pci_bus * pci_create_bus(struct device *parent,
        b->resource[0] = &ioport_resource;
        b->resource[1] = &iomem_resource;
 
+       set_pci_bus_resources_arch_default(b);
+
        return b;
 
 dev_create_file_err: