aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/property.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2016-03-17 14:22:17 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 15:09:34 -0700
commita7c1d0a987ee3be0b87db5c95aa4fbadf7c3c1c2 (patch)
treef06cf8ee8b6a4e565c02f150187b69d171e604eb /drivers/base/property.c
parentlib/string: introduce match_string() helper (diff)
downloadlinux-dev-a7c1d0a987ee3be0b87db5c95aa4fbadf7c3c1c2.tar.xz
linux-dev-a7c1d0a987ee3be0b87db5c95aa4fbadf7c3c1c2.zip
device property: convert to use match_string() helper
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>
Diffstat (limited to 'drivers/base/property.c')
-rw-r--r--drivers/base/property.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 76628a7b45f1..9b1a65debd49 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -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;