Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib: make _tolower() public

This function is required by *printf and kstrto* functions that are
located in the different modules. This patch makes _tolower() public.
However, it's good idea to not use the helper outside of mentioned
functions.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Linus Torvalds
75fb8f26 72d39508

+19 -18
+9
include/linux/ctype.h
··· 52 52 #define tolower(c) __tolower(c) 53 53 #define toupper(c) __toupper(c) 54 54 55 + /* 56 + * Fast implementation of tolower() for internal usage. Do not use in your 57 + * code. 58 + */ 59 + static inline char _tolower(const char c) 60 + { 61 + return c | 0x20; 62 + } 63 + 55 64 #endif
-5
lib/kstrtox.c
··· 19 19 #include <linux/types.h> 20 20 #include <asm/uaccess.h> 21 21 22 - static inline char _tolower(const char c) 23 - { 24 - return c | 0x20; 25 - } 26 - 27 22 static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) 28 23 { 29 24 unsigned long long acc;
+10 -13
lib/vsprintf.c
··· 31 31 #include <asm/div64.h> 32 32 #include <asm/sections.h> /* for dereference_function_descriptor() */ 33 33 34 - /* Works only for digits and letters, but small and fast */ 35 - #define TOLOWER(x) ((x) | 0x20) 36 - 37 34 static unsigned int simple_guess_base(const char *cp) 38 35 { 39 36 if (cp[0] == '0') { 40 - if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) 37 + if (_tolower(cp[1]) == 'x' && isxdigit(cp[2])) 41 38 return 16; 42 39 else 43 40 return 8; ··· 56 59 if (!base) 57 60 base = simple_guess_base(cp); 58 61 59 - if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') 62 + if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x') 60 63 cp += 2; 61 64 62 65 while (isxdigit(*cp)) { 63 66 unsigned int value; 64 67 65 - value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; 68 + value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10; 66 69 if (value >= base) 67 70 break; 68 71 result = result * base + value; ··· 1033 1036 qualifier: 1034 1037 /* get the conversion qualifier */ 1035 1038 spec->qualifier = -1; 1036 - if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || 1037 - TOLOWER(*fmt) == 'z' || *fmt == 't') { 1039 + if (*fmt == 'h' || _tolower(*fmt) == 'l' || 1040 + _tolower(*fmt) == 'z' || *fmt == 't') { 1038 1041 spec->qualifier = *fmt++; 1039 1042 if (unlikely(spec->qualifier == *fmt)) { 1040 1043 if (spec->qualifier == 'l') { ··· 1101 1104 spec->type = FORMAT_TYPE_LONG; 1102 1105 else 1103 1106 spec->type = FORMAT_TYPE_ULONG; 1104 - } else if (TOLOWER(spec->qualifier) == 'z') { 1107 + } else if (_tolower(spec->qualifier) == 'z') { 1105 1108 spec->type = FORMAT_TYPE_SIZE_T; 1106 1109 } else if (spec->qualifier == 't') { 1107 1110 spec->type = FORMAT_TYPE_PTRDIFF; ··· 1260 1263 if (qualifier == 'l') { 1261 1264 long *ip = va_arg(args, long *); 1262 1265 *ip = (str - buf); 1263 - } else if (TOLOWER(qualifier) == 'z') { 1266 + } else if (_tolower(qualifier) == 'z') { 1264 1267 size_t *ip = va_arg(args, size_t *); 1265 1268 *ip = (str - buf); 1266 1269 } else { ··· 1547 1550 void *skip_arg; 1548 1551 if (qualifier == 'l') 1549 1552 skip_arg = va_arg(args, long *); 1550 - else if (TOLOWER(qualifier) == 'z') 1553 + else if (_tolower(qualifier) == 'z') 1551 1554 skip_arg = va_arg(args, size_t *); 1552 1555 else 1553 1556 skip_arg = va_arg(args, int *); ··· 1853 1856 1854 1857 /* get conversion qualifier */ 1855 1858 qualifier = -1; 1856 - if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || 1857 - TOLOWER(*fmt) == 'z') { 1859 + if (*fmt == 'h' || _tolower(*fmt) == 'l' || 1860 + _tolower(*fmt) == 'z') { 1858 1861 qualifier = *fmt++; 1859 1862 if (unlikely(qualifier == *fmt)) { 1860 1863 if (qualifier == 'h') {