aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/pci_32.c
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2007-12-20 23:52:43 -0500
committerPaul Mackerras <paulus@samba.org>2008-01-16 22:57:08 -0500
commit66524b220a2929625e4c39ec692d3a4698e761fb (patch)
treeaf320f4be227b22865a9856d6ade2c82afea6fbc /arch/powerpc/kernel/pci_32.c
parentacaa617620b8b4071c6a3525b0160f4be07412d7 (diff)
[POWERPC] pci_32.c: Use for_each_child_of_node
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/pci_32.c')
-rw-r--r--arch/powerpc/kernel/pci_32.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index a9c6cb24aab0..47dc754465bb 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -13,6 +13,7 @@
13#include <linux/bootmem.h> 13#include <linux/bootmem.h>
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/of.h>
16 17
17#include <asm/processor.h> 18#include <asm/processor.h>
18#include <asm/io.h> 19#include <asm/io.h>
@@ -171,7 +172,7 @@ make_one_node_map(struct device_node* node, u8 pci_bus)
171 } else 172 } else
172 pci_to_OF_bus_map[pci_bus] = bus_range[0]; 173 pci_to_OF_bus_map[pci_bus] = bus_range[0];
173 174
174 for (node=node->child; node != 0;node = node->sibling) { 175 for_each_child_of_node(node, node) {
175 struct pci_dev* dev; 176 struct pci_dev* dev;
176 const unsigned int *class_code, *reg; 177 const unsigned int *class_code, *reg;
177 178
@@ -240,15 +241,18 @@ pcibios_make_OF_bus_map(void)
240typedef int (*pci_OF_scan_iterator)(struct device_node* node, void* data); 241typedef int (*pci_OF_scan_iterator)(struct device_node* node, void* data);
241 242
242static struct device_node* 243static struct device_node*
243scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void* data) 244scan_OF_pci_childs(struct device_node *parent, pci_OF_scan_iterator filter, void* data)
244{ 245{
246 struct device_node *node;
245 struct device_node* sub_node; 247 struct device_node* sub_node;
246 248
247 for (; node != 0;node = node->sibling) { 249 for_each_child_of_node(parent, node) {
248 const unsigned int *class_code; 250 const unsigned int *class_code;
249 251
250 if (filter(node, data)) 252 if (filter(node, data)) {
253 of_node_put(node);
251 return node; 254 return node;
255 }
252 256
253 /* For PCI<->PCI bridges or CardBus bridges, we go down 257 /* For PCI<->PCI bridges or CardBus bridges, we go down
254 * Note: some OFs create a parent node "multifunc-device" as 258 * 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 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) && 264 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) &&
261 strcmp(node->name, "multifunc-device")) 265 strcmp(node->name, "multifunc-device"))
262 continue; 266 continue;
263 sub_node = scan_OF_pci_childs(node->child, filter, data); 267 sub_node = scan_OF_pci_childs(node, filter, data);
264 if (sub_node) 268 if (sub_node) {
269 of_node_put(node);
265 return sub_node; 270 return sub_node;
271 }
266 } 272 }
267 return NULL; 273 return NULL;
268} 274}
@@ -366,7 +372,7 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
366 hose = pci_find_hose_for_OF_device(node); 372 hose = pci_find_hose_for_OF_device(node);
367 if (!hose || !hose->dn) 373 if (!hose || !hose->dn)
368 return -ENODEV; 374 return -ENODEV;
369 if (!scan_OF_pci_childs(hose->dn->child, 375 if (!scan_OF_pci_childs(hose->dn,
370 find_OF_pci_device_filter, (void *)node)) 376 find_OF_pci_device_filter, (void *)node))
371 return -ENODEV; 377 return -ENODEV;
372 reg = of_get_property(node, "reg", NULL); 378 reg = of_get_property(node, "reg", NULL);