public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] lib: make TOLOWER macro public
@ 2011-07-18  8:23 Andy Shevchenko
  2011-07-18  8:23 ` [PATCH 2/2] lib: call native hex_to_bin() inside _kstrtoull() Andy Shevchenko
  2011-07-18 10:25 ` [PATCH 1/2] lib: make TOLOWER macro public Alexey Dobriyan
  0 siblings, 2 replies; 11+ messages in thread
From: Andy Shevchenko @ 2011-07-18  8:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, Andrew Morton, Alexey Dobriyan

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
---
 include/linux/kernel.h |    3 +++
 lib/kstrtox.c          |   13 ++++---------
 lib/vsprintf.c         |    3 ---
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 567a6f7..8c29d3a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -188,6 +188,9 @@ NORET_TYPE void do_exit(long error_code)
 NORET_TYPE void complete_and_exit(struct completion *, long)
 	ATTRIB_NORET;
 
+/* Works only for digits and letters, but small and fast */
+#define TOLOWER(x) ((x) | 0x20)
+
 /* Internal, do not use. */
 int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
 int __must_check _kstrtol(const char *s, unsigned int base, long *res);
diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index 2dbae88..5099755 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -19,11 +19,6 @@
 #include <linux/types.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)
 {
 	unsigned long long acc;
@@ -31,14 +26,14 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
 
 	if (base == 0) {
 		if (s[0] == '0') {
-			if (_tolower(s[1]) == 'x' && isxdigit(s[2]))
+			if (TOLOWER(s[1]) == 'x' && isxdigit(s[2]))
 				base = 16;
 			else
 				base = 8;
 		} else
 			base = 10;
 	}
-	if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
+	if (base == 16 && s[0] == '0' && TOLOWER(s[1]) == 'x')
 		s += 2;
 
 	acc = 0;
@@ -48,8 +43,8 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
 
 		if ('0' <= *s && *s <= '9')
 			val = *s - '0';
-		else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f')
-			val = _tolower(*s) - 'a' + 10;
+		else if ('a' <= TOLOWER(*s) && TOLOWER(*s) <= 'f')
+			val = TOLOWER(*s) - 'a' + 10;
 		else if (*s == '\n' && *(s + 1) == '\0')
 			break;
 		else
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 75bace7..29a0fe0 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -31,9 +31,6 @@
 #include <asm/div64.h>
 #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)
 {
 	if (cp[0] == '0') {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-07-19  7:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-18  8:23 [PATCH 1/2] lib: make TOLOWER macro public Andy Shevchenko
2011-07-18  8:23 ` [PATCH 2/2] lib: call native hex_to_bin() inside _kstrtoull() Andy Shevchenko
2011-07-18 10:31   ` Alexey Dobriyan
2011-07-18 10:39     ` Andy Shevchenko
2011-07-18 12:57     ` [PATCHv2 1/2] lib: make _tolower() public Andy Shevchenko
2011-07-18 12:57       ` [PATCHv2 2/2] lib: kstrtox: add performance test case Andy Shevchenko
2011-07-18 20:52       ` [PATCHv2 1/2] lib: make _tolower() public Alexey Dobriyan
2011-07-19  7:17         ` [PATCHv2.1] " Andy Shevchenko
2011-07-18 19:05     ` [PATCH 2/2] lib: call native hex_to_bin() inside _kstrtoull() Andy Shevchenko
2011-07-18 10:25 ` [PATCH 1/2] lib: make TOLOWER macro public Alexey Dobriyan
2011-07-18 10:36   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox