device property: convert to use match_string() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 17 Mar 2016 21:22:17 +0000 (14:22 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 17 Mar 2016 22:09:34 +0000 (15:09 -0700)
The new helper returns index of the mathing string in an array.  We
would use it here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/base/property.c

index 76628a7b45f1efb81fb43cc9ec63d85885883692..9b1a65debd49e645d41343eac7d54a4369ddc2fd 100644 (file)
@@ -651,7 +651,7 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
        const char *propname, const char *string)
 {
        const char **values;
-       int nval, ret, i;
+       int nval, ret;
 
        nval = fwnode_property_read_string_array(fwnode, propname, NULL, 0);
        if (nval < 0)
@@ -668,13 +668,9 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
        if (ret < 0)
                goto out;
 
-       ret = -ENODATA;
-       for (i = 0; i < nval; i++) {
-               if (!strcmp(values[i], string)) {
-                       ret = i;
-                       break;
-               }
-       }
+       ret = match_string(values, nval, string);
+       if (ret < 0)
+               ret = -ENODATA;
 out:
        kfree(values);
        return ret;