All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling
@ 2017-04-03 17:36 Wolfram Sang
  2017-04-03 17:36 ` [PATCH i2c-tools 2/2] i2ctransfer: grammar fixes in manpage Wolfram Sang
  2017-04-07 12:13 ` [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling Wolfram Sang
  0 siblings, 2 replies; 5+ messages in thread
From: Wolfram Sang @ 2017-04-03 17:36 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-renesas-soc, Uwe Kleine-König, Wolfram Sang

Probably because of a bad rebase, the old and bogus handling (v1) of "force"
slipped into the latest version of the patch (v3). Apply the better
version from v2 which does the error handling correct and makes the code
a lot easier to understand.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 tools/i2ctransfer.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 0f7ddd5..bc027c3 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -199,8 +199,6 @@ int main(int argc, char *argv[])
 
 			arg_ptr = end;
 			if (*arg_ptr) {
-				int whole_range_ok;
-
 				if (*arg_ptr++ != '@') {
 					fprintf(stderr, "Error: Unknown seperator after length\n");
 					goto err_out_with_arg;
@@ -211,16 +209,22 @@ int main(int argc, char *argv[])
 				 * the address here.
 				 */
 
-				address = parse_i2c_address(arg_ptr);
-				/* With 'force', allow whole address range */
-				whole_range_ok = force && address == -2;
-				if (address < 0 && !whole_range_ok)
-					goto err_out_with_arg;
-
-				/* Ensure address is not busy */
-				if (!force && set_slave_addr(file, address, 0))
-					goto err_out_with_arg;
-
+				if (!force) {
+					address = parse_i2c_address(arg_ptr);
+					if (address < 0)
+						goto err_out_with_arg;
+
+					/* Ensure address is not busy */
+					if (set_slave_addr(file, address, 0))
+						goto err_out_with_arg;
+				} else {
+					/* 'force' allows whole address range */
+					address = strtol(arg_ptr, &end, 0);
+					if (arg_ptr == end || *end || address > 0x7f) {
+						fprintf(stderr, "Error: Invalid chip address\n");
+						goto err_out_with_arg;
+					}
+				}
 			} else {
 				/* Reuse last address if possible */
 				if (address < 0) {
-- 
2.11.0

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

* [PATCH i2c-tools 2/2] i2ctransfer: grammar fixes in manpage
  2017-04-03 17:36 [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling Wolfram Sang
@ 2017-04-03 17:36 ` Wolfram Sang
  2017-04-04  7:31   ` Geert Uytterhoeven
  2017-04-07 12:13 ` [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2017-04-03 17:36 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-renesas-soc, Uwe Kleine-König, Wolfram Sang

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 tools/i2ctransfer.8 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8
index 28b3388..d17df3c 100644
--- a/tools/i2ctransfer.8
+++ b/tools/i2ctransfer.8
@@ -74,7 +74,7 @@ This number should correspond to one of the busses listed by
 The next parameter is one or multiple
 .I desc
 blocks.
-The number of blocks is limited by the Linux Kernel and defined in I2C_RDWR_IOCTL_MAX_MSGS (42 as of v4.10).
+The number of blocks is limited by the Linux Kernel and defined with I2C_RDWR_IOCTL_MAX_MSGS (42 as of v4.10).
 .I desc
 blocks are composed like this:
 
@@ -86,7 +86,7 @@ specifies if the message is read or write
 .TP
 .B <length_of_message>
 specifies the number of bytes read or written in this message.
-It is parsed as an unsigned 16 bit integer, but note that the Linux Kernel apply an additional upper limit (8192 as of v4.10).
+It is parsed as an unsigned 16 bit integer, but note that the Linux Kernel applies an additional upper limit (8192 as of v4.10).
 .TP
 .B [@address]
 specifies the 7-bit address of the chip to be accessed for this message, and is an integer.
-- 
2.11.0

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

* Re: [PATCH i2c-tools 2/2] i2ctransfer: grammar fixes in manpage
  2017-04-03 17:36 ` [PATCH i2c-tools 2/2] i2ctransfer: grammar fixes in manpage Wolfram Sang
@ 2017-04-04  7:31   ` Geert Uytterhoeven
  2017-04-07 12:13     ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-04-04  7:31 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Linux I2C, Linux-Renesas, Uwe Kleine-König

Hi Wolfram,

On Mon, Apr 3, 2017 at 7:36 PM, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> --- a/tools/i2ctransfer.8
> +++ b/tools/i2ctransfer.8
> @@ -74,7 +74,7 @@ This number should correspond to one of the busses listed by
>  The next parameter is one or multiple
>  .I desc
>  blocks.
> -The number of blocks is limited by the Linux Kernel and defined in I2C_RDWR_IOCTL_MAX_MSGS (42 as of v4.10).
> +The number of blocks is limited by the Linux Kernel and defined with I2C_RDWR_IOCTL_MAX_MSGS (42 as of v4.10).

defined by?

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] 5+ messages in thread

* Re: [PATCH i2c-tools 2/2] i2ctransfer: grammar fixes in manpage
  2017-04-04  7:31   ` Geert Uytterhoeven
@ 2017-04-07 12:13     ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2017-04-07 12:13 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Wolfram Sang, Linux I2C, Linux-Renesas, Uwe Kleine-König

[-- Attachment #1: Type: text/plain, Size: 698 bytes --]

On Tue, Apr 04, 2017 at 09:31:17AM +0200, Geert Uytterhoeven wrote:
> Hi Wolfram,
> 
> On Mon, Apr 3, 2017 at 7:36 PM, Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> > --- a/tools/i2ctransfer.8
> > +++ b/tools/i2ctransfer.8
> > @@ -74,7 +74,7 @@ This number should correspond to one of the busses listed by
> >  The next parameter is one or multiple
> >  .I desc
> >  blocks.
> > -The number of blocks is limited by the Linux Kernel and defined in I2C_RDWR_IOCTL_MAX_MSGS (42 as of v4.10).
> > +The number of blocks is limited by the Linux Kernel and defined with I2C_RDWR_IOCTL_MAX_MSGS (42 as of v4.10).
> 
> defined by?

Thanks, yes. Fixed locally and pushed out.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling
  2017-04-03 17:36 [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling Wolfram Sang
  2017-04-03 17:36 ` [PATCH i2c-tools 2/2] i2ctransfer: grammar fixes in manpage Wolfram Sang
@ 2017-04-07 12:13 ` Wolfram Sang
  1 sibling, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2017-04-07 12:13 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, linux-renesas-soc, Uwe Kleine-König

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

On Mon, Apr 03, 2017 at 07:36:12PM +0200, Wolfram Sang wrote:
> Probably because of a bad rebase, the old and bogus handling (v1) of "force"
> slipped into the latest version of the patch (v3). Apply the better
> version from v2 which does the error handling correct and makes the code
> a lot easier to understand.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Pushed out to i2c-tools/master.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2017-04-07 12:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03 17:36 [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling Wolfram Sang
2017-04-03 17:36 ` [PATCH i2c-tools 2/2] i2ctransfer: grammar fixes in manpage Wolfram Sang
2017-04-04  7:31   ` Geert Uytterhoeven
2017-04-07 12:13     ` Wolfram Sang
2017-04-07 12:13 ` [PATCH i2c-tools 1/2] i2ctransfer: replace broken "force" handling Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.