mn10300: remove redundant hex()
PATCH 1/1 mn10300: remove redundant hex()
replace rendundant hex() with kernel's hex_to_bin()
Signed-off-by Arjun Sreedharan <[email protected]>
--- arch/mn10300/kernel/gdb-stub.c | 61 ++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 38 deletions(-)
arch/mn10300/kernel/gdb-stub.c +23 -38
@@ -176,27 +176,12 @@ static struct gdbstub_bkpt gdbstub_bkpts[256];static void getpacket (char *buffer);static int putpacket (char *buffer);static int computeSignal (enum exception_code excep); -static int hex (unsigned char ch);static int hexToInt (char **ptr,int *intValue);static unsigned char *mem2hex (const void *mem,char *buf,int count,int may_fault);static const char *hex2mem (const char *buf,void *_mem,int count,int may_fault); -/* -* Convert ch from a hex digit to an int -*/ -static int hex (unsigned char ch) -{ -if (ch >='a' && ch <='f' ) -return ch -'a' +10 ; -if (ch >='0' && ch <='9' ) -return ch -'0' ; -if (ch >='A' && ch <='F' ) -return ch -'A' +10 ; -return -1 ; -} -#ifdef CONFIG_GDBSTUB_DEBUGGING void debug_to_serial (const char *p,int n)
@@ -283,12 +268,12 @@ static void getpacket(char *buffer) ret =gdbstub_io_rx_char (&ch,0 );if (ret <0 ) error = ret; - xmitcsum =hex (ch) <<4 ; + xmitcsum =hex_to_bin (ch) <<4 ; ret =gdbstub_io_rx_char (&ch,0 );if (ret <0 ) error = ret; - xmitcsum |=hex (ch); + xmitcsum |=hex_to_bin (ch);if (error) {if (error == -EIO )
@@ -391,7 +376,7 @@ static int hexToInt(char **ptr, int *intValue) *intValue =0 ;while (**ptr) { - hexValue =hex (**ptr); + hexValue =hex_to_bin (**ptr);if (hexValue <0 )break ;
@@ -857,8 +842,8 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) } ch;if ((u32 ) mem &1 && count >=1 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++);if (gdbstub_write_byte (ch.val, mem) !=0 )return 0 ; mem++;
@@ -866,10 +851,10 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }if ((u32 ) mem &3 && count >=2 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); - ch.b[1 ] =hex (*buf++) <<4 ; - ch.b[1 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++); + ch.b[1 ] =hex_to_bin (*buf++) <<4 ; + ch.b[1 ] |=hex_to_bin (*buf++);if (gdbstub_write_word (ch.val, mem) !=0 )return 0 ; mem +=2 ;
@@ -877,14 +862,14 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }while (count >=4 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); - ch.b[1 ] =hex (*buf++) <<4 ; - ch.b[1 ] |=hex (*buf++); - ch.b[2 ] =hex (*buf++) <<4 ; - ch.b[2 ] |=hex (*buf++); - ch.b[3 ] =hex (*buf++) <<4 ; - ch.b[3 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++); + ch.b[1 ] =hex_to_bin (*buf++) <<4 ; + ch.b[1 ] |=hex_to_bin (*buf++); + ch.b[2 ] =hex_to_bin (*buf++) <<4 ; + ch.b[2 ] |=hex_to_bin (*buf++); + ch.b[3 ] =hex_to_bin (*buf++) <<4 ; + ch.b[3 ] |=hex_to_bin (*buf++);if (gdbstub_write_dword (ch.val, mem) !=0 )return 0 ; mem +=4 ;
@@ -892,10 +877,10 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }if (count >=2 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); - ch.b[1 ] =hex (*buf++) <<4 ; - ch.b[1 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++); + ch.b[1 ] =hex_to_bin (*buf++) <<4 ; + ch.b[1 ] |=hex_to_bin (*buf++);if (gdbstub_write_word (ch.val, mem) !=0 )return 0 ; mem +=2 ;
@@ -903,8 +888,8 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }if (count >=1 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++);if (gdbstub_write_byte (ch.val, mem) !=0 )return 0 ; }
Signature · 1 line
1.7.11.7
Ping !!
Quoted 141 lines · Arjun Sreedharan
replace rendundant
hex()with kernel'shex_to_bin()Signed-off-by Arjun Sreedharan <[email protected]>--- arch/mn10300/kernel/gdb-stub.c | 61 ++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 38 deletions(-)arch/mn10300/kernel/gdb-stub.c +23
-39@@ -176,27 +176,12 @@ static struct gdbstub_bkpt gdbstub_bkpts[256];static void getpacket (char *buffer);static int putpacket (char *buffer);static int computeSignal (enum exception_code excep); -static int hex (unsigned char ch);static int hexToInt (char **ptr,int *intValue);static unsigned char *mem2hex (const void *mem,char *buf,int count,int may_fault);static const char *hex2mem (const char *buf,void *_mem,int count,int may_fault); -/* -* Convert ch from a hex digit to an int -*/ -static int hex (unsigned char ch) -{ -if (ch >='a' && ch <='f' ) -return ch -'a' +10 ; -if (ch >='0' && ch <='9' ) -return ch -'0' ; -if (ch >='A' && ch <='F' ) -return ch -'A' +10 ; -return -1 ; -} -#ifdef CONFIG_GDBSTUB_DEBUGGING void debug_to_serial (const char *p,int n)@@ -283,12 +268,12 @@ static void getpacket(char *buffer) ret =gdbstub_io_rx_char (&ch,0 );if (ret <0 ) error = ret; - xmitcsum =hex (ch) <<4 ; + xmitcsum =hex_to_bin (ch) <<4 ; ret =gdbstub_io_rx_char (&ch,0 );if (ret <0 ) error = ret; - xmitcsum |=hex (ch); + xmitcsum |=hex_to_bin (ch);if (error) {if (error == -EIO )@@ -391,7 +376,7 @@ static int hexToInt(char **ptr, int *intValue) *intValue =0 ;while (**ptr) { - hexValue =hex (**ptr); + hexValue =hex_to_bin (**ptr);if (hexValue <0 )break ;@@ -857,8 +842,8 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) } ch;if ((u32 ) mem &1 && count >=1 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++);if (gdbstub_write_byte (ch.val, mem) !=0 )return 0 ; mem++;@@ -866,10 +851,10 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }if ((u32 ) mem &3 && count >=2 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); - ch.b[1 ] =hex (*buf++) <<4 ; - ch.b[1 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++); + ch.b[1 ] =hex_to_bin (*buf++) <<4 ; + ch.b[1 ] |=hex_to_bin (*buf++);if (gdbstub_write_word (ch.val, mem) !=0 )return 0 ; mem +=2 ;@@ -877,14 +862,14 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }while (count >=4 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); - ch.b[1 ] =hex (*buf++) <<4 ; - ch.b[1 ] |=hex (*buf++); - ch.b[2 ] =hex (*buf++) <<4 ; - ch.b[2 ] |=hex (*buf++); - ch.b[3 ] =hex (*buf++) <<4 ; - ch.b[3 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++); + ch.b[1 ] =hex_to_bin (*buf++) <<4 ; + ch.b[1 ] |=hex_to_bin (*buf++); + ch.b[2 ] =hex_to_bin (*buf++) <<4 ; + ch.b[2 ] |=hex_to_bin (*buf++); + ch.b[3 ] =hex_to_bin (*buf++) <<4 ; + ch.b[3 ] |=hex_to_bin (*buf++);if (gdbstub_write_dword (ch.val, mem) !=0 )return 0 ; mem +=4 ;@@ -892,10 +877,10 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }if (count >=2 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); - ch.b[1 ] =hex (*buf++) <<4 ; - ch.b[1 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++); + ch.b[1 ] =hex_to_bin (*buf++) <<4 ; + ch.b[1 ] |=hex_to_bin (*buf++);if (gdbstub_write_word (ch.val, mem) !=0 )return 0 ; mem +=2 ;@@ -903,8 +888,8 @@ const char *hex2mem(const char *buf, void *_mem, int count, int may_fault) }if (count >=1 ) { - ch.b[0 ] =hex (*buf++) <<4 ; - ch.b[0 ] |=hex (*buf++); + ch.b[0 ] =hex_to_bin (*buf++) <<4 ; + ch.b[0 ] |=hex_to_bin (*buf++);if (gdbstub_write_byte (ch.val, mem) !=0 )return 0 ; } --1.7.11.7
Arjun,
Quoted 1 line · Arjun Sreedharan
Ping !!
I wouldn't hold my breath waiting for any response, if I were you.
Quoted 7 lines · Arjun Sreedharan
Quoted 6 lines
replace rendundant
hex()with kernel'shex_to_bin()Signed-off-by Arjun Sreedharan <[email protected]>--- arch/mn10300/kernel/gdb-stub.c | 61 ++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 38 deletions(-)
You can't actually build a mn10300 kernel with GDBSTUB set since v2.6.39, see https://lkml.org/lkml/2014/9/18/387 . Perhaps you still managed to build arch/mn10300/kernel/gdb-stub.o manually, bypassing kconfig. Or did you just edit out its dependency on DEPRECATED?
Paul Bolle