powerpc/pci: Cleanup debug printk's
[deliverable/linux.git] / arch / powerpc / kernel / pci-common.c
index 1ec73938a00f122c7685c713aefb383934728b30..09ac98e2a502ae6ae814cb499eb06007153f0b89 100644 (file)
 #include <asm/ppc-pci.h>
 #include <asm/firmware.h>
 
-#ifdef DEBUG
-#include <asm/udbg.h>
-#define DBG(fmt...) printk(fmt)
-#else
-#define DBG(fmt...)
-#endif
-
 static DEFINE_SPINLOCK(hose_spinlock);
 
 /* XXX kill that some day ... */
@@ -53,8 +46,9 @@ static int global_phb_number;         /* Global phb counter */
 /* ISA Memory physical address */
 resource_size_t isa_mem_base;
 
-/* Default PCI flags is 0 */
-unsigned int ppc_pci_flags;
+/* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */
+unsigned int ppc_pci_flags = 0;
+
 
 static struct dma_mapping_ops *pci_dma_ops;
 
@@ -214,8 +208,8 @@ void __devinit pcibios_setup_new_device(struct pci_dev *dev)
 
        sd->of_node = pci_device_to_OF_node(dev);
 
-       DBG("PCI: device %s OF node: %s\n", pci_name(dev),
-           sd->of_node ? sd->of_node->full_name : "<none>");
+       pr_debug("PCI: device %s OF node: %s\n", pci_name(dev),
+                sd->of_node ? sd->of_node->full_name : "<none>");
 
        sd->dma_ops = pci_dma_ops;
 #ifdef CONFIG_PPC32
@@ -252,7 +246,7 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
                return -1;
 #endif
 
-       DBG("Try to map irq for %s...\n", pci_name(pci_dev));
+       pr_debug("PCI: Try to map irq for %s...\n", pci_name(pci_dev));
 
 #ifdef DEBUG
        memset(&oirq, 0xff, sizeof(oirq));
@@ -276,26 +270,26 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
                    line == 0xff || line == 0) {
                        return -1;
                }
-               DBG(" -> no map ! Using line %d (pin %d) from PCI config\n",
-                   line, pin);
+               pr_debug(" No map ! Using line %d (pin %d) from PCI config\n",
+                        line, pin);
 
                virq = irq_create_mapping(NULL, line);
                if (virq != NO_IRQ)
                        set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
        } else {
-               DBG(" -> got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
-                   oirq.size, oirq.specifier[0], oirq.specifier[1],
+               pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
+                        oirq.size, oirq.specifier[0], oirq.specifier[1],
                    oirq.controller->full_name);
 
                virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
                                             oirq.size);
        }
        if(virq == NO_IRQ) {
-               DBG(" -> failed to map !\n");
+               pr_debug(" Failed to map !\n");
                return -1;
        }
 
-       DBG(" -> mapped to linux irq %d\n", virq);
+       pr_debug(" Mapped to linux irq %d\n", virq);
 
        pci_dev->irq = virq;
 
@@ -451,8 +445,8 @@ pgprot_t pci_phys_mem_access_prot(struct file *file,
                pci_dev_put(pdev);
        }
 
-       DBG("non-PCI map for %llx, prot: %lx\n",
-           (unsigned long long)offset, prot);
+       pr_debug("PCI: Non-PCI map for %llx, prot: %lx\n",
+                (unsigned long long)offset, prot);
 
        return __pgprot(prot);
 }
@@ -853,15 +847,12 @@ void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
 int pci_proc_domain(struct pci_bus *bus)
 {
        struct pci_controller *hose = pci_bus_to_host(bus);
-#ifdef CONFIG_PPC64
-       return hose->buid != 0;
-#else
+
        if (!(ppc_pci_flags & PPC_PCI_ENABLE_PROC_DOMAINS))
                return 0;
        if (ppc_pci_flags & PPC_PCI_COMPAT_DOMAIN_0)
                return hose->global_number != 0;
        return 1;
-#endif
 }
 
 void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
