powerpc: Use of for_each_node_by_name() instead of open-coding it
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 1 Feb 2017 01:54:37 +0000 (17:54 -0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 4 Dec 2017 02:10:59 +0000 (13:10 +1100)
Instead of manually coding the loop with of_find_node_by_name(), let's
switch to the standard macro for iterating over nodes with given name.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
[mpe: Fix build failures due to typo in mpc832x_mds.c]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/83xx/mpc832x_mds.c
arch/powerpc/platforms/83xx/mpc832x_rdb.c
arch/powerpc/platforms/83xx/mpc836x_mds.c
arch/powerpc/platforms/cell/interrupt.c
arch/powerpc/platforms/cell/setup.c
arch/powerpc/platforms/cell/spider-pic.c
arch/powerpc/platforms/powermac/feature.c

index bb7b25acf26ffd800d0ead5173c70031b5a488d2..74c154e67c8bbf82a627a84074febbafea42eeb4 100644 (file)
@@ -75,7 +75,7 @@ static void __init mpc832x_sys_setup_arch(void)
                par_io_init(np);
                of_node_put(np);
 
-               for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
+               for_each_node_by_name(np, "ucc")
                        par_io_of_config(np);
        }
 
index a4539c5accb0bc68f29aa814d5845eb24a13c241..43898659387371b1db60a6d4372ea3c0ffbb1f6f 100644 (file)
@@ -204,7 +204,7 @@ static void __init mpc832x_rdb_setup_arch(void)
                par_io_init(np);
                of_node_put(np);
 
-               for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
+               for_each_node_by_name(np, "ucc")
                        par_io_of_config(np);
        }
 #endif                         /* CONFIG_QUICC_ENGINE */
index 4fc3051c2b2eee0bd4c463dec489dcab21d8f099..fd44dd03e1f3a4f90bf0efc3f81565c527dec204 100644 (file)
@@ -83,7 +83,7 @@ static void __init mpc836x_mds_setup_arch(void)
                par_io_init(np);
                of_node_put(np);
 
-               for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
+               for_each_node_by_name(np, "ucc")
                        par_io_of_config(np);
 #ifdef CONFIG_QE_USB
                /* Must fixup Par IO before QE GPIO chips are registered. */
index 6fc85e29dc082a5a00a79298dc768acf9b99f0bd..5d4bf9aed51ae74da8f4e28763917acd8cba885c 100644 (file)
@@ -315,8 +315,7 @@ static int __init setup_iic(void)
        struct cbe_iic_regs __iomem *node_iic;
        const u32 *np;
 
-       for (dn = NULL;
-            (dn = of_find_node_by_name(dn,"interrupt-controller")) != NULL;) {
+       for_each_node_by_name(dn, "interrupt-controller") {
                if (!of_device_is_compatible(dn,
                                     "IBM,CBEA-Internal-Interrupt-Controller"))
                        continue;
index d3543e68efe80afde410f40665bb17af61a4e5f7..7d31b8d146613e7c0b66919357c9ae9533836a00 100644 (file)
@@ -192,8 +192,7 @@ static void __init mpic_init_IRQ(void)
        struct device_node *dn;
        struct mpic *mpic;
 
-       for (dn = NULL;
-            (dn = of_find_node_by_name(dn, "interrupt-controller"));) {
+       for_each_node_by_name(dn, "interrupt-controller") {
                if (!of_device_is_compatible(dn, "CBEA,platform-open-pic"))
                        continue;
 
index aa44bfc464677a3c3718d0f9e5febfb55b90a38a..c137f0cb4151757410d584d53c69c4a68dd2f369 100644 (file)
@@ -343,8 +343,7 @@ void __init spider_init_IRQ(void)
         * device-tree is bogus anyway) so all we can do is pray or maybe test
         * the address and deduce the node-id
         */
-       for (dn = NULL;
-            (dn = of_find_node_by_name(dn, "interrupt-controller"));) {
+       for_each_node_by_name(dn, "interrupt-controller") {
                if (of_device_is_compatible(dn, "CBEA,platform-spider-pic")) {
                        if (of_address_to_resource(dn, 0, &r)) {
                                printk(KERN_WARNING "spider-pic: Failed\n");
index 80a31f581d361977ac81c0c670284fef5b3b597f..466b842346831947e9af8480694361859e6fd150 100644 (file)
@@ -2641,7 +2641,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
        phys_addr_t             addr;
        u64                     size;
 
-       for (node = NULL; (node = of_find_node_by_name(node, name)) != NULL;) {
+       for_each_node_by_name(node, name) {
                if (!compat)
                        break;
                if (of_device_is_compatible(node, compat))