From 3fc957721d18c93662f7d4dab455b80f53dd2641 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 14 May 2008 16:05:49 -0700 Subject: lib: create common ascii hex array Add a common hex array in hexdump.c so everyone can use it. Add a common hi/lo helper to avoid the shifting masking that is done to get the upper and lower nibbles of a byte value. Pull the pack_hex_byte helper from kgdb as it is opencoded many places in the tree that will be consolidated. Signed-off-by: Harvey Harrison Acked-by: Paul Mundt Cc: Jason Wessel Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/sh/kernel/kgdb_stub.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'arch/sh/kernel/kgdb_stub.c') diff --git a/arch/sh/kernel/kgdb_stub.c b/arch/sh/kernel/kgdb_stub.c index d453c3a1c79f..832641bbd47d 100644 --- a/arch/sh/kernel/kgdb_stub.c +++ b/arch/sh/kernel/kgdb_stub.c @@ -330,14 +330,6 @@ static char *ebin_to_mem(const char *buf, char *mem, int count) return mem; } -/* Pack a hex byte */ -static char *pack_hex_byte(char *pkt, int byte) -{ - *pkt++ = hexchars[(byte >> 4) & 0xf]; - *pkt++ = hexchars[(byte & 0xf)]; - return pkt; -} - /* Scan for the start char '$', read the packet and check the checksum */ static void get_packet(char *buffer, int buflen) { -- cgit v1.2.3 From bfd3c7a728fbe642f79f99482a6c01158c675545 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 12 May 2008 12:05:43 -0700 Subject: sh: use the common ascii hex helpers Signed-off-by: Harvey Harrison Signed-off-by: Paul Mundt --- arch/sh/kernel/kgdb_stub.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'arch/sh/kernel/kgdb_stub.c') diff --git a/arch/sh/kernel/kgdb_stub.c b/arch/sh/kernel/kgdb_stub.c index 832641bbd47d..bf8ac4c71640 100644 --- a/arch/sh/kernel/kgdb_stub.c +++ b/arch/sh/kernel/kgdb_stub.c @@ -274,8 +274,7 @@ static char *mem_to_hex(const char *mem, char *buf, const int count) } for (i = 0; i < count; i++) { ch = *mem++; - *buf++ = highhex(ch); - *buf++ = lowhex(ch); + buf = pack_hex_byte(buf, ch); } *buf = 0; return (buf); @@ -427,8 +426,8 @@ static void put_packet(char *buffer) /* '#' Separator, put high and low components of checksum */ put_debug_char('#'); - put_debug_char(highhex(checksum)); - put_debug_char(lowhex(checksum)); + put_debug_char(hex_asc_hi(checksum)); + put_debug_char(hex_asc_lo(checksum)); } while ((get_debug_char()) != '+'); /* While no ack */ } @@ -650,8 +649,8 @@ static void undo_single_step(void) static void send_signal_msg(const int signum) { out_buffer[0] = 'S'; - out_buffer[1] = highhex(signum); - out_buffer[2] = lowhex(signum); + out_buffer[1] = hex_asc_hi(signum); + out_buffer[2] = hex_asc_lo(signum); out_buffer[3] = 0; put_packet(out_buffer); } -- cgit v1.2.3