]> err.no Git - linux-2.6/blobdiff - arch/powerpc/kernel/pci_32.c
ftrace: limit trace entries
[linux-2.6] / arch / powerpc / kernel / pci_32.c
index a9c6cb24aab0c16f4165f7cfcf3389e4c1a826f0..88db4ffaf11c772e5f73ccbbca6cd96f07eb2c88 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/bootmem.h>
 #include <linux/irq.h>
 #include <linux/list.h>
+#include <linux/of.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
@@ -93,64 +94,6 @@ fixup_cpc710_pci64(struct pci_dev* dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM,    PCI_DEVICE_ID_IBM_CPC710_PCI64, fixup_cpc710_pci64);
 
-
-void __init
-update_bridge_resource(struct pci_dev *dev, struct resource *res)
-{
-       u8 io_base_lo, io_limit_lo;
-       u16 mem_base, mem_limit;
-       u16 cmd;
-       resource_size_t start, end, off;
-       struct pci_controller *hose = dev->sysdata;
-
-       if (!hose) {
-               printk("update_bridge_base: no hose?\n");
-               return;
-       }
-       pci_read_config_word(dev, PCI_COMMAND, &cmd);
-       pci_write_config_word(dev, PCI_COMMAND,
-                             cmd & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY));
-       if (res->flags & IORESOURCE_IO) {
-               off = (unsigned long) hose->io_base_virt - isa_io_base;
-               start = res->start - off;
-               end = res->end - off;
-               io_base_lo = (start >> 8) & PCI_IO_RANGE_MASK;
-               io_limit_lo = (end >> 8) & PCI_IO_RANGE_MASK;
-               if (end > 0xffff)
-                       io_base_lo |= PCI_IO_RANGE_TYPE_32;
-               else
-                       io_base_lo |= PCI_IO_RANGE_TYPE_16;
-               pci_write_config_word(dev, PCI_IO_BASE_UPPER16,
-                               start >> 16);
-               pci_write_config_word(dev, PCI_IO_LIMIT_UPPER16,
-                               end >> 16);
-               pci_write_config_byte(dev, PCI_IO_BASE, io_base_lo);
-               pci_write_config_byte(dev, PCI_IO_LIMIT, io_limit_lo);
-
-       } else if ((res->flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH))
-                  == IORESOURCE_MEM) {
-               off = hose->pci_mem_offset;
-               mem_base = ((res->start - off) >> 16) & PCI_MEMORY_RANGE_MASK;
-               mem_limit = ((res->end - off) >> 16) & PCI_MEMORY_RANGE_MASK;
-               pci_write_config_word(dev, PCI_MEMORY_BASE, mem_base);
-               pci_write_config_word(dev, PCI_MEMORY_LIMIT, mem_limit);
-
-       } else if ((res->flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH))
-                  == (IORESOURCE_MEM | IORESOURCE_PREFETCH)) {
-               off = hose->pci_mem_offset;
-               mem_base = ((res->start - off) >> 16) & PCI_PREF_RANGE_MASK;
-               mem_limit = ((res->end - off) >> 16) & PCI_PREF_RANGE_MASK;
-               pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, mem_base);
-               pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, mem_limit);
-
-       } else {
-               DBG(KERN_ERR "PCI: ugh, bridge %s res has flags=%lx\n",
-                   pci_name(dev), res->flags);
-       }
-       pci_write_config_word(dev, PCI_COMMAND, cmd);
-}
-
-
 #ifdef CONFIG_PPC_OF
 /*
  * Functions below are used on OpenFirmware machines.
@@ -171,7 +114,7 @@ make_one_node_map(struct device_node* node, u8 pci_bus)
        } else
                pci_to_OF_bus_map[pci_bus] = bus_range[0];
 
-       for (node=node->child; node != 0;node = node->sibling) {
+       for_each_child_of_node(node, node) {
                struct pci_dev* dev;
                const unsigned int *class_code, *reg;
        
@@ -240,15 +183,18 @@ pcibios_make_OF_bus_map(void)
 typedef int (*pci_OF_scan_iterator)(struct device_node* node, void* data);
 
 static struct device_node*
-scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void* data)
+scan_OF_pci_childs(struct device_node *parent, pci_OF_scan_iterator filter, void* data)
 {
+       struct device_node *node;
        struct device_node* sub_node;
 
-       for (; node != 0;node = node->sibling) {
+       for_each_child_of_node(parent, node) {
                const unsigned int *class_code;
        
-               if (filter(node, data))
+               if (filter(node, data)) {
+                       of_node_put(node);
                        return node;
+               }
 
                /* For PCI<->PCI bridges or CardBus bridges, we go down
                 * Note: some OFs create a parent node "multifunc-device" as
@@ -260,9 +206,11 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
                        (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) &&
                        strcmp(node->name, "multifunc-device"))
                        continue;
-               sub_node = scan_OF_pci_childs(node->child, filter, data);
-               if (sub_node)
+               sub_node = scan_OF_pci_childs(node, filter, data);
+               if (sub_node) {
+                       of_node_put(node);
                        return sub_node;
+               }
        }
        return NULL;
 }
@@ -270,11 +218,11 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
 static struct device_node *scan_OF_for_pci_dev(struct device_node *parent,
                                               unsigned int devfn)
 {
-       struct device_node *np = NULL;
+       struct device_node *np;
        const u32 *reg;
        unsigned int psize;
 
-       while ((np = of_get_next_child(parent, np)) != NULL) {
+       for_each_child_of_node(parent, np) {
                reg = of_get_property(np, "reg", &psize);
                if (reg == NULL || psize < 4)
                        continue;
@@ -366,7 +314,7 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
        hose = pci_find_hose_for_OF_device(node);
        if (!hose || !hose->dn)
                return -ENODEV;
-       if (!scan_OF_pci_childs(hose->dn->child,
+       if (!scan_OF_pci_childs(hose->dn,
                        find_OF_pci_device_filter, (void *)node))
                return -ENODEV;
        reg = of_get_property(node, "reg", NULL);