]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/pci/setup-res.c
[PATCH] Switch all my contributions stuff to a single common address
[karo-tx-linux.git] / drivers / pci / setup-res.c
index 7d35cdf4579f2f92ca8c5293053dad43511042ea..2dbd96cce2d8469e82198ec3d29ae3604ef104de 100644 (file)
@@ -26,8 +26,7 @@
 #include "pci.h"
 
 
-void
-pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
+void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
 {
        struct pci_bus_region region;
        u32 new, check, mask;
@@ -43,20 +42,18 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
        /*
         * Ignore non-moveable resources.  This might be legacy resources for
         * which no functional BAR register exists or another important
-        * system resource we should better not move around in system address
-        * space.
+        * system resource we shouldn't move around.
         */
        if (res->flags & IORESOURCE_PCI_FIXED)
                return;
 
        pcibios_resource_to_bus(dev, &region, res);
 
-       pr_debug("  got res [%llx:%llx] bus [%llx:%llx] flags %lx for "
-                "BAR %d of %s\n", (unsigned long long)res->start,
-                (unsigned long long)res->end,
+       dev_dbg(&dev->dev, "BAR %d: got res %pR bus [%#llx-%#llx] "
+               "flags %#lx\n", resno, res,
                 (unsigned long long)region.start,
                 (unsigned long long)region.end,
-                (unsigned long)res->flags, resno, pci_name(dev));
+                (unsigned long)res->flags);
 
        new = region.start | (res->flags & PCI_REGION_FLAG_MASK);
        if (res->flags & IORESOURCE_IO)
@@ -81,9 +78,8 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
        pci_read_config_dword(dev, reg, &check);
 
        if ((new ^ check) & mask) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", pci_name(dev), resno,
-                      new, check);
+               dev_err(&dev->dev, "BAR %d: error updating (%#08x != %#08x)\n",
+                       resno, new, check);
        }
 
        if ((new & (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK)) ==
@@ -92,15 +88,14 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
                pci_write_config_dword(dev, reg + 4, new);
                pci_read_config_dword(dev, reg + 4, &check);
                if (check != new) {
-                       printk(KERN_ERR "PCI: Error updating region "
-                              "%s/%d (high %08x != %08x)\n",
-                              pci_name(dev), resno, new, check);
+                       dev_err(&dev->dev, "BAR %d: error updating "
+                              "(high %#08x != %#08x)\n", resno, new, check);
                }
        }
        res->flags &= ~IORESOURCE_UNSET;
-       pr_debug("PCI: moved device %s resource %d (%lx) to %x\n",
-               pci_name(dev), resno, res->flags,
-               new & ~PCI_REGION_FLAG_MASK);
+       dev_dbg(&dev->dev, "BAR %d: moved to bus [%#llx-%#llx] flags %#lx\n",
+               resno, (unsigned long long)region.start,
+               (unsigned long long)region.end, res->flags);
 }
 
 int pci_claim_resource(struct pci_dev *dev, int resource)
@@ -117,12 +112,11 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
                err = insert_resource(root, res);
 
        if (err) {
-               printk(KERN_ERR "PCI: %s region %d of %s %s [%llx:%llx]\n",
-                       root ? "Address space collision on" :
-                               "No parent found for",
-                       resource, dtype, pci_name(dev),
-                       (unsigned long long)res->start,
-                       (unsigned long long)res->end);
+               dev_err(&dev->dev, "BAR %d: %s of %s %pR\n",
+                       resource,
+                       root ? "address space collision on" :
+                               "no parent found for",
+                       dtype, res);
        }
 
        return err;
@@ -135,16 +129,14 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
        resource_size_t size, min, align;
        int ret;
 
-       size = res->end - res->start + 1;
+       size = resource_size(res);
        min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM;
 
        align = resource_alignment(res);
        if (!align) {
-               printk(KERN_ERR "PCI: Cannot allocate resource (bogus "
-                       "alignment) %d [%llx:%llx] (flags %lx) of %s\n",
-                       resno, (unsigned long long)res->start,
-                       (unsigned long long)res->end, res->flags,
-                       pci_name(dev));
+               dev_err(&dev->dev, "BAR %d: can't allocate resource (bogus "
+                       "alignment) %pR flags %#lx\n",
+                       resno, res, res->flags);
                return -EINVAL;
        }
 
@@ -165,11 +157,8 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
        }
 
        if (ret) {
-               printk(KERN_ERR "PCI: Failed to allocate %s resource "
-                       "#%d:%llx@%llx for %s\n",
-                       res->flags & IORESOURCE_IO ? "I/O" : "mem",
-                       resno, (unsigned long long)size,
-                       (unsigned long long)res->start, pci_name(dev));
+               dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
+                       resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
        } else {
                res->flags &= ~IORESOURCE_STARTALIGN;
                if (resno < PCI_BRIDGE_RESOURCES)
@@ -205,11 +194,8 @@ int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
        }
 
        if (ret) {
-               printk(KERN_ERR "PCI: Failed to allocate %s resource "
-                               "#%d:%llx@%llx for %s\n",
-                       res->flags & IORESOURCE_IO ? "I/O" : "mem",
-                       resno, (unsigned long long)(res->end - res->start + 1),
-                       (unsigned long long)res->start, pci_name(dev));
+               dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
+                       resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
        } else if (resno < PCI_BRIDGE_RESOURCES) {
                pci_update_resource(dev, res, resno);
        }
@@ -239,11 +225,9 @@ void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
 
                r_align = resource_alignment(r);
                if (!r_align) {
-                       printk(KERN_WARNING "PCI: bogus alignment of resource "
-                               "%d [%llx:%llx] (flags %lx) of %s\n",
-                               i, (unsigned long long)r->start,
-                               (unsigned long long)r->end, r->flags,
-                               pci_name(dev));
+                       dev_warn(&dev->dev, "BAR %d: bogus alignment "
+                               "%pR flags %#lx\n",
+                               i, r, r->flags);
                        continue;
                }
                for (list = head; ; list = list->next) {
@@ -291,9 +275,7 @@ int pci_enable_resources(struct pci_dev *dev, int mask)
 
                if (!r->parent) {
                        dev_err(&dev->dev, "device not available because of "
-                               "BAR %d [%llx:%llx] collisions\n", i,
-                               (unsigned long long) r->start,
-                               (unsigned long long) r->end);
+                               "BAR %d %pR collisions\n", i, r);
                        return -EINVAL;
                }