@@ -1198,10 +1189,10 @@ static int __init reparent_resources(struct resource *parent,
        *pp = NULL;
        for (p = res->child; p != NULL; p = p->sibling) {
                p->parent = res;
-               DBG(KERN_INFO "PCI: reparented %s [%llx..%llx] under %s\n",
-                   p->name,
-                   (unsigned long long)p->start,
-                   (unsigned long long)p->end, res->name);
+               pr_debug("PCI: Reparented %s [%llx..%llx] under %s\n",
+                        p->name,
+                        (unsigned long long)p->start,
+                        (unsigned long long)p->end, res->name);
        }
        return 0;
 }
@@ -1239,80 +1230,77 @@ static int __init reparent_resources(struct resource *parent,
  *         as well.
  */
 
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+void pcibios_allocate_bus_resources(struct pci_bus *bus)
 {
-       struct pci_bus *bus;
+       struct pci_bus *b;
        int i;
        struct resource *res, *pr;
 
-       /* Depth-First Search on bus tree */
-       list_for_each_entry(bus, bus_list, node) {
-               for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) {
-                       if ((res = bus->resource[i]) == NULL || !res->flags
-                           || res->start > res->end)
-                               continue;
-                       if (bus->parent == NULL)
-                               pr = (res->flags & IORESOURCE_IO) ?
-                                       &ioport_resource : &iomem_resource;
-                       else {
-                               /* Don't bother with non-root busses when
-                                * re-assigning all resources. We clear the
-                                * resource flags as if they were colliding
-                                * and as such ensure proper re-allocation
-                                * later.
+       for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) {
+               if ((res = bus->resource[i]) == NULL || !res->flags
+                   || res->start > res->end)
+                       continue;
+               if (bus->parent == NULL)
+                       pr = (res->flags & IORESOURCE_IO) ?
+                               &ioport_resource : &iomem_resource;
+               else {
+                       /* Don't bother with non-root busses when
+                        * re-assigning all resources. We clear the
+                        * resource flags as if they were colliding
+                        * and as such ensure proper re-allocation
+                        * later.
+                        */
+                       if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)
+                               goto clear_resource;
+                       pr = pci_find_parent_resource(bus->self, res);
+                       if (pr == res) {
+                               /* this happens when the generic PCI
+                                * code (wrongly) decides that this
+                                * bridge is transparent  -- paulus
                                 */
-                               if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)
-                                       goto clear_resource;
-                               pr = pci_find_parent_resource(bus->self, res);
-                               if (pr == res) {
-                                       /* this happens when the generic PCI
-                                        * code (wrongly) decides that this
-                                        * bridge is transparent  -- paulus
-                                        */
-                                       continue;
-                               }
+                               continue;
                        }
+               }
 
-                       DBG("PCI: %s (bus %d) bridge rsrc %d: %016llx-%016llx "
-                           "[0x%x], parent %p (%s)\n",
-                           bus->self ? pci_name(bus->self) : "PHB",
-                           bus->number, i,
-                           (unsigned long long)res->start,
-                           (unsigned long long)res->end,
-                           (unsigned int)res->flags,
-                           pr, (pr && pr->name) ? pr->name : "nil");
-
-                       if (pr && !(pr->flags & IORESOURCE_UNSET)) {
-                               if (request_resource(pr, res) == 0)
-                                       continue;
-                               /*
-                                * Must be a conflict with an existing entry.
-                                * Move that entry (or entries) under the
-                                * bridge resource and try again.
-                                */
-                               if (reparent_resources(pr, res) == 0)
-                                       continue;
-                       }
-                       printk(KERN_WARNING
-                              "PCI: Cannot allocate resource region "
-                              "%d of PCI bridge %d, will remap\n",
-                              i, bus->number);
-clear_resource:
-                       res->flags = 0;
+               pr_debug("PCI: %s (bus %d) bridge rsrc %d: %016llx-%016llx "
+                        "[0x%x], parent %p (%s)\n",
+                        bus->self ? pci_name(bus->self) : "PHB",
+                        bus->number, i,
+                        (unsigned long long)res->start,
+                        (unsigned long long)res->end,
+                        (unsigned int)res->flags,
+                        pr, (pr && pr->name) ? pr->name : "nil");
+
+               if (pr && !(pr->flags & IORESOURCE_UNSET)) {
+                       if (request_resource(pr, res) == 0)
+                               continue;
+                       /*
+                        * Must be a conflict with an existing entry.
+                        * Move that entry (or entries) under the
+                        * bridge resource and try again.
+                        */
+                       if (reparent_resources(pr, res) == 0)
+                               continue;
                }
-               pcibios_allocate_bus_resources(&bus->children);
+               printk(KERN_WARNING "PCI: Cannot allocate resource region "
+                      "%d of PCI bridge %d, will remap\n", i, bus->number);
+clear_resource:
+               res->flags = 0;
        }
