diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2007-11-29 14:44:36 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-01-16 22:56:54 -0500 |
commit | 26cb7d8bbddc8338904b8810b860ccf052c761fa (patch) | |
tree | 24a183faa00bcee80453ca1fa65f414ddea8d141 /arch/powerpc | |
parent | 283029d16a882539ab0027afd94ac52858d050b2 (diff) |
[POWERPC] Use for_each macros in arch/powerpc/sysdev
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/sysdev/fsl_soc.c | 7 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mv64x60_dev.c | 24 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mv64x60_pci.c | 4 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mv64x60_udbg.c | 4 | ||||
-rw-r--r-- | arch/powerpc/sysdev/tsi108_dev.c | 9 | ||||
-rw-r--r-- | arch/powerpc/sysdev/uic.c | 15 |
6 files changed, 25 insertions, 38 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index 4baad80ab731..217bcc2e8f86 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c | |||
@@ -1128,13 +1128,12 @@ arch_initcall(fs_enet_of_init); | |||
1128 | 1128 | ||
1129 | static int __init fsl_pcmcia_of_init(void) | 1129 | static int __init fsl_pcmcia_of_init(void) |
1130 | { | 1130 | { |
1131 | struct device_node *np = NULL; | 1131 | struct device_node *np; |
1132 | /* | 1132 | /* |
1133 | * Register all the devices which type is "pcmcia" | 1133 | * Register all the devices which type is "pcmcia" |
1134 | */ | 1134 | */ |
1135 | while ((np = of_find_compatible_node(np, | 1135 | for_each_compatible_node(np, "pcmcia", "fsl,pq-pcmcia") |
1136 | "pcmcia", "fsl,pq-pcmcia")) != NULL) | 1136 | of_platform_device_create(np, "m8xx-pcmcia", NULL); |
1137 | of_platform_device_create(np, "m8xx-pcmcia", NULL); | ||
1138 | return 0; | 1137 | return 0; |
1139 | } | 1138 | } |
1140 | 1139 | ||
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c index 548a32082e4a..304056cafb1e 100644 --- a/arch/powerpc/sysdev/mv64x60_dev.c +++ b/arch/powerpc/sysdev/mv64x60_dev.c | |||
@@ -241,7 +241,7 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id) | |||
241 | 241 | ||
242 | /* only register the shared platform device the first time through */ | 242 | /* only register the shared platform device the first time through */ |
243 | if (id == 0 && (err = eth_register_shared_pdev(np))) | 243 | if (id == 0 && (err = eth_register_shared_pdev(np))) |
244 | return err;; | 244 | return err; |
245 | 245 | ||
246 | memset(r, 0, sizeof(r)); | 246 | memset(r, 0, sizeof(r)); |
247 | of_irq_to_resource(np, 0, &r[0]); | 247 | of_irq_to_resource(np, 0, &r[0]); |
@@ -451,22 +451,19 @@ static int __init mv64x60_device_setup(void) | |||
451 | int id; | 451 | int id; |
452 | int err; | 452 | int err; |
453 | 453 | ||
454 | for (id = 0; | 454 | id = 0; |
455 | (np = of_find_compatible_node(np, "serial", "marvell,mpsc")); id++) | 455 | for_each_compatible_node(np, "serial", "marvell,mpsc") |
456 | if ((err = mv64x60_mpsc_device_setup(np, id))) | 456 | if ((err = mv64x60_mpsc_device_setup(np, id++))) |
457 | goto error; | 457 | goto error; |
458 | 458 | ||
459 | for (id = 0; | 459 | id = 0; |
460 | (np = of_find_compatible_node(np, "network", | 460 | for_each_compatible_node(np, "network", "marvell,mv64x60-eth") |
461 | "marvell,mv64x60-eth")); | 461 | if ((err = mv64x60_eth_device_setup(np, id++))) |
462 | id++) | ||
463 | if ((err = mv64x60_eth_device_setup(np, id))) | ||
464 | goto error; | 462 | goto error; |
465 | 463 | ||
466 | for (id = 0; | 464 | id = 0; |
467 | (np = of_find_compatible_node(np, "i2c", "marvell,mv64x60-i2c")); | 465 | for_each_compatible_node(np, "i2c", "marvell,mv64x60-i2c") |
468 | id++) | 466 | if ((err = mv64x60_i2c_device_setup(np, id++))) |
469 | if ((err = mv64x60_i2c_device_setup(np, id))) | ||
470 | goto error; | 467 | goto error; |
471 | 468 | ||
472 | /* support up to one watchdog timer */ | 469 | /* support up to one watchdog timer */ |
@@ -477,7 +474,6 @@ static int __init mv64x60_device_setup(void) | |||
477 | of_node_put(np); | 474 | of_node_put(np); |
478 | } | 475 | } |
479 | 476 | ||
480 | |||
481 | return 0; | 477 | return 0; |
482 | 478 | ||
483 | error: | 479 | error: |
diff --git a/arch/powerpc/sysdev/mv64x60_pci.c b/arch/powerpc/sysdev/mv64x60_pci.c index 6933f9c73b43..d21ab8fa4993 100644 --- a/arch/powerpc/sysdev/mv64x60_pci.c +++ b/arch/powerpc/sysdev/mv64x60_pci.c | |||
@@ -164,8 +164,8 @@ static int __init mv64x60_add_bridge(struct device_node *dev) | |||
164 | 164 | ||
165 | void __init mv64x60_pci_init(void) | 165 | void __init mv64x60_pci_init(void) |
166 | { | 166 | { |
167 | struct device_node *np = NULL; | 167 | struct device_node *np; |
168 | 168 | ||
169 | while ((np = of_find_compatible_node(np, "pci", "marvell,mv64x60-pci"))) | 169 | for_each_compatible_node(np, "pci", "marvell,mv64x60-pci") |
170 | mv64x60_add_bridge(np); | 170 | mv64x60_add_bridge(np); |
171 | } | 171 | } |
diff --git a/arch/powerpc/sysdev/mv64x60_udbg.c b/arch/powerpc/sysdev/mv64x60_udbg.c index 367e7b13ec00..35c77c7d0616 100644 --- a/arch/powerpc/sysdev/mv64x60_udbg.c +++ b/arch/powerpc/sysdev/mv64x60_udbg.c | |||
@@ -85,10 +85,10 @@ static void mv64x60_udbg_init(void) | |||
85 | if (!stdout) | 85 | if (!stdout) |
86 | return; | 86 | return; |
87 | 87 | ||
88 | for (np = NULL; | 88 | for_each_compatible_node(np, "serial", "marvell,mpsc") { |
89 | (np = of_find_compatible_node(np, "serial", "marvell,mpsc")); ) | ||
90 | if (np == stdout) | 89 | if (np == stdout) |
91 | break; | 90 | break; |
91 | } | ||
92 | 92 | ||
93 | of_node_put(stdout); | 93 | of_node_put(stdout); |
94 | if (!np) | 94 | if (!np) |
diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c index a113d800cbf0..be2808a292f7 100644 --- a/arch/powerpc/sysdev/tsi108_dev.c +++ b/arch/powerpc/sysdev/tsi108_dev.c | |||
@@ -66,14 +66,12 @@ EXPORT_SYMBOL(get_vir_csrbase); | |||
66 | static int __init tsi108_eth_of_init(void) | 66 | static int __init tsi108_eth_of_init(void) |
67 | { | 67 | { |
68 | struct device_node *np; | 68 | struct device_node *np; |
69 | unsigned int i; | 69 | unsigned int i = 0; |
70 | struct platform_device *tsi_eth_dev; | 70 | struct platform_device *tsi_eth_dev; |
71 | struct resource res; | 71 | struct resource res; |
72 | int ret; | 72 | int ret; |
73 | 73 | ||
74 | for (np = NULL, i = 0; | 74 | for_each_compatible_node(np, "network", "tsi108-ethernet") { |
75 | (np = of_find_compatible_node(np, "network", "tsi108-ethernet")) != NULL; | ||
76 | i++) { | ||
77 | struct resource r[2]; | 75 | struct resource r[2]; |
78 | struct device_node *phy, *mdio; | 76 | struct device_node *phy, *mdio; |
79 | hw_info tsi_eth_data; | 77 | hw_info tsi_eth_data; |
@@ -98,7 +96,7 @@ static int __init tsi108_eth_of_init(void) | |||
98 | __FUNCTION__,r[1].name, r[1].start, r[1].end); | 96 | __FUNCTION__,r[1].name, r[1].start, r[1].end); |
99 | 97 | ||
100 | tsi_eth_dev = | 98 | tsi_eth_dev = |
101 | platform_device_register_simple("tsi-ethernet", i, &r[0], | 99 | platform_device_register_simple("tsi-ethernet", i++, &r[0], |
102 | 1); | 100 | 1); |
103 | 101 | ||
104 | if (IS_ERR(tsi_eth_dev)) { | 102 | if (IS_ERR(tsi_eth_dev)) { |
@@ -154,6 +152,7 @@ static int __init tsi108_eth_of_init(void) | |||
154 | unreg: | 152 | unreg: |
155 | platform_device_unregister(tsi_eth_dev); | 153 | platform_device_unregister(tsi_eth_dev); |
156 | err: | 154 | err: |
155 | of_node_put(np); | ||
157 | return ret; | 156 | return ret; |
158 | } | 157 | } |
159 | 158 | ||
diff --git a/arch/powerpc/sysdev/uic.c b/arch/powerpc/sysdev/uic.c index ae3eadddddbd..625b275c3795 100644 --- a/arch/powerpc/sysdev/uic.c +++ b/arch/powerpc/sysdev/uic.c | |||
@@ -309,28 +309,23 @@ void __init uic_init_tree(void) | |||
309 | const u32 *interrupts; | 309 | const u32 *interrupts; |
310 | 310 | ||
311 | /* First locate and initialize the top-level UIC */ | 311 | /* First locate and initialize the top-level UIC */ |
312 | 312 | for_each_compatible_node(np, NULL, "ibm,uic") { | |
313 | np = of_find_compatible_node(NULL, NULL, "ibm,uic"); | ||
314 | while (np) { | ||
315 | interrupts = of_get_property(np, "interrupts", NULL); | 313 | interrupts = of_get_property(np, "interrupts", NULL); |
316 | if (! interrupts) | 314 | if (!interrupts) |
317 | break; | 315 | break; |
318 | |||
319 | np = of_find_compatible_node(np, NULL, "ibm,uic"); | ||
320 | } | 316 | } |
321 | 317 | ||
322 | BUG_ON(!np); /* uic_init_tree() assumes there's a UIC as the | 318 | BUG_ON(!np); /* uic_init_tree() assumes there's a UIC as the |
323 | * top-level interrupt controller */ | 319 | * top-level interrupt controller */ |
324 | primary_uic = uic_init_one(np); | 320 | primary_uic = uic_init_one(np); |
325 | if (! primary_uic) | 321 | if (!primary_uic) |
326 | panic("Unable to initialize primary UIC %s\n", np->full_name); | 322 | panic("Unable to initialize primary UIC %s\n", np->full_name); |
327 | 323 | ||
328 | irq_set_default_host(primary_uic->irqhost); | 324 | irq_set_default_host(primary_uic->irqhost); |
329 | of_node_put(np); | 325 | of_node_put(np); |
330 | 326 | ||
331 | /* The scan again for cascaded UICs */ | 327 | /* The scan again for cascaded UICs */ |
332 | np = of_find_compatible_node(NULL, NULL, "ibm,uic"); | 328 | for_each_compatible_node(np, NULL, "ibm,uic") { |
333 | while (np) { | ||
334 | interrupts = of_get_property(np, "interrupts", NULL); | 329 | interrupts = of_get_property(np, "interrupts", NULL); |
335 | if (interrupts) { | 330 | if (interrupts) { |
336 | /* Secondary UIC */ | 331 | /* Secondary UIC */ |
@@ -348,8 +343,6 @@ void __init uic_init_tree(void) | |||
348 | 343 | ||
349 | /* FIXME: setup critical cascade?? */ | 344 | /* FIXME: setup critical cascade?? */ |
350 | } | 345 | } |
351 | |||
352 | np = of_find_compatible_node(np, NULL, "ibm,uic"); | ||
353 | } | 346 | } |
354 | } | 347 | } |
355 | 348 | ||