gpio: of: optimize "gpios" property parsing of of_parse_own_gpio()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 14 Jun 2016 10:07:03 +0000 (19:07 +0900)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 23 Jun 2016 09:07:10 +0000 (11:07 +0200)
Call of_property_read_u32_array() only once rather than iterating
of_property_read_u32_index().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib-of.c

index d8c36c1bf85058af8328a7fedecda14a06e2381e..6b866fc4657d08f1d1146b401d59a00d58c95ae8 100644 (file)
@@ -140,7 +140,7 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
                .flags = &xlate_flags,
        };
        u32 tmp;
-       int i, ret;
+       int ret;
 
        chip_np = np->parent;
        if (!chip_np)
@@ -159,12 +159,10 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
 
        gg_data.gpiospec.args_count = tmp;
        gg_data.gpiospec.np = chip_np;
-       for (i = 0; i < tmp; i++) {
-               ret = of_property_read_u32_index(np, "gpios", i,
-                                          &gg_data.gpiospec.args[i]);
-               if (ret)
-                       return ERR_PTR(ret);
-       }
+       ret = of_property_read_u32_array(np, "gpios", gg_data.gpiospec.args,
+                                        tmp);
+       if (ret)
+               return ERR_PTR(ret);
 
        gpiochip_find(&gg_data, of_gpiochip_find_and_xlate);
        if (!gg_data.out_gpio) {