diff options
| author | Vadim Pasternak <vadimp@mellanox.com> | 2020-07-14 15:01:53 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-05-30 12:42:13 +0100 |
| commit | d18c6c5391a4760e5d4820c4530c2bb507d82650 (patch) | |
| tree | 6171707603fc1c04bbb5c99f65a769d11296078c /include/linux | |
| parent | d93213962c2683d13f510cb32cd93d792ea23d0e (diff) | |
lib/string_helpers: Introduce string_upper() and string_lower() helpers
[ Upstream commit 58eeba0bdb52afe5c18ce2a760ca9fe2901943e9 ]
Provide the helpers for string conversions to upper and lower cases.
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Stable-dep-of: 3c0f4f09c063 ("usb: gadget: u_ether: Fix host MAC address case")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/string_helpers.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index d23c5030901a..0618885b3edc 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -2,6 +2,7 @@ #ifndef _LINUX_STRING_HELPERS_H_ #define _LINUX_STRING_HELPERS_H_ +#include <linux/ctype.h> #include <linux/types.h> struct file; @@ -72,6 +73,20 @@ static inline int string_escape_str_any_np(const char *src, char *dst, return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only); } +static inline void string_upper(char *dst, const char *src) +{ + do { + *dst++ = toupper(*src); + } while (*src++); +} + +static inline void string_lower(char *dst, const char *src) +{ + do { + *dst++ = tolower(*src); + } while (*src++); +} + char *kstrdup_quotable(const char *src, gfp_t gfp); char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp); char *kstrdup_quotable_file(struct file *file, gfp_t gfp); |
