diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2011-07-25 20:13:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-25 23:57:16 -0400 |
commit | 75fb8f269305fc066c4c6ec6e7232df0c92f434d (patch) | |
tree | be2f806f817368cb52270baee3f1d77005e3ca8a /lib | |
parent | 72d39508e43689b9346dfc956fad5e94a8911886 (diff) |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kstrtox.c | 5 | ||||
-rw-r--r-- | lib/vsprintf.c | 23 |
2 files changed, 10 insertions, 18 deletions
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index 2dbae88090ac..5e066759f551 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
@@ -19,11 +19,6 @@ | |||
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
21 | 21 | ||
22 | static inline char _tolower(const char c) | ||
23 | { | ||
24 | return c | 0x20; | ||
25 | } | ||
26 | |||
27 | static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | 22 | static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) |
28 | { | 23 | { |
29 | unsigned long long acc; | 24 | unsigned long long acc; |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 4365df31a1d5..39e3e8f1d4ec 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -31,13 +31,10 @@ | |||
31 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ | 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 | static unsigned int simple_guess_base(const char *cp) | 34 | static unsigned int simple_guess_base(const char *cp) |
38 | { | 35 | { |
39 | if (cp[0] == '0') { | 36 | if (cp[0] == '0') { |
40 | if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) | 37 | if (_tolower(cp[1]) == 'x' && isxdigit(cp[2])) |
41 | return 16; | 38 | return 16; |
42 | else | 39 | else |
43 | return 8; | 40 | return 8; |
@@ -59,13 +56,13 @@ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int bas | |||
59 | if (!base) | 56 | if (!base) |
60 | base = simple_guess_base(cp); | 57 | base = simple_guess_base(cp); |
61 | 58 | ||
62 | if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') | 59 | if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x') |
63 | cp += 2; | 60 | cp += 2; |
64 | 61 | ||
65 | while (isxdigit(*cp)) { | 62 | while (isxdigit(*cp)) { |
66 | unsigned int value; | 63 | unsigned int value; |
67 | 64 | ||
68 | value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; | 65 | value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10; |
69 | if (value >= base) | 66 | if (value >= base) |
70 | break; | 67 | break; |
71 | result = result * base + value; | 68 | result = result * base + value; |
@@ -1036,8 +1033,8 @@ precision: | |||
1036 | qualifier: | 1033 | qualifier: |
1037 | /* get the conversion qualifier */ | 1034 | /* get the conversion qualifier */ |
1038 | spec->qualifier = -1; | 1035 | spec->qualifier = -1; |
1039 | if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || | 1036 | if (*fmt == 'h' || _tolower(*fmt) == 'l' || |
1040 | TOLOWER(*fmt) == 'z' || *fmt == 't') { | 1037 | _tolower(*fmt) == 'z' || *fmt == 't') { |
1041 | spec->qualifier = *fmt++; | 1038 | spec->qualifier = *fmt++; |
1042 | if (unlikely(spec->qualifier == *fmt)) { | 1039 | if (unlikely(spec->qualifier == *fmt)) { |
1043 | if (spec->qualifier == 'l') { | 1040 | if (spec->qualifier == 'l') { |
@@ -1104,7 +1101,7 @@ qualifier: | |||
1104 | spec->type = FORMAT_TYPE_LONG; | 1101 | spec->type = FORMAT_TYPE_LONG; |
1105 | else | 1102 | else |
1106 | spec->type = FORMAT_TYPE_ULONG; | 1103 | spec->type = FORMAT_TYPE_ULONG; |
1107 | } else if (TOLOWER(spec->qualifier) == 'z') { | 1104 | } else if (_tolower(spec->qualifier) == 'z') { |
1108 | spec->type = FORMAT_TYPE_SIZE_T; | 1105 | spec->type = FORMAT_TYPE_SIZE_T; |
1109 | } else if (spec->qualifier == 't') { | 1106 | } else if (spec->qualifier == 't') { |
1110 | spec->type = FORMAT_TYPE_PTRDIFF; | 1107 | spec->type = FORMAT_TYPE_PTRDIFF; |
@@ -1263,7 +1260,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
1263 | if (qualifier == 'l') { | 1260 | if (qualifier == 'l') { |
1264 | long *ip = va_arg(args, long *); | 1261 | long *ip = va_arg(args, long *); |
1265 | *ip = (str - buf); | 1262 | *ip = (str - buf); |
1266 | } else if (TOLOWER(qualifier) == 'z') { | 1263 | } else if (_tolower(qualifier) == 'z') { |
1267 | size_t *ip = va_arg(args, size_t *); | 1264 | size_t *ip = va_arg(args, size_t *); |
1268 | *ip = (str - buf); | 1265 | *ip = (str - buf); |
1269 | } else { | 1266 | } else { |
@@ -1550,7 +1547,7 @@ do { \ | |||
1550 | void *skip_arg; | 1547 | void *skip_arg; |
1551 | if (qualifier == 'l') | 1548 | if (qualifier == 'l') |
1552 | skip_arg = va_arg(args, long *); | 1549 | skip_arg = va_arg(args, long *); |
1553 | else if (TOLOWER(qualifier) == 'z') | 1550 | else if (_tolower(qualifier) == 'z') |
1554 | skip_arg = va_arg(args, size_t *); | 1551 | skip_arg = va_arg(args, size_t *); |
1555 | else | 1552 | else |
1556 | skip_arg = va_arg(args, int *); | 1553 | skip_arg = va_arg(args, int *); |
@@ -1856,8 +1853,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args) | |||
1856 | 1853 | ||
1857 | /* get conversion qualifier */ | 1854 | /* get conversion qualifier */ |
1858 | qualifier = -1; | 1855 | qualifier = -1; |
1859 | if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || | 1856 | if (*fmt == 'h' || _tolower(*fmt) == 'l' || |
1860 | TOLOWER(*fmt) == 'z') { | 1857 | _tolower(*fmt) == 'z') { |
1861 | qualifier = *fmt++; | 1858 | qualifier = *fmt++; |
1862 | if (unlikely(qualifier == *fmt)) { | 1859 | if (unlikely(qualifier == *fmt)) { |
1863 | if (qualifier == 'h') { | 1860 | if (qualifier == 'h') { |