Commit 66524b22 authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Paul Mackerras

[POWERPC] pci_32.c: Use for_each_child_of_node

Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent acaa6176
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/of.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -171,7 +172,7 @@ make_one_node_map(struct device_node* node, u8 pci_bus) ...@@ -171,7 +172,7 @@ make_one_node_map(struct device_node* node, u8 pci_bus)
} else } else
pci_to_OF_bus_map[pci_bus] = bus_range[0]; 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; struct pci_dev* dev;
const unsigned int *class_code, *reg; const unsigned int *class_code, *reg;
...@@ -240,15 +241,18 @@ pcibios_make_OF_bus_map(void) ...@@ -240,15 +241,18 @@ pcibios_make_OF_bus_map(void)
typedef int (*pci_OF_scan_iterator)(struct device_node* node, void* data); typedef int (*pci_OF_scan_iterator)(struct device_node* node, void* data);
static struct device_node* 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; struct device_node* sub_node;
for (; node != 0;node = node->sibling) { for_each_child_of_node(parent, node) {
const unsigned int *class_code; const unsigned int *class_code;
if (filter(node, data)) if (filter(node, data)) {
of_node_put(node);
return node; return node;
}
/* For PCI<->PCI bridges or CardBus bridges, we go down /* For PCI<->PCI bridges or CardBus bridges, we go down
* Note: some OFs create a parent node "multifunc-device" as * Note: some OFs create a parent node "multifunc-device" as
...@@ -260,9 +264,11 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void* ...@@ -260,9 +264,11 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
(*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) && (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) &&
strcmp(node->name, "multifunc-device")) strcmp(node->name, "multifunc-device"))
continue; continue;
sub_node = scan_OF_pci_childs(node->child, filter, data); sub_node = scan_OF_pci_childs(node, filter, data);
if (sub_node) if (sub_node) {
of_node_put(node);
return sub_node; return sub_node;
}
} }
return NULL; return NULL;
} }
...@@ -366,7 +372,7 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn) ...@@ -366,7 +372,7 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
hose = pci_find_hose_for_OF_device(node); hose = pci_find_hose_for_OF_device(node);
if (!hose || !hose->dn) if (!hose || !hose->dn)
return -ENODEV; return -ENODEV;
if (!scan_OF_pci_childs(hose->dn->child, if (!scan_OF_pci_childs(hose->dn,
find_OF_pci_device_filter, (void *)node)) find_OF_pci_device_filter, (void *)node))
return -ENODEV; return -ENODEV;
reg = of_get_property(node, "reg", NULL); reg = of_get_property(node, "reg", NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment