mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi"
@ 2017-10-17 13:16 Ulrich Ölmann
  2017-10-17 13:16 ` [PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted Ulrich Ölmann
  2017-10-17 13:16 ` [PATCH 2/2] commands: spi: do not restrict spi's " Ulrich Ölmann
  0 siblings, 2 replies; 8+ messages in thread
From: Ulrich Ölmann @ 2017-10-17 13:16 UTC (permalink / raw)
  To: Barebox List

Currently both commands set the default base for parsing user supplied data to
16 which makes it impossible at all to parse decimal data.

Presumably this originates from having the convenience to easily copy'n'paste
hex dumped data into these commands without further preprocessing it before.

Change the default base to 0 to particularly allow decimally formatted data.
This is in accordance to what the "mw" command does.

Ulrich Ölmann (2):
  commands: i2c: do not restrict i2c_write's data to be hex-formatted
  commands: spi: do not restrict spi's data to be hex-formatted

 commands/i2c.c | 2 +-
 commands/spi.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted
  2017-10-17 13:16 [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi" Ulrich Ölmann
@ 2017-10-17 13:16 ` Ulrich Ölmann
  2017-10-17 13:51   ` Uwe Kleine-König
  2017-10-17 13:16 ` [PATCH 2/2] commands: spi: do not restrict spi's " Ulrich Ölmann
  1 sibling, 1 reply; 8+ messages in thread
From: Ulrich Ölmann @ 2017-10-17 13:16 UTC (permalink / raw)
  To: Barebox List

The price to pay is needing the usual prefix "0x" for each hex-formatted number.

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 commands/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/i2c.c b/commands/i2c.c
index 573032ab1588..b74c53509f38 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -129,7 +129,7 @@ static int do_i2c_write(int argc, char *argv[])
 
 	buf = xmalloc(count);
 	for (i = 0; i < count; i++)
-		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 16);
+		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 0);
 
 	ret = i2c_write_reg(&client, reg | wide, buf, count);
 	if (ret != count) {
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] commands: spi: do not restrict spi's data to be hex-formatted
  2017-10-17 13:16 [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi" Ulrich Ölmann
  2017-10-17 13:16 ` [PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted Ulrich Ölmann
@ 2017-10-17 13:16 ` Ulrich Ölmann
  1 sibling, 0 replies; 8+ messages in thread
From: Ulrich Ölmann @ 2017-10-17 13:16 UTC (permalink / raw)
  To: Barebox List

The price to pay is needing the usual prefix "0x" for each hex-formatted number.

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 commands/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/spi.c b/commands/spi.c
index 6603b34b673c..7bf193b0bbbb 100644
--- a/commands/spi.c
+++ b/commands/spi.c
@@ -84,7 +84,7 @@ static int do_spi(int argc, char *argv[])
 	rx_buf = xmalloc(read);
 
 	for (i = 0; i < count; i++)
-		tx_buf[i] = (u8) simple_strtol(argv[optind + i], NULL, 16);
+		tx_buf[i] = (u8) simple_strtol(argv[optind + i], NULL, 0);
 
 	ret = spi_write_then_read(&spi, tx_buf, count, rx_buf, read);
 	if (ret)
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted
  2017-10-17 13:16 ` [PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted Ulrich Ölmann
@ 2017-10-17 13:51   ` Uwe Kleine-König
  2017-10-19  6:55     ` Ulrich Ölmann
  0 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2017-10-17 13:51 UTC (permalink / raw)
  To: Ulrich Ölmann; +Cc: Barebox List

Hello,

On Tue, Oct 17, 2017 at 03:16:24PM +0200, Ulrich Ölmann wrote:
> The price to pay is needing the usual prefix "0x" for each hex-formatted number.
> 
> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>

ack for the change. I'd like to see the motivation (i.e. consistency with
the other commands in barebox as mentioned in the cover letter) in the
commit log, though.

> ---
>  commands/i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/commands/i2c.c b/commands/i2c.c
> index 573032ab1588..b74c53509f38 100644
> --- a/commands/i2c.c
> +++ b/commands/i2c.c
> @@ -129,7 +129,7 @@ static int do_i2c_write(int argc, char *argv[])
>  
>  	buf = xmalloc(count);
>  	for (i = 0; i < count; i++)
> -		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 16);
> +		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 0);

Maybe change that to:

		buf[i] = simple_strtol(...);

which is a bit easier to read and drops an unnecessary cast? (Or should
that better go in a separate change?)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted
  2017-10-17 13:51   ` Uwe Kleine-König
@ 2017-10-19  6:55     ` Ulrich Ölmann
  0 siblings, 0 replies; 8+ messages in thread
From: Ulrich Ölmann @ 2017-10-19  6:55 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Barebox List

Hi Uwe and list,

On Tue, Oct 17, 2017 at 03:51:37PM +0200, Uwe Kleine-König wrote:
> On Tue, Oct 17, 2017 at 03:16:24PM +0200, Ulrich Ölmann wrote:
> > The price to pay is needing the usual prefix "0x" for each hex-formatted number.
> > 
> > Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
> 
> ack for the change. I'd like to see the motivation (i.e. consistency with
> the other commands in barebox as mentioned in the cover letter) in the
> commit log, though.

just sent a v2.

> [...]
> > -		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 16);
> > +		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 0);
> 
> Maybe change that to:
> 
> 		buf[i] = simple_strtol(...);
> 
> which is a bit easier to read and drops an unnecessary cast? (Or should
> that better go in a separate change?)

Fully agreed. Will you prepare a patch?

Best regards
Ulrich
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi"
  2017-10-19  6:53 [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi" Ulrich Ölmann
  2017-10-19  7:44 ` Ulrich Ölmann
@ 2017-10-23  7:27 ` Sascha Hauer
  1 sibling, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2017-10-23  7:27 UTC (permalink / raw)
  To: Ulrich Ölmann; +Cc: Barebox List

On Thu, Oct 19, 2017 at 08:53:06AM +0200, Ulrich Ölmann wrote:
> Currently both commands set the default base for parsing user supplied data to
> 16 which makes it impossible at all to parse decimal data.
> 
> Presumably this originates from having the convenience to easily copy'n'paste
> hex dumped data into these commands without further preprocessing it before.
> 
> Change the default base to 0 to particularly allow decimally formatted data.
> This is in accordance to what the "mw" command does.
> 
> Changes since (implicit) v1 (20171017) (http://lists.infradead.org/pipermail/barebox/2017-October/031356.html):
>   - extended the commit messages to include the motivation for the change
>   - added Uwe's acked-by
> 
> Ulrich Ölmann (2):
>   commands: i2c: do not restrict i2c_write's data to be hex-formatted
>   commands: spi: do not restrict spi's data to be hex-formatted

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi"
  2017-10-19  6:53 [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi" Ulrich Ölmann
@ 2017-10-19  7:44 ` Ulrich Ölmann
  2017-10-23  7:27 ` Sascha Hauer
  1 sibling, 0 replies; 8+ messages in thread
From: Ulrich Ölmann @ 2017-10-19  7:44 UTC (permalink / raw)
  To: Barebox List

Args, forgot the v2-infix in the subject...
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi"
@ 2017-10-19  6:53 Ulrich Ölmann
  2017-10-19  7:44 ` Ulrich Ölmann
  2017-10-23  7:27 ` Sascha Hauer
  0 siblings, 2 replies; 8+ messages in thread
From: Ulrich Ölmann @ 2017-10-19  6:53 UTC (permalink / raw)
  To: Barebox List

Currently both commands set the default base for parsing user supplied data to
16 which makes it impossible at all to parse decimal data.

Presumably this originates from having the convenience to easily copy'n'paste
hex dumped data into these commands without further preprocessing it before.

Change the default base to 0 to particularly allow decimally formatted data.
This is in accordance to what the "mw" command does.

Changes since (implicit) v1 (20171017) (http://lists.infradead.org/pipermail/barebox/2017-October/031356.html):
  - extended the commit messages to include the motivation for the change
  - added Uwe's acked-by

Ulrich Ölmann (2):
  commands: i2c: do not restrict i2c_write's data to be hex-formatted
  commands: spi: do not restrict spi's data to be hex-formatted

 commands/i2c.c | 2 +-
 commands/spi.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--
2.11.0

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2017-10-23  7:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-17 13:16 [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi" Ulrich Ölmann
2017-10-17 13:16 ` [PATCH 1/2] commands: i2c: do not restrict i2c_write's data to be hex-formatted Ulrich Ölmann
2017-10-17 13:51   ` Uwe Kleine-König
2017-10-19  6:55     ` Ulrich Ölmann
2017-10-17 13:16 ` [PATCH 2/2] commands: spi: do not restrict spi's " Ulrich Ölmann
2017-10-19  6:53 [PATCH 0/2] Allow decimally formatted data for the commands "i2c_write" and "spi" Ulrich Ölmann
2017-10-19  7:44 ` Ulrich Ölmann
2017-10-23  7:27 ` Sascha Hauer

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