Commit 75fb8f26 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 72d39508
...@@ -52,4 +52,13 @@ static inline unsigned char __toupper(unsigned char c) ...@@ -52,4 +52,13 @@ static inline unsigned char __toupper(unsigned char c)
#define tolower(c) __tolower(c) #define tolower(c) __tolower(c)
#define toupper(c) __toupper(c) #define toupper(c) __toupper(c)
/*
* Fast implementation of tolower() for internal usage. Do not use in your
* code.
*/
static inline char _tolower(const char c)
{
return c | 0x20;
}
#endif #endif
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
static inline char _tolower(const char c)
{
return c | 0x20;
}
static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
{ {
unsigned long long acc; unsigned long long acc;
......
...@@ -31,13 +31,10 @@ ...@@ -31,13 +31,10 @@
#include <asm/div64.h> #include <asm/div64.h>
#include <asm/sections.h> /* for dereference_function_descriptor() */ #include <asm/sections.h> /* for dereference_function_descriptor() */
/* Works only for digits and letters, but small and fast */
#define TOLOWER(x) ((x) | 0x20)
static unsigned int simple_guess_base(const char *cp) static unsigned int simple_guess_base(const char *cp)
{ {
if (cp[0] == '0') { if (cp[0] == '0') {
if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) if (_tolower(cp[1]) == 'x' && isxdigit(cp[2]))
return 16; return 16;
else else
return 8; return 8;
...@@ -59,13 +56,13 @@ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int bas ...@@ -59,13 +56,13 @@ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int bas
if (!base) if (!base)
base = simple_guess_base(cp); base = simple_guess_base(cp);
if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x')
cp += 2; cp += 2;
while (isxdigit(*cp)) { while (isxdigit(*cp)) {
unsigned int value; unsigned int value;
value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10;
if (value >= base) if (value >= base)
break; break;
result = result * base + value; result = result * base + value;
...@@ -1036,8 +1033,8 @@ int format_decode(const char *fmt, struct printf_spec *spec) ...@@ -1036,8 +1033,8 @@ int format_decode(const char *fmt, struct printf_spec *spec)
qualifier: qualifier:
/* get the conversion qualifier */ /* get the conversion qualifier */
spec->qualifier = -1; spec->qualifier = -1;
if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || if (*fmt == 'h' || _tolower(*fmt) == 'l' ||
TOLOWER(*fmt) == 'z' || *fmt == 't') { _tolower(*fmt) == 'z' || *fmt == 't') {
spec->qualifier = *fmt++; spec->qualifier = *fmt++;
if (unlikely(spec->qualifier == *fmt)) { if (unlikely(spec->qualifier == *fmt)) {
if (spec->qualifier == 'l') { if (spec->qualifier == 'l') {
...@@ -1104,7 +1101,7 @@ int format_decode(const char *fmt, struct printf_spec *spec) ...@@ -1104,7 +1101,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)
spec->type = FORMAT_TYPE_LONG; spec->type = FORMAT_TYPE_LONG;
else else
spec->type = FORMAT_TYPE_ULONG; spec->type = FORMAT_TYPE_ULONG;
} else if (TOLOWER(spec->qualifier) == 'z') { } else if (_tolower(spec->qualifier) == 'z') {
spec->type = FORMAT_TYPE_SIZE_T; spec->type = FORMAT_TYPE_SIZE_T;
} else if (spec->qualifier == 't') { } else if (spec->qualifier == 't') {
spec->type = FORMAT_TYPE_PTRDIFF; spec->type = FORMAT_TYPE_PTRDIFF;
...@@ -1263,7 +1260,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ...@@ -1263,7 +1260,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
if (qualifier == 'l') { if (qualifier == 'l') {
long *ip = va_arg(args, long *); long *ip = va_arg(args, long *);
*ip = (str - buf); *ip = (str - buf);
} else if (TOLOWER(qualifier) == 'z') { } else if (_tolower(qualifier) == 'z') {
size_t *ip = va_arg(args, size_t *); size_t *ip = va_arg(args, size_t *);
*ip = (str - buf); *ip = (str - buf);
} else { } else {
...@@ -1550,7 +1547,7 @@ do { \ ...@@ -1550,7 +1547,7 @@ do { \
void *skip_arg; void *skip_arg;
if (qualifier == 'l') if (qualifier == 'l')
skip_arg = va_arg(args, long *); skip_arg = va_arg(args, long *);
else if (TOLOWER(qualifier) == 'z') else if (_tolower(qualifier) == 'z')
skip_arg = va_arg(args, size_t *); skip_arg = va_arg(args, size_t *);
else else
skip_arg = va_arg(args, int *); skip_arg = va_arg(args, int *);
...@@ -1856,8 +1853,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args) ...@@ -1856,8 +1853,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
/* get conversion qualifier */ /* get conversion qualifier */
qualifier = -1; qualifier = -1;
if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || if (*fmt == 'h' || _tolower(*fmt) == 'l' ||
TOLOWER(*fmt) == 'z') { _tolower(*fmt) == 'z') {
qualifier = *fmt++; qualifier = *fmt++;
if (unlikely(qualifier == *fmt)) { if (unlikely(qualifier == *fmt)) {
if (qualifier == 'h') { if (qualifier == 'h') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment