Skip to content

Commit 26cb7d8

Browse files
cyrillospaulusmack
authored andcommitted
[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>
1 parent 283029d commit 26cb7d8

6 files changed

Lines changed: 25 additions & 38 deletions

File tree

‎arch/powerpc/sysdev/fsl_soc.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,13 +1128,12 @@ arch_initcall(fs_enet_of_init);
11281128

11291129
static int __init fsl_pcmcia_of_init(void)
11301130
{
1131-
struct device_node *np = NULL;
1131+
struct device_node *np;
11321132
/*
11331133
* Register all the devices which type is "pcmcia"
11341134
*/
1135-
while ((np = of_find_compatible_node(np,
1136-
"pcmcia", "fsl,pq-pcmcia")) != NULL)
1137-
of_platform_device_create(np, "m8xx-pcmcia", NULL);
1135+
for_each_compatible_node(np, "pcmcia", "fsl,pq-pcmcia")
1136+
of_platform_device_create(np, "m8xx-pcmcia", NULL);
11381137
return 0;
11391138
}
11401139

‎arch/powerpc/sysdev/mv64x60_dev.c‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id)
241241

242242
/* only register the shared platform device the first time through */
243243
if (id == 0 && (err = eth_register_shared_pdev(np)))
244-
return err;;
244+
return err;
245245

246246
memset(r, 0, sizeof(r));
247247
of_irq_to_resource(np, 0, &r[0]);
@@ -451,22 +451,19 @@ static int __init mv64x60_device_setup(void)
451451
int id;
452452
int err;
453453

454-
for (id = 0;
455-
(np = of_find_compatible_node(np, "serial", "marvell,mpsc")); id++)
456-
if ((err = mv64x60_mpsc_device_setup(np, id)))
454+
id = 0;
455+
for_each_compatible_node(np, "serial", "marvell,mpsc")
456+
if ((err = mv64x60_mpsc_device_setup(np, id++)))
457457
goto error;
458458

459-
for (id = 0;
460-
(np = of_find_compatible_node(np, "network",
461-
"marvell,mv64x60-eth"));
462-
id++)
463-
if ((err = mv64x60_eth_device_setup(np, id)))
459+
id = 0;
460+
for_each_compatible_node(np, "network", "marvell,mv64x60-eth")
461+
if ((err = mv64x60_eth_device_setup(np, id++)))
464462
goto error;
465463

466-
for (id = 0;
467-
(np = of_find_compatible_node(np, "i2c", "marvell,mv64x60-i2c"));
468-
id++)
469-
if ((err = mv64x60_i2c_device_setup(np, id)))
464+
id = 0;
465+
for_each_compatible_node(np, "i2c", "marvell,mv64x60-i2c")
466+
if ((err = mv64x60_i2c_device_setup(np, id++)))
470467
goto error;
471468

472469
/* support up to one watchdog timer */
@@ -477,7 +474,6 @@ static int __init mv64x60_device_setup(void)
477474
of_node_put(np);
478475
}
479476

480-
481477
return 0;
482478

483479
error:

‎arch/powerpc/sysdev/mv64x60_pci.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ static int __init mv64x60_add_bridge(struct device_node *dev)
164164

165165
void __init mv64x60_pci_init(void)
166166
{
167-
struct device_node *np = NULL;
167+
struct device_node *np;
168168

169-
while ((np = of_find_compatible_node(np, "pci", "marvell,mv64x60-pci")))
169+
for_each_compatible_node(np, "pci", "marvell,mv64x60-pci")
170170
mv64x60_add_bridge(np);
171171
}

‎arch/powerpc/sysdev/mv64x60_udbg.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ static void mv64x60_udbg_init(void)
8585
if (!stdout)
8686
return;
8787

88-
for (np = NULL;
89-
(np = of_find_compatible_node(np, "serial", "marvell,mpsc")); )
88+
for_each_compatible_node(np, "serial", "marvell,mpsc") {
9089
if (np == stdout)
9190
break;
91+
}
9292

9393
of_node_put(stdout);
9494
if (!np)

‎arch/powerpc/sysdev/tsi108_dev.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ EXPORT_SYMBOL(get_vir_csrbase);
6666
static int __init tsi108_eth_of_init(void)
6767
{
6868
struct device_node *np;
69-
unsigned int i;
69+
unsigned int i = 0;
7070
struct platform_device *tsi_eth_dev;
7171
struct resource res;
7272
int ret;
7373

74-
for (np = NULL, i = 0;
75-
(np = of_find_compatible_node(np, "network", "tsi108-ethernet")) != NULL;
76-
i++) {
74+
for_each_compatible_node(np, "network", "tsi108-ethernet") {
7775
struct resource r[2];
7876
struct device_node *phy, *mdio;
7977
hw_info tsi_eth_data;
@@ -98,7 +96,7 @@ static int __init tsi108_eth_of_init(void)
9896
__FUNCTION__,r[1].name, r[1].start, r[1].end);
9997

10098
tsi_eth_dev =
101-
platform_device_register_simple("tsi-ethernet", i, &r[0],
99+
platform_device_register_simple("tsi-ethernet", i++, &r[0],
102100
1);
103101

104102
if (IS_ERR(tsi_eth_dev)) {
@@ -154,6 +152,7 @@ static int __init tsi108_eth_of_init(void)
154152
unreg:
155153
platform_device_unregister(tsi_eth_dev);
156154
err:
155+
of_node_put(np);
157156
return ret;
158157
}
159158

‎arch/powerpc/sysdev/uic.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,28 +309,23 @@ void __init uic_init_tree(void)
309309
const u32 *interrupts;
310310

311311
/* First locate and initialize the top-level UIC */
312-
313-
np = of_find_compatible_node(NULL, NULL, "ibm,uic");
314-
while (np) {
312+
for_each_compatible_node(np, NULL, "ibm,uic") {
315313
interrupts = of_get_property(np, "interrupts", NULL);
316-
if (! interrupts)
314+
if (!interrupts)
317315
break;
318-
319-
np = of_find_compatible_node(np, NULL, "ibm,uic");
320316
}
321317

322318
BUG_ON(!np); /* uic_init_tree() assumes there's a UIC as the
323319
* top-level interrupt controller */
324320
primary_uic = uic_init_one(np);
325-
if (! primary_uic)
321+
if (!primary_uic)
326322
panic("Unable to initialize primary UIC %s\n", np->full_name);
327323

328324
irq_set_default_host(primary_uic->irqhost);
329325
of_node_put(np);
330326

331327
/* The scan again for cascaded UICs */
332-
np = of_find_compatible_node(NULL, NULL, "ibm,uic");
333-
while (np) {
328+
for_each_compatible_node(np, NULL, "ibm,uic") {
334329
interrupts = of_get_property(np, "interrupts", NULL);
335330
if (interrupts) {
336331
/* Secondary UIC */
@@ -348,8 +343,6 @@ void __init uic_init_tree(void)
348343

349344
/* FIXME: setup critical cascade?? */
350345
}
351-
352-
np = of_find_compatible_node(np, NULL, "ibm,uic");
353346
}
354347
}
355348

0 commit comments

Comments
 (0)