Skip to contentSkip to conversation

ppc: use the common ascii hex helpers

PATCH NAK Harvey Harrison 1 participant 1 message May 12, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 12/12 ppc: use the common ascii hex helpers

---
 arch/powerpc/kernel/btext.c     |   34 ++++++++++++++----------------
 arch/powerpc/kernel/prom_init.c |    3 +-
 arch/ppc/kernel/ppc-stub.c      |   43 ++++++++++++--------------------------
 arch/ppc/syslib/btext.c         |   18 +++++++---------
 arch/ppc/xmon/start_8xx.c       |    2 +-
 5 files changed, 40 insertions(+), 60 deletions(-)
arch/powerpc/kernel/btext.c +16 -18
index d8f0329..26e5863 100644
@@ -442,28 +442,26 @@ void btext_drawtext(const char *c, unsigned int len)
 
 void btext_drawhex(unsigned long v)
 {
-	char *hex_table = "0123456789abcdef";
-
 	if (!boot_text_mapped)
 		return;
 #ifdef CONFIG_PPC64
-	btext_drawchar(hex_table[(v >> 60) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 56) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 52) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 48) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 44) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 40) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 36) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 32) & 0x0000000FUL]);
+	btext_drawchar(hex_asc_hi(v >> 56));
+	btext_drawchar(hex_asc_lo(v >> 56));
+	btext_drawchar(hex_asc_hi(v >> 48));
+	btext_drawchar(hex_asc_lo(v >> 48));
+	btext_drawchar(hex_asc_hi(v >> 40));
+	btext_drawchar(hex_asc_lo(v >> 40));
+	btext_drawchar(hex_asc_hi(v >> 32));
+	btext_drawchar(hex_asc_lo(v >> 32));
 #endif
-	btext_drawchar(hex_table[(v >> 28) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 24) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 20) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 16) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 12) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >>  8) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >>  4) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >>  0) & 0x0000000FUL]);
+	btext_drawchar(hex_asc_hi(v >> 24));
+	btext_drawchar(hex_asc_lo(v >> 24));
+	btext_drawchar(hex_asc_hi(v >> 16));
+	btext_drawchar(hex_asc_lo(v >> 16));
+	btext_drawchar(hex_asc_hi(v >> 8));
+	btext_drawchar(hex_asc_lo(v >> 8));
+	btext_drawchar(hex_asc_hi(v));
+	btext_drawchar(hex_asc_lo(v));
 	btext_drawchar(' ');
 }
 
arch/powerpc/kernel/prom_init.c +1 -2
index 6d6df1e..c5aa96e 100644
@@ -453,7 +453,6 @@ static void add_string(char **str, const char *q)
 
 static char *tohex(unsigned int x)
 {
-	static char digits[] = "0123456789abcdef";
 	static char result[9];
 	int i;
 
@@ -461,7 +460,7 @@ static char *tohex(unsigned int x)
 	i = 8;
 	do {
 		--i;
-		result[i] = digits[x & 0xf];
+		result[i] = hex_asc_lo(x);
 		x >>= 4;
 	} while (x != 0 && i > 0);
 	return &result[i];
arch/ppc/kernel/ppc-stub.c +14 -29

82 lines not on this page · raw message

arch/ppc/syslib/btext.c +8 -10
index d116670..f1af035 100644
@@ -391,18 +391,16 @@ btext_drawstring(const char *c)
 void BTEXT
 btext_drawhex(unsigned long v)
 {
-	static char hex_table[] = "0123456789abcdef";
-
 	if (!boot_text_mapped)
 		return;
-	btext_drawchar(hex_table[(v >> 28) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 24) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 20) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 16) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >> 12) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >>  8) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >>  4) & 0x0000000FUL]);
-	btext_drawchar(hex_table[(v >>  0) & 0x0000000FUL]);
+	btext_drawchar(hex_asc_hi(v >> 24));
+	btext_drawchar(hex_asc_lo(v >> 24));
+	btext_drawchar(hex_asc_hi(v >> 16));
+	btext_drawchar(hex_asc_lo(v >> 16));
+	btext_drawchar(hex_asc_hi(v >> 8));
+	btext_drawchar(hex_asc_lo(v >> 8));
+	btext_drawchar(hex_asc_hi(v));
+	btext_drawchar(hex_asc_lo(v));
 	btext_drawchar(' ');
 }
 
arch/ppc/xmon/start_8xx.c +1 -1
index 3097406..207fd5c 100644
@@ -273,7 +273,7 @@ prom_drawhex(uint val)
 	int i;
 	for (i = 7;  i >= 0;  i--)
 	{
-		buf[i] = "0123456789abcdef"[val & 0x0f];
+		buf[i] = hex_asc_lo(val);
 		val >>= 4;
 	}
 	buf[8] = '\0';
Signature · 1 line
1.5.5.1.404.g981f6