This change re-introduces `match_string()` as a macro that uses ARRAY_SIZE() to compute the size of the array.
After this change, work can start on migrating subsystems to use this new helper. Since the original helper is pretty used, migrating to this new one will take a while, and will be reviewed by each subsystem.
Signed-off-by: Alexandru Ardelean alexandru.ardelean@analog.com --- include/linux/string.h | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/include/linux/string.h b/include/linux/string.h index 7149fcdf62df..34491b075449 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -198,6 +198,15 @@ static inline int strtobool(const char *s, bool *res) int __match_string(const char * const *array, size_t n, const char *string); int __sysfs_match_string(const char * const *array, size_t n, const char *s);
+/** + * match_string - matches given string in an array + * @_a: array of strings + * @_s: string to match with + * + * Helper for __match_string(). Calculates the size of @a automatically. + */ +#define match_string(_a, _s) __match_string(_a, ARRAY_SIZE(_a), _s) + /** * sysfs_match_string - matches given string in an array * @_a: array of strings