diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2017-04-07 14:26:27 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2017-04-07 14:26:27 +1000 |
commit | f8949d1e32658fc73b09732ac30ab1b29ef37b9c (patch) | |
tree | 022f2c4cf2c62319fb70249a3874018d712e9932 /lib | |
parent | 5f74f579f11453b350d29a9d48d1bd6444c7d60d (diff) | |
parent | cb2e3d461b26f07540e0b898e0125137def2b015 (diff) |
Merge remote-tracking branch 'usb/usb-next'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/string.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index b5c9a1168d3a..1c1fc9187b05 100644 --- a/lib/string.c +++ b/lib/string.c @@ -656,6 +656,32 @@ int match_string(const char * const *array, size_t n, const char *string) } EXPORT_SYMBOL(match_string); +/** + * __sysfs_match_string - matches given string in an array + * @array: array of strings + * @n: number of strings in the array or -1 for NULL terminated arrays + * @str: string to match with + * + * Returns index of @str in the @array or -EINVAL, just like match_string(). + * Uses sysfs_streq instead of strcmp for matching. + */ +int __sysfs_match_string(const char * const *array, size_t n, const char *str) +{ + const char *item; + int index; + + for (index = 0; index < n; index++) { + item = array[index]; + if (!item) + break; + if (sysfs_streq(item, str)) + return index; + } + + return -EINVAL; +} +EXPORT_SYMBOL(__sysfs_match_string); + #ifndef __HAVE_ARCH_MEMSET /** * memset - Fill a region of memory with the given value |