gpio: Convert to use match_string() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 3 May 2018 17:14:46 +0000 (20:14 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 16 May 2018 12:35:24 +0000 (14:35 +0200)
The new helper returns index of the matching string in an array.
We are going to use it here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib-of.c

index 586d151..28d9680 100644 (file)
@@ -210,11 +210,8 @@ static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *
        if (!con_id)
                return ERR_PTR(-ENOENT);
 
-       for (i = 0; i < ARRAY_SIZE(whitelist); i++)
-               if (!strcmp(con_id, whitelist[i]))
-                       break;
-
-       if (i == ARRAY_SIZE(whitelist))
+       i = match_string(whitelist, ARRAY_SIZE(whitelist), con_id);
+       if (i < 0)
                return ERR_PTR(-ENOENT);
 
        desc = of_get_named_gpiod_flags(np, con_id, 0, of_flags);