* [PATCH] cris: kgdb: use native hex2bin
@ 2013-06-04 8:51 Andy Shevchenko
2013-06-04 9:33 ` Andy Shevchenko
2015-09-30 14:46 ` Andy Shevchenko
0 siblings, 2 replies; 10+ messages in thread
From: Andy Shevchenko @ 2013-06-04 8:51 UTC (permalink / raw)
To: Mikael Starvik, Jesper Nilsson, linux-cris-kernel, linux-kernel
Cc: Andy Shevchenko, Geert Uytterhoeven
There are kernel native helpers to convert hex ascii to the binary format:
hex_to_bin() and hex2bin(). Thus, no need to reimplement them customly.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
arch/cris/arch-v10/kernel/kgdb.c | 36 +++----------------------
arch/cris/arch-v32/kernel/kgdb.c | 57 +++++++---------------------------------
2 files changed, 14 insertions(+), 79 deletions(-)
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index 22d846b..dbd4ba8 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -413,18 +413,6 @@ gdb_cris_strtol (const char *s, char **endptr, int base)
}
/********************************** Packet I/O ******************************/
-/* Returns the integer equivalent of a hexadecimal character. */
-static int
-hex (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);
-}
/* Convert the memory, pointed to by mem into hexadecimal representation.
Put the result in buf, and return a pointer to the last character
@@ -455,22 +443,6 @@ mem2hex(char *buf, unsigned char *mem, int count)
return (buf);
}
-/* Convert the array, in hexadecimal representation, pointed to by buf into
- binary representation. Put the result in mem, and return a pointer to
- the character after the last byte written. */
-static unsigned char*
-hex2mem (unsigned char *mem, char *buf, int count)
-{
- int i;
- unsigned char ch;
- for (i = 0; i < count; i++) {
- ch = hex (*buf++) << 4;
- ch = ch + hex (*buf++);
- *mem++ = ch;
- }
- return (mem);
-}
-
/* Put the content of the array, in binary representation, pointed to by buf
into memory pointed to by mem, and return a pointer to the character after
the last byte written.
@@ -524,8 +496,8 @@ getpacket (char *buffer)
buffer[count] = '\0';
if (ch == '#') {
- xmitcsum = hex (getDebugChar ()) << 4;
- xmitcsum += hex (getDebugChar ());
+ xmitcsum = hex_to_bin(getDebugChar()) << 4;
+ xmitcsum += hex_to_bin(getDebugChar());
if (checksum != xmitcsum) {
/* Wrong checksum */
putDebugChar ('-');
@@ -760,7 +732,7 @@ handle_exception (int sigval)
Each byte of register data is described by two hex digits.
Success: OK
Failure: void. */
- hex2mem((char *)&cris_reg, &remcomInBuffer[1], sizeof(registers));
+ hex2bin((char *)&cris_reg, &remcomInBuffer[1], sizeof(registers));
gdb_cris_strcpy (remcomOutBuffer, "OK");
break;
@@ -835,7 +807,7 @@ handle_exception (int sigval)
int length = gdb_cris_strtol(lenptr+1, &dataptr, 16);
if (*lenptr == ',' && *dataptr == ':') {
if (remcomInBuffer[0] == 'M') {
- hex2mem(addr, dataptr + 1, length);
+ hex2bin(addr, dataptr + 1, length);
}
else /* X */ {
bin2mem(addr, dataptr + 1, length);
diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch-v32/kernel/kgdb.c
index b06813a..590c11b 100644
--- a/arch/cris/arch-v32/kernel/kgdb.c
+++ b/arch/cris/arch-v32/kernel/kgdb.c
@@ -384,19 +384,11 @@ int getDebugChar(void);
/* Serial port, writes one character. ETRAX 100 specific. from debugport.c */
void putDebugChar(int val);
-/* Returns the integer equivalent of a hexadecimal character. */
-static int hex(char ch);
-
/* Convert the memory, pointed to by mem into hexadecimal representation.
Put the result in buf, and return a pointer to the last character
in buf (null). */
static char *mem2hex(char *buf, unsigned char *mem, int count);
-/* Convert the array, in hexadecimal representation, pointed to by buf into
- binary representation. Put the result in mem, and return a pointer to
- the character after the last byte written. */
-static unsigned char *hex2mem(unsigned char *mem, char *buf, int count);
-
/* Put the content of the array, in binary representation, pointed to by buf
into memory pointed to by mem, and return a pointer to
the character after the last byte written. */
@@ -547,7 +539,7 @@ write_register(int regno, char *val)
if (regno >= R0 && regno <= ACR) {
/* Consecutive 32-bit registers. */
- hex2mem((unsigned char *)®.r0 + (regno - R0) * sizeof(unsigned int),
+ hex2bin((unsigned char *)®.r0 + (regno - R0) * sizeof(unsigned int),
val, sizeof(unsigned int));
} else if (regno == BZ || regno == VR || regno == WZ || regno == DZ) {
@@ -557,15 +549,15 @@ write_register(int regno, char *val)
} else if (regno == PID) {
/* 32-bit register. (Even though we already checked SRS and WZ, we cannot
combine this with the EXS - SPC write since SRS and WZ have different size.) */
- hex2mem((unsigned char *)®.pid, val, sizeof(unsigned int));
+ hex2bin((unsigned char *)®.pid, val, sizeof(unsigned int));
} else if (regno == SRS) {
/* 8-bit register. */
- hex2mem((unsigned char *)®.srs, val, sizeof(unsigned char));
+ hex2bin((unsigned char *)®.srs, val, sizeof(unsigned char));
} else if (regno >= EXS && regno <= SPC) {
/* Consecutive 32-bit registers. */
- hex2mem((unsigned char *)®.exs + (regno - EXS) * sizeof(unsigned int),
+ hex2bin((unsigned char *)®.exs + (regno - EXS) * sizeof(unsigned int),
val, sizeof(unsigned int));
} else if (regno == PC) {
@@ -574,7 +566,7 @@ write_register(int regno, char *val)
} else if (regno >= S0 && regno <= S15) {
/* 32-bit registers. */
- hex2mem((unsigned char *)&sreg.s0_0 + (reg.srs * 16 * sizeof(unsigned int)) + (regno - S0) * sizeof(unsigned int), val, sizeof(unsigned int));
+ hex2bin((unsigned char *)&sreg.s0_0 + (reg.srs * 16 * sizeof(unsigned int)) + (regno - S0) * sizeof(unsigned int), val, sizeof(unsigned int));
} else {
/* Non-existing register. */
status = E05;
@@ -630,19 +622,6 @@ read_register(char regno, unsigned int *valptr)
}
/********************************** Packet I/O ******************************/
-/* Returns the integer equivalent of a hexadecimal character. */
-static int
-hex(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;
-}
-
/* Convert the memory, pointed to by mem into hexadecimal representation.
Put the result in buf, and return a pointer to the last character
in buf (null). */
@@ -689,22 +668,6 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count)
return buf;
}
-/* Convert the array, in hexadecimal representation, pointed to by buf into
- binary representation. Put the result in mem, and return a pointer to
- the character after the last byte written. */
-static unsigned char*
-hex2mem(unsigned char *mem, char *buf, int count)
-{
- int i;
- unsigned char ch;
- for (i = 0; i < count; i++) {
- ch = hex (*buf++) << 4;
- ch = ch + hex (*buf++);
- *mem++ = ch;
- }
- return mem;
-}
-
/* Put the content of the array, in binary representation, pointed to by buf
into memory pointed to by mem, and return a pointer to the character after
the last byte written.
@@ -763,8 +726,8 @@ getpacket(char *buffer)
buffer[count] = 0;
if (ch == '#') {
- xmitcsum = hex(getDebugChar()) << 4;
- xmitcsum += hex(getDebugChar());
+ xmitcsum = hex_to_bin(getDebugChar()) << 4;
+ xmitcsum += hex_to_bin(getDebugChar());
if (checksum != xmitcsum) {
/* Wrong checksum */
putDebugChar('-');
@@ -1306,9 +1269,9 @@ handle_exception(int sigval)
Success: OK
Failure: void. */
/* General and special registers. */
- hex2mem((char *)®, &input_buffer[1], sizeof(registers));
+ hex2bin((char *)®, &input_buffer[1], sizeof(registers));
/* Support registers. */
- hex2mem((char *)&sreg + (reg.srs * 16 * sizeof(unsigned int)),
+ hex2bin((char *)&sreg + (reg.srs * 16 * sizeof(unsigned int)),
&input_buffer[1] + sizeof(registers),
16 * sizeof(unsigned int));
gdb_cris_strcpy(output_buffer, "OK");
@@ -1389,7 +1352,7 @@ handle_exception(int sigval)
int len = gdb_cris_strtol(lenptr+1, &dataptr, 16);
if (*lenptr == ',' && *dataptr == ':') {
if (input_buffer[0] == 'M') {
- hex2mem(addr, dataptr + 1, len);
+ hex2bin(addr, dataptr + 1, len);
} else /* X */ {
bin2mem(addr, dataptr + 1, len);
}
--
1.8.2.rc0.22.gb3600c3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2013-06-04 8:51 [PATCH] cris: kgdb: use native hex2bin Andy Shevchenko
@ 2013-06-04 9:33 ` Andy Shevchenko
2015-09-30 14:46 ` Andy Shevchenko
1 sibling, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2013-06-04 9:33 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Mikael Starvik, Jesper Nilsson, Cris,
linux-kernel@vger.kernel.org, Geert Uytterhoeven
On Tue, Jun 4, 2013 at 11:51 AM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> There are kernel native helpers to convert hex ascii to the binary format:
> hex_to_bin() and hex2bin(). Thus, no need to reimplement them customly.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Forgot to mention this is v2.
Changes:
- rebased against today's linux-next
- v32 is also fixed
- fixed missed usage of hex() outside of hex2mem()
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2013-06-04 8:51 [PATCH] cris: kgdb: use native hex2bin Andy Shevchenko
2013-06-04 9:33 ` Andy Shevchenko
@ 2015-09-30 14:46 ` Andy Shevchenko
2015-09-30 15:22 ` Jesper Nilsson
1 sibling, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2015-09-30 14:46 UTC (permalink / raw)
To: Mikael Starvik, Jesper Nilsson, linux-cris-kernel, linux-kernel
Cc: Geert Uytterhoeven
On Tue, 2013-06-04 at 11:51 +0300, Andy Shevchenko wrote:
> There are kernel native helpers to convert hex ascii to the binary
> format:
> hex_to_bin() and hex2bin(). Thus, no need to reimplement them
> customly.
>
No one is interested in this?
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> arch/cris/arch-v10/kernel/kgdb.c | 36 +++----------------------
> arch/cris/arch-v32/kernel/kgdb.c | 57 +++++++-----------------------
> ----------
> 2 files changed, 14 insertions(+), 79 deletions(-)
>
> diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch
> -v10/kernel/kgdb.c
> index 22d846b..dbd4ba8 100644
> --- a/arch/cris/arch-v10/kernel/kgdb.c
> +++ b/arch/cris/arch-v10/kernel/kgdb.c
> @@ -413,18 +413,6 @@ gdb_cris_strtol (const char *s, char **endptr,
> int base)
> }
>
> /********************************** Packet I/O
> ******************************/
> -/* Returns the integer equivalent of a hexadecimal character. */
> -static int
> -hex (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);
> -}
>
> /* Convert the memory, pointed to by mem into hexadecimal
> representation.
> Put the result in buf, and return a pointer to the last character
> @@ -455,22 +443,6 @@ mem2hex(char *buf, unsigned char *mem, int
> count)
> return (buf);
> }
>
> -/* Convert the array, in hexadecimal representation, pointed to by
> buf into
> - binary representation. Put the result in mem, and return a
> pointer to
> - the character after the last byte written. */
> -static unsigned char*
> -hex2mem (unsigned char *mem, char *buf, int count)
> -{
> - int i;
> - unsigned char ch;
> - for (i = 0; i < count; i++) {
> - ch = hex (*buf++) << 4;
> - ch = ch + hex (*buf++);
> - *mem++ = ch;
> - }
> - return (mem);
> -}
> -
> /* Put the content of the array, in binary representation, pointed
> to by buf
> into memory pointed to by mem, and return a pointer to the
> character after
> the last byte written.
> @@ -524,8 +496,8 @@ getpacket (char *buffer)
> buffer[count] = '\0';
>
> if (ch == '#') {
> - xmitcsum = hex (getDebugChar ()) << 4;
> - xmitcsum += hex (getDebugChar ());
> + xmitcsum = hex_to_bin(getDebugChar()) << 4;
> + xmitcsum += hex_to_bin(getDebugChar());
> if (checksum != xmitcsum) {
> /* Wrong checksum */
> putDebugChar ('-');
> @@ -760,7 +732,7 @@ handle_exception (int sigval)
> Each byte of register data is
> described by two hex digits.
> Success: OK
> Failure: void. */
> - hex2mem((char *)&cris_reg,
> &remcomInBuffer[1], sizeof(registers));
> + hex2bin((char *)&cris_reg,
> &remcomInBuffer[1], sizeof(registers));
> gdb_cris_strcpy (remcomOutBuffer,
> "OK");
> break;
>
> @@ -835,7 +807,7 @@ handle_exception (int sigval)
> int length =
> gdb_cris_strtol(lenptr+1, &dataptr, 16);
> if (*lenptr == ',' &&
> *dataptr == ':') {
> if
> (remcomInBuffer[0] == 'M') {
> - hex2mem(addr
> , dataptr + 1, length);
> + hex2bin(addr
> , dataptr + 1, length);
> }
> else /* X */ {
> bin2mem(addr
> , dataptr + 1, length);
> diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch
> -v32/kernel/kgdb.c
> index b06813a..590c11b 100644
> --- a/arch/cris/arch-v32/kernel/kgdb.c
> +++ b/arch/cris/arch-v32/kernel/kgdb.c
> @@ -384,19 +384,11 @@ int getDebugChar(void);
> /* Serial port, writes one character. ETRAX 100 specific. from
> debugport.c */
> void putDebugChar(int val);
>
> -/* Returns the integer equivalent of a hexadecimal character. */
> -static int hex(char ch);
> -
> /* Convert the memory, pointed to by mem into hexadecimal
> representation.
> Put the result in buf, and return a pointer to the last character
> in buf (null). */
> static char *mem2hex(char *buf, unsigned char *mem, int count);
>
> -/* Convert the array, in hexadecimal representation, pointed to by
> buf into
> - binary representation. Put the result in mem, and return a
> pointer to
> - the character after the last byte written. */
> -static unsigned char *hex2mem(unsigned char *mem, char *buf, int
> count);
> -
> /* Put the content of the array, in binary representation, pointed
> to by buf
> into memory pointed to by mem, and return a pointer to
> the character after the last byte written. */
> @@ -547,7 +539,7 @@ write_register(int regno, char *val)
>
> if (regno >= R0 && regno <= ACR) {
> /* Consecutive 32-bit registers. */
> - hex2mem((unsigned char *)®.r0 + (regno - R0) *
> sizeof(unsigned int),
> + hex2bin((unsigned char *)®.r0 + (regno - R0) *
> sizeof(unsigned int),
> val, sizeof(unsigned int));
>
> } else if (regno == BZ || regno == VR || regno == WZ ||
> regno == DZ) {
> @@ -557,15 +549,15 @@ write_register(int regno, char *val)
> } else if (regno == PID) {
> /* 32-bit register. (Even though we already checked
> SRS and WZ, we cannot
> combine this with the EXS - SPC write since SRS
> and WZ have different size.) */
> - hex2mem((unsigned char *)®.pid, val,
> sizeof(unsigned int));
> + hex2bin((unsigned char *)®.pid, val,
> sizeof(unsigned int));
>
> } else if (regno == SRS) {
> /* 8-bit register. */
> - hex2mem((unsigned char *)®.srs, val,
> sizeof(unsigned char));
> + hex2bin((unsigned char *)®.srs, val,
> sizeof(unsigned char));
>
> } else if (regno >= EXS && regno <= SPC) {
> /* Consecutive 32-bit registers. */
> - hex2mem((unsigned char *)®.exs + (regno - EXS) *
> sizeof(unsigned int),
> + hex2bin((unsigned char *)®.exs + (regno - EXS) *
> sizeof(unsigned int),
> val, sizeof(unsigned int));
>
> } else if (regno == PC) {
> @@ -574,7 +566,7 @@ write_register(int regno, char *val)
>
> } else if (regno >= S0 && regno <= S15) {
> /* 32-bit registers. */
> - hex2mem((unsigned char *)&sreg.s0_0 + (reg.srs * 16 *
> sizeof(unsigned int)) + (regno - S0) * sizeof(unsigned int), val,
> sizeof(unsigned int));
> + hex2bin((unsigned char *)&sreg.s0_0 + (reg.srs * 16 *
> sizeof(unsigned int)) + (regno - S0) * sizeof(unsigned int), val,
> sizeof(unsigned int));
> } else {
> /* Non-existing register. */
> status = E05;
> @@ -630,19 +622,6 @@ read_register(char regno, unsigned int *valptr)
> }
>
> /********************************** Packet I/O
> ******************************/
> -/* Returns the integer equivalent of a hexadecimal character. */
> -static int
> -hex(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;
> -}
> -
> /* Convert the memory, pointed to by mem into hexadecimal
> representation.
> Put the result in buf, and return a pointer to the last character
> in buf (null). */
> @@ -689,22 +668,6 @@ mem2hex_nbo(char *buf, unsigned char *mem, int
> count)
> return buf;
> }
>
> -/* Convert the array, in hexadecimal representation, pointed to by
> buf into
> - binary representation. Put the result in mem, and return a
> pointer to
> - the character after the last byte written. */
> -static unsigned char*
> -hex2mem(unsigned char *mem, char *buf, int count)
> -{
> - int i;
> - unsigned char ch;
> - for (i = 0; i < count; i++) {
> - ch = hex (*buf++) << 4;
> - ch = ch + hex (*buf++);
> - *mem++ = ch;
> - }
> - return mem;
> -}
> -
> /* Put the content of the array, in binary representation, pointed
> to by buf
> into memory pointed to by mem, and return a pointer to the
> character after
> the last byte written.
> @@ -763,8 +726,8 @@ getpacket(char *buffer)
> buffer[count] = 0;
>
> if (ch == '#') {
> - xmitcsum = hex(getDebugChar()) << 4;
> - xmitcsum += hex(getDebugChar());
> + xmitcsum = hex_to_bin(getDebugChar()) << 4;
> + xmitcsum += hex_to_bin(getDebugChar());
> if (checksum != xmitcsum) {
> /* Wrong checksum */
> putDebugChar('-');
> @@ -1306,9 +1269,9 @@ handle_exception(int sigval)
> Success: OK
> Failure: void. */
> /* General and special registers. */
> - hex2mem((char *)®,
> &input_buffer[1], sizeof(registers));
> + hex2bin((char *)®,
> &input_buffer[1], sizeof(registers));
> /* Support registers. */
> - hex2mem((char *)&sreg + (reg.srs *
> 16 * sizeof(unsigned int)),
> + hex2bin((char *)&sreg + (reg.srs *
> 16 * sizeof(unsigned int)),
> &input_buffer[1] +
> sizeof(registers),
> 16 * sizeof(unsigned int));
> gdb_cris_strcpy(output_buffer,
> "OK");
> @@ -1389,7 +1352,7 @@ handle_exception(int sigval)
> int len =
> gdb_cris_strtol(lenptr+1, &dataptr, 16);
> if (*lenptr == ',' &&
> *dataptr == ':') {
> if (input_buffer[0]
> == 'M') {
> - hex2mem(addr
> , dataptr + 1, len);
> + hex2bin(addr
> , dataptr + 1, len);
> } else /* X */ {
> bin2mem(addr
> , dataptr + 1, len);
> }
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2015-09-30 14:46 ` Andy Shevchenko
@ 2015-09-30 15:22 ` Jesper Nilsson
2015-09-30 15:37 ` Andy Shevchenko
0 siblings, 1 reply; 10+ messages in thread
From: Jesper Nilsson @ 2015-09-30 15:22 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Mikael Starvik, Jesper Nilsson, linux-cris-kernel,
linux-kernel@vger.kernel.org, Geert Uytterhoeven
On Wed, Sep 30, 2015 at 04:46:53PM +0200, Andy Shevchenko wrote:
> On Tue, 2013-06-04 at 11:51 +0300, Andy Shevchenko wrote:
> > There are kernel native helpers to convert hex ascii to the binary
> > format:
> > hex_to_bin() and hex2bin(). Thus, no need to reimplement them
> > customly.
> >
>
> No one is interested in this?
Hm, dunno why, but obviously I've missed these patches,
and I can't find them on my main mailaccount either.
Anyways, I found them on a secondary account, and have
added them to the CRIS linux-next tree.
Thanks!
/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper.nilsson@axis.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2015-09-30 15:22 ` Jesper Nilsson
@ 2015-09-30 15:37 ` Andy Shevchenko
2015-09-30 18:02 ` Jesper Nilsson
0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2015-09-30 15:37 UTC (permalink / raw)
To: Jesper Nilsson
Cc: Mikael Starvik, Jesper Nilsson, linux-cris-kernel,
linux-kernel@vger.kernel.org, Geert Uytterhoeven
On Wed, 2015-09-30 at 17:22 +0200, Jesper Nilsson wrote:
> On Wed, Sep 30, 2015 at 04:46:53PM +0200, Andy Shevchenko wrote:
> > On Tue, 2013-06-04 at 11:51 +0300, Andy Shevchenko wrote:
> > > There are kernel native helpers to convert hex ascii to the
> > > binary
> > > format:
> > > hex_to_bin() and hex2bin(). Thus, no need to reimplement them
> > > customly.
> > >
> >
> > No one is interested in this?
>
> Hm, dunno why, but obviously I've missed these patches,
> and I can't find them on my main mailaccount either.
>
> Anyways, I found them on a secondary account, and have
> added them to the CRIS linux-next tree.
Just noticed that it was along time ago and currently it might produce
compile warnings or errors since now hex2bin is prefixed by
__must_check.
Would you like me to send v2?
>
> Thanks!
>
> /^JN - Jesper Nilsson
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2015-09-30 15:37 ` Andy Shevchenko
@ 2015-09-30 18:02 ` Jesper Nilsson
2015-09-30 18:11 ` Jesper Nilsson
0 siblings, 1 reply; 10+ messages in thread
From: Jesper Nilsson @ 2015-09-30 18:02 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jesper Nilsson, Mikael Starvik, Jesper Nilsson, linux-cris-kernel,
linux-kernel@vger.kernel.org, Geert Uytterhoeven
On Wed, Sep 30, 2015 at 06:37:51PM +0300, Andy Shevchenko wrote:
> On Wed, 2015-09-30 at 17:22 +0200, Jesper Nilsson wrote:
> > On Wed, Sep 30, 2015 at 04:46:53PM +0200, Andy Shevchenko wrote:
> > > On Tue, 2013-06-04 at 11:51 +0300, Andy Shevchenko wrote:
> > > > There are kernel native helpers to convert hex ascii to the
> > > > binary
> > > > format:
> > > > hex_to_bin() and hex2bin(). Thus, no need to reimplement them
> > > > customly.
> > > >
> > >
> > > No one is interested in this?
> >
> > Hm, dunno why, but obviously I've missed these patches,
> > and I can't find them on my main mailaccount either.
> >
> > Anyways, I found them on a secondary account, and have
> > added them to the CRIS linux-next tree.
>
> Just noticed that it was along time ago and currently it might produce
> compile warnings or errors since now hex2bin is prefixed by
> __must_check.
>
> Would you like me to send v2?
Unless you've tweaked them more since you sent them,
it shouldn't be necessary, the patches applied cleanly.
Those (most) files in CRIS are not touched very often... :-)
> Andy Shevchenko <andriy.shevchenko@linux.intel.com>
/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper_at_jni.nu
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2015-09-30 18:02 ` Jesper Nilsson
@ 2015-09-30 18:11 ` Jesper Nilsson
0 siblings, 0 replies; 10+ messages in thread
From: Jesper Nilsson @ 2015-09-30 18:11 UTC (permalink / raw)
To: Jesper Nilsson
Cc: Andy Shevchenko, Jesper Nilsson, Mikael Starvik,
linux-cris-kernel, linux-kernel@vger.kernel.org,
Geert Uytterhoeven
On Wed, Sep 30, 2015 at 08:02:34PM +0200, Jesper Nilsson wrote:
> On Wed, Sep 30, 2015 at 06:37:51PM +0300, Andy Shevchenko wrote:
> > On Wed, 2015-09-30 at 17:22 +0200, Jesper Nilsson wrote:
> > > On Wed, Sep 30, 2015 at 04:46:53PM +0200, Andy Shevchenko wrote:
> > > > On Tue, 2013-06-04 at 11:51 +0300, Andy Shevchenko wrote:
> > > > > There are kernel native helpers to convert hex ascii to the
> > > > > binary
> > > > > format:
> > > > > hex_to_bin() and hex2bin(). Thus, no need to reimplement them
> > > > > customly.
> > > > >
> > > >
> > > > No one is interested in this?
> > >
> > > Hm, dunno why, but obviously I've missed these patches,
> > > and I can't find them on my main mailaccount either.
> > >
> > > Anyways, I found them on a secondary account, and have
> > > added them to the CRIS linux-next tree.
> >
> > Just noticed that it was along time ago and currently it might produce
> > compile warnings or errors since now hex2bin is prefixed by
> > __must_check.
> >
> > Would you like me to send v2?
>
> Unless you've tweaked them more since you sent them,
> it shouldn't be necessary, the patches applied cleanly.
> Those (most) files in CRIS are not touched very often... :-)
... and now I saw your v2, I'll take that instead since
you already fixed the __must_check problems.
Thanks a lot!
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com>
/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper.nilsson@axis.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Exotic architecture fixes
@ 2013-05-23 20:09 Geert Uytterhoeven
2013-05-28 15:53 ` [PATCH] arch/cris: old patch to use hex2bin Andy Shevchenko
0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2013-05-23 20:09 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton, Al Viro, David Howells, Yoshinori Sato,
Haavard Skinnemoen, Hans-Christian Egtvedt, Chen Liqin, Lennox Wu,
linux-c6x-dev, Cris, linux
I created a branch where I collected several exotic architecture fixes
(and a few
other trivial fixes):
git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git
exotic-arch-fixes
Several of these have been ack'ed (cfr. *-indicators below).
If you reject any of the commits, please scream.
If you want to take any of them yourself, please do so.
I intend to merge this into my for-next branch after the release of v3.10-rc4,
and ask Linus to pull after the release of v3.10-rc5.
This branch may be rebased.
Thanks!
Geert Uytterhoeven (32):
* avr32: atmel_default_console_device depends on CONFIG_SERIAL_ATMEL
* c6x: Wire up asm-generic/xor.h
cris/kgdb: Properly split long lines in asm
cris/kgdb: Remove unused static int do_printk
cris/kgdb: Kill forward declarations for static functions
cris/kgdb: Use #ifdef PROCESS_SUPPORT where needed
cris/kgb: Make symbols used from asm global
cris/kgdb: Remove obsolete USED*() macros
cris/kgdb: Fix buffer overflow in getpacket()
cris/kgdb: Remove sections protected by #ifdef PROCESS_SUPPORT
cris: Provide <asm/kvm_para.h>
cris: Provide inb_p() and outb_p()
* cris: Switch to asm-generic/linkage.h
* cris: Wire up asm-generic/xor.h
cris: Switch cris to drivers/Kconfig
console: Disable VGA text console support on cris
parport: disable PC-style parallel port support on cris
cris: Wire up asm-generic/vga.h
frv: head.S - Remove commented-out initialization code
h8300: Hardcode symbol prefixes in asm sources
* h8300: Fix <asm/tlb.h>
h8300: Fill the system call table using a CALL() macro
h8300: Wire up asm-generic/xor.h
h8300: Limit timer channel ranges in Kconfig
h8300: Switch h8300 to drivers/Kconfig
h8300: Mark H83002 and H83048 CPU support broken
openrisc: Wire up asm-generic/xor.h
score: Remove unneeded <asm/dma-mapping.h>
score: Wire up asm-generic/xor.h
* console/font: Refactor font support code selection logic
* ntp: Remove unused variable flags in __hardpps
* input: cros_ec_keyb_clear_keyboard() depends on CONFIG_PM_SLEEP
Jiang Liu (1):
h8300: add missing definition for read_barries_depends()
arch/avr32/mach-at32ap/at32ap700x.c | 2 +
arch/c6x/include/asm/Kbuild | 1 +
arch/cris/Kconfig | 32 +-
arch/cris/arch-v10/kernel/kgdb.c | 870 +++++++---------------
arch/cris/arch-v32/drivers/Kconfig | 7 -
arch/cris/include/asm/Kbuild | 4 +
arch/cris/include/asm/io.h | 3 +
arch/cris/include/asm/linkage.h | 6 -
arch/frv/kernel/head.S | 5 -
arch/h8300/Kconfig | 118 +---
arch/h8300/Kconfig.cpu | 4 +
arch/h8300/include/asm/Kbuild | 2 +
arch/h8300/include/asm/barrier.h | 2 +
arch/h8300/include/asm/linkage.h | 6 -
arch/h8300/include/asm/tlb.h | 15 -
arch/h8300/kernel/entry.S | 118 ++--
arch/h8300/kernel/syscalls.S | 648 ++++++++--------
arch/h8300/lib/abs.S | 4 +-
arch/h8300/lib/memcpy.S | 4 +-
arch/h8300/lib/memset.S | 4 +-
arch/h8300/platform/h8300h/aki3068net/crt0_ram.S | 16 +-
arch/h8300/platform/h8300h/generic/crt0_ram.S | 14 +-
arch/h8300/platform/h8300h/generic/crt0_rom.S | 14 +-
arch/h8300/platform/h8300h/h8max/crt0_ram.S | 16 +-
arch/h8300/platform/h8s/edosk2674/crt0_ram.S | 16 +-
arch/h8300/platform/h8s/edosk2674/crt0_rom.S | 14 +-
arch/h8300/platform/h8s/generic/crt0_ram.S | 16 +-
arch/h8300/platform/h8s/generic/crt0_rom.S | 12 +-
arch/openrisc/include/asm/Kbuild | 1 +
arch/score/include/asm/Kbuild | 1 +
arch/score/include/asm/dma-mapping.h | 6 -
drivers/input/keyboard/cros_ec_keyb.c | 54 +-
drivers/media/platform/Kconfig | 2 +-
drivers/parport/Kconfig | 4 +-
drivers/staging/media/solo6x10/Kconfig | 2 +
drivers/usb/misc/sisusbvga/Kconfig | 1 +
drivers/video/console/Kconfig | 16 +-
drivers/video/console/Makefile | 14 +-
kernel/time/ntp.c | 1 -
39 files changed, 789 insertions(+), 1286 deletions(-)
delete mode 100644 arch/cris/include/asm/linkage.h
delete mode 100644 arch/h8300/include/asm/linkage.h
delete mode 100644 arch/score/include/asm/dma-mapping.h
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] arch/cris: old patch to use hex2bin
2013-05-23 20:09 Exotic architecture fixes Geert Uytterhoeven
@ 2013-05-28 15:53 ` Andy Shevchenko
2013-05-28 15:53 ` [PATCH] cris: kgdb: use native hex2bin Andy Shevchenko
0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2013-05-28 15:53 UTC (permalink / raw)
To: linux-kernel, Geert Uytterhoeven, Cris; +Cc: Andy Shevchenko
Geert, would you like to add following patch to your tree as well?
Andy Shevchenko (1):
cris: kgdb: use native hex2bin
arch/cris/arch-v10/kernel/kgdb.c | 50 ++++++----------------------------------
1 file changed, 7 insertions(+), 43 deletions(-)
--
1.8.2.rc0.22.gb3600c3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] cris: kgdb: use native hex2bin
2013-05-28 15:53 ` [PATCH] arch/cris: old patch to use hex2bin Andy Shevchenko
@ 2013-05-28 15:53 ` Andy Shevchenko
2013-05-30 7:57 ` Geert Uytterhoeven
0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2013-05-28 15:53 UTC (permalink / raw)
To: linux-kernel, Geert Uytterhoeven, Cris; +Cc: Andy Shevchenko
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/cris/arch-v10/kernel/kgdb.c | 50 ++++++----------------------------------
1 file changed, 7 insertions(+), 43 deletions(-)
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index 37e6d2c..07bccd8 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -278,19 +278,11 @@ void putDebugChar (int val);
void enableDebugIRQ (void);
-/* Returns the integer equivalent of a hexadecimal character. */
-static int hex (char ch);
-
/* Convert the memory, pointed to by mem into hexadecimal representation.
Put the result in buf, and return a pointer to the last character
in buf (null). */
static char *mem2hex (char *buf, unsigned char *mem, int count);
-/* Convert the array, in hexadecimal representation, pointed to by buf into
- binary representation. Put the result in mem, and return a pointer to
- the character after the last byte written. */
-static unsigned char *hex2mem (unsigned char *mem, char *buf, int count);
-
/* Put the content of the array, in binary representation, pointed to by buf
into memory pointed to by mem, and return a pointer to
the character after the last byte written. */
@@ -560,7 +552,7 @@ write_register (int regno, char *val)
if (regno >= R0 && regno <= PC) {
/* 32-bit register with simple offset. */
- hex2mem ((unsigned char *)current_reg + regno * sizeof(unsigned int),
+ hex2bin((unsigned char *)current_reg + regno * sizeof(unsigned int),
val, sizeof(unsigned int));
}
else if (regno == P0 || regno == VR || regno == P4 || regno == P8) {
@@ -570,12 +562,12 @@ write_register (int regno, char *val)
else if (regno == CCR) {
/* 16 bit register with complex offset. (P4 is read-only, P6 is not implemented,
and P7 (MOF) is 32 bits in ETRAX 100LX. */
- hex2mem ((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short),
+ hex2bin((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short),
val, sizeof(unsigned short));
}
else if (regno >= MOF && regno <= USP) {
/* 32 bit register with complex offset. (P8 has been taken care of.) */
- hex2mem ((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int),
+ hex2bin((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int),
val, sizeof(unsigned int));
}
else {
@@ -595,7 +587,7 @@ write_stack_register (int thread_id, int regno, char *valptr)
stack_registers *d = (stack_registers *)stack_list[thread_id];
unsigned int val;
- hex2mem ((unsigned char *)&val, valptr, sizeof(unsigned int));
+ hex2bin((unsigned char *)&val, valptr, sizeof(unsigned int));
if (regno >= R0 && regno < SP) {
d->r[regno] = val;
}
@@ -659,18 +651,6 @@ read_register (char regno, unsigned int *valptr)
}
/********************************** Packet I/O ******************************/
-/* Returns the integer equivalent of a hexadecimal character. */
-static int
-hex (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);
-}
/* Convert the memory, pointed to by mem into hexadecimal representation.
Put the result in buf, and return a pointer to the last character
@@ -703,22 +683,6 @@ mem2hex(char *buf, unsigned char *mem, int count)
return (buf);
}
-/* Convert the array, in hexadecimal representation, pointed to by buf into
- binary representation. Put the result in mem, and return a pointer to
- the character after the last byte written. */
-static unsigned char*
-hex2mem (unsigned char *mem, char *buf, int count)
-{
- int i;
- unsigned char ch;
- for (i = 0; i < count; i++) {
- ch = hex (*buf++) << 4;
- ch = ch + hex (*buf++);
- *mem++ = ch;
- }
- return (mem);
-}
-
/* Put the content of the array, in binary representation, pointed to by buf
into memory pointed to by mem, and return a pointer to the character after
the last byte written.
@@ -964,7 +928,7 @@ handle_exception (int sigval)
Success: OK
Failure: void. */
#ifdef PROCESS_SUPPORT
- hex2mem ((unsigned char *)®_g, &remcomInBuffer[1], sizeof(registers));
+ hex2bin((unsigned char *)®_g, &remcomInBuffer[1], sizeof(registers));
if (current_thread_g == executing_task) {
copy_registers (®, ®_g, sizeof(registers));
}
@@ -972,7 +936,7 @@ handle_exception (int sigval)
copy_registers_to_stack(current_thread_g, ®_g);
}
#else
- hex2mem((char *)®, &remcomInBuffer[1], sizeof(registers));
+ hex2bin((char *)®, &remcomInBuffer[1], sizeof(registers));
#endif
gdb_cris_strcpy (remcomOutBuffer, "OK");
break;
@@ -1053,7 +1017,7 @@ handle_exception (int sigval)
int length = gdb_cris_strtol(lenptr+1, &dataptr, 16);
if (*lenptr == ',' && *dataptr == ':') {
if (remcomInBuffer[0] == 'M') {
- hex2mem(addr, dataptr + 1, length);
+ hex2bin(addr, dataptr + 1, length);
}
else /* X */ {
bin2mem(addr, dataptr + 1, length);
--
1.8.2.rc0.22.gb3600c3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2013-05-28 15:53 ` [PATCH] cris: kgdb: use native hex2bin Andy Shevchenko
@ 2013-05-30 7:57 ` Geert Uytterhoeven
2013-05-30 9:09 ` Andy Shevchenko
0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2013-05-30 7:57 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel@vger.kernel.org, Cris
On Tue, May 28, 2013 at 5:53 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
> index 37e6d2c..07bccd8 100644
> --- a/arch/cris/arch-v10/kernel/kgdb.c
> +++ b/arch/cris/arch-v10/kernel/kgdb.c
> @@ -659,18 +651,6 @@ read_register (char regno, unsigned int *valptr)
> }
>
> /********************************** Packet I/O ******************************/
> -/* Returns the integer equivalent of a hexadecimal character. */
> -static int
> -hex (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);
> -}
This one handles both upper and lower case hex characters, while hex2bin()
handles lower case only. Is that OK, or should hex2bin be extended?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cris: kgdb: use native hex2bin
2013-05-30 7:57 ` Geert Uytterhoeven
@ 2013-05-30 9:09 ` Andy Shevchenko
0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2013-05-30 9:09 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Andy Shevchenko, linux-kernel@vger.kernel.org, Cris
On Thu, May 30, 2013 at 10:57 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Tue, May 28, 2013 at 5:53 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>> diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
>> index 37e6d2c..07bccd8 100644
>> --- a/arch/cris/arch-v10/kernel/kgdb.c
>> +++ b/arch/cris/arch-v10/kernel/kgdb.c
>
>> @@ -659,18 +651,6 @@ read_register (char regno, unsigned int *valptr)
>> }
>>
>> /********************************** Packet I/O ******************************/
>> -/* Returns the integer equivalent of a hexadecimal character. */
>> -static int
>> -hex (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);
>> -}
>
> This one handles both upper and lower case hex characters, while hex2bin()
> handles lower case only. Is that OK, or should hex2bin be extended?
Its implementation is located in lib/hexdump.c
If you look at it carefully you find that hex2bin calls hex_to_bin()
which services both cases (via using tolower()).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-09-30 18:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-04 8:51 [PATCH] cris: kgdb: use native hex2bin Andy Shevchenko
2013-06-04 9:33 ` Andy Shevchenko
2015-09-30 14:46 ` Andy Shevchenko
2015-09-30 15:22 ` Jesper Nilsson
2015-09-30 15:37 ` Andy Shevchenko
2015-09-30 18:02 ` Jesper Nilsson
2015-09-30 18:11 ` Jesper Nilsson
-- strict thread matches above, loose matches on Subject: below --
2013-05-23 20:09 Exotic architecture fixes Geert Uytterhoeven
2013-05-28 15:53 ` [PATCH] arch/cris: old patch to use hex2bin Andy Shevchenko
2013-05-28 15:53 ` [PATCH] cris: kgdb: use native hex2bin Andy Shevchenko
2013-05-30 7:57 ` Geert Uytterhoeven
2013-05-30 9:09 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).