+
+       list_for_each_entry(b, &bus->children, node)
+               pcibios_allocate_bus_resources(b);
 }
 
 static inline void __devinit alloc_resource(struct pci_dev *dev, int idx)
 {
        struct resource *pr, *r = &dev->resource[idx];
 
-       DBG("PCI: Allocating %s: Resource %d: %016llx..%016llx [%x]\n",
-           pci_name(dev), idx,
-           (unsigned long long)r->start,
-           (unsigned long long)r->end,
-           (unsigned int)r->flags);
+       pr_debug("PCI: Allocating %s: Resource %d: %016llx..%016llx [%x]\n",
+                pci_name(dev), idx,
+                (unsigned long long)r->start,
+                (unsigned long long)r->end,
+                (unsigned int)r->flags);
 
        pr = pci_find_parent_resource(dev, r);
        if (!pr || (pr->flags & IORESOURCE_UNSET) ||
@@ -1320,10 +1308,11 @@ static inline void __devinit alloc_resource(struct pci_dev *dev, int idx)
                printk(KERN_WARNING "PCI: Cannot allocate resource region %d"
                       " of device %s, will remap\n", idx, pci_name(dev));
                if (pr)
-                       DBG("PCI:  parent is %p: %016llx-%016llx [%x]\n", pr,
-                           (unsigned long long)pr->start,
-                           (unsigned long long)pr->end,
-                           (unsigned int)pr->flags);
+                       pr_debug("PCI:  parent is %p: %016llx-%016llx [%x]\n",
+                                pr,
+                                (unsigned long long)pr->start,
+                                (unsigned long long)pr->end,
+                                (unsigned int)pr->flags);
                /* We'll assign a new address later */
                r->flags |= IORESOURCE_UNSET;
                r->end -= r->start;
@@ -1361,7 +1350,8 @@ static void __init pcibios_allocate_resources(int pass)
                         * but keep it unregistered.
                         */
                        u32 reg;
-                       DBG("PCI: Switching off ROM of %s\n", pci_name(dev));
+                       pr_debug("PCI: Switching off ROM of %s\n",
+                                pci_name(dev));
                        r->flags &= ~IORESOURCE_ROM_ENABLE;
                        pci_read_config_dword(dev, dev->rom_base_reg, &reg);
                        pci_write_config_dword(dev, dev->rom_base_reg,
@@ -1372,10 +1362,13 @@ static void __init pcibios_allocate_resources(int pass)
 
 void __init pcibios_resource_survey(void)
 {
+       struct pci_bus *b;
+
        /* Allocate and assign resources. If we re-assign everything, then
         * we skip the allocate phase
         */
-       pcibios_allocate_bus_resources(&pci_root_buses);
+       list_for_each_entry(b, &pci_root_buses, node)
+               pcibios_allocate_bus_resources(b);
 
        if (!(ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)) {
                pcibios_allocate_resources(0);
@@ -1383,7 +1376,7 @@ void __init pcibios_resource_survey(void)
        }
 
        if (!(ppc_pci_flags & PPC_PCI_PROBE_ONLY)) {
-               DBG("PCI: Assigning unassigned resouces...\n");
+               pr_debug("PCI: Assigning unassigned resouces...\n");
                pci_assign_unassigned_resources();
        }
 
This page took 0.028317 seconds and 5 git commands to generate.