powerpc: use for_each_child_of_node() macro
authorQinglang Miao <miaoqinglang@huawei.com>
Tue, 28 Jul 2020 02:28:07 +0000 (10:28 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 29 Jul 2020 12:30:33 +0000 (22:30 +1000)
Use for_each_child_of_node() macro instead of open coding it.

Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200728022807.87815-1-miaoqinglang@huawei.com
arch/powerpc/platforms/pasemi/misc.c
arch/powerpc/platforms/powermac/low_i2c.c
arch/powerpc/platforms/powermac/pfunc_base.c
arch/powerpc/platforms/powermac/udbg_scc.c

index 1cd4ca14b08d8760b341c8f2627e6eddac2a2818..1bf65d02d3ba3bee4cd5f840bc81cccc6475eef6 100644 (file)
@@ -56,8 +56,7 @@ static int __init pasemi_register_i2c_devices(void)
                if (!adap_node)
                        continue;
 
-               node = NULL;
-               while ((node = of_get_next_child(adap_node, node))) {
+               for_each_child_of_node(adap_node, node) {
                        struct i2c_board_info info = {};
                        const u32 *addr;
                        int len;
index bf4be4b53b44de55b34e7a6f51785610aae9c744..f77a59b5c2e1a9dcc7a810fc3e112ef03e7b8b32 100644 (file)
@@ -629,8 +629,7 @@ static void __init kw_i2c_probe(void)
                        for (i = 0; i < chans; i++)
                                kw_i2c_add(host, np, np, i);
                } else {
-                       for (child = NULL;
-                            (child = of_get_next_child(np, child)) != NULL;) {
+                       for_each_child_of_node(np, child) {
                                const u32 *reg = of_get_property(child,
                                                "reg", NULL);
                                if (reg == NULL)
@@ -1193,8 +1192,7 @@ static void pmac_i2c_devscan(void (*callback)(struct device_node *dev,
         * platform function instance
         */
        list_for_each_entry(bus, &pmac_i2c_busses, link) {
-               for (np = NULL;
-                    (np = of_get_next_child(bus->busnode, np)) != NULL;) {
+               for_each_child_of_node(bus->busnode, np) {
                        struct whitelist_ent *p;
                        /* If multibus, check if device is on that bus */
                        if (bus->flags & pmac_i2c_multibus)
index 62311e84a4232c4170f53fd65a8653eea5fa1005..f5422506d4b08ff04662a3da93c51dedbb296d52 100644 (file)
@@ -114,7 +114,7 @@ static void macio_gpio_init_one(struct macio_chip *macio)
         * Ok, got one, we dont need anything special to track them down, so
         * we just create them all
         */
-       for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;) {
+       for_each_child_of_node(gparent, gp) {
                const u32 *reg = of_get_property(gp, "reg", NULL);
                unsigned long offset;
                if (reg == NULL)
@@ -133,7 +133,7 @@ static void macio_gpio_init_one(struct macio_chip *macio)
            macio->of_node);
 
        /* And now we run all the init ones */
-       for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;)
+       for_each_child_of_node(gparent, gp)
                pmf_do_functions(gp, NULL, 0, PMF_FLAGS_ON_INIT, NULL);
 
        /* Note: We do not at this point implement the "at sleep" or "at wake"
index 6b61a18e8db33489c16c6c05803a19d1e29340b0..f286bdfe8346e35ac9074a6ef69e7cb84beb9723 100644 (file)
@@ -80,7 +80,7 @@ void udbg_scc_init(int force_scc)
        path = of_get_property(of_chosen, "linux,stdout-path", NULL);
        if (path != NULL)
                stdout = of_find_node_by_path(path);
-       for (ch = NULL; (ch = of_get_next_child(escc, ch)) != NULL;) {
+       for_each_child_of_node(escc, ch) {
                if (ch == stdout)
                        ch_def = of_node_get(ch);
                if (of_node_name_eq(ch, "ch-a"))