All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch proposal for risky i2c addresses in i2c-tools
@ 2018-01-05 15:02 Romain Porte
  2018-01-05 15:02 ` [PATCH 1/3] Add risky_addr option for i2c tools Romain Porte
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-05 15:02 UTC (permalink / raw)
  To: linux-i2c; +Cc: jdelvare

This patchset proposes a new option for risky i2c addresses between 0x78
and 0x7f that are currently disabled. This behavior is marked as not
recommended, but is sometimes needed if you have a device using an
address in this range.

It was inspired by an email from Wolfram Sang [1] that encouraged to add
this option for using i2c-tools with devices using this address range.

[1]: https://www.spinics.net/lists/linux-i2c/msg25295.html

Please review!

Romain.

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

* [PATCH 1/3] Add risky_addr option for i2c tools
  2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
@ 2018-01-05 15:02 ` Romain Porte
  2018-01-05 15:02 ` [PATCH 2/3] Update help message for risky_addr option Romain Porte
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-05 15:02 UTC (permalink / raw)
  To: linux-i2c; +Cc: jdelvare, Romain Porte

If the user is sure that the reserved 0x77 - 0x7f range is not needed by
its devices, then he can pass the "-a" option for allowing so called
"risky addresses". It is then possible to access devices in this
address range.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cbusses.c   | 12 +++++++++---
 tools/i2cbusses.h   |  2 +-
 tools/i2cdump.c     |  5 +++--
 tools/i2cget.c      |  5 +++--
 tools/i2cset.c      |  5 +++--
 tools/i2ctransfer.c |  5 +++--
 6 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
index 41f5b6b..b0bcb26 100644
--- a/tools/i2cbusses.c
+++ b/tools/i2cbusses.c
@@ -377,19 +377,25 @@ int lookup_i2c_bus(const char *i2cbus_arg)
  * Parse a CHIP-ADDRESS command line argument and return the corresponding
  * chip address, or a negative value if the address is invalid.
  */
-int parse_i2c_address(const char *address_arg)
+int parse_i2c_address(const char *address_arg, int risky_addr)
 {
 	long address;
 	char *end;
+	long max_addr = 0x77;
 
 	address = strtol(address_arg, &end, 0);
 	if (*end || !*address_arg) {
 		fprintf(stderr, "Error: Chip address is not a number!\n");
 		return -1;
 	}
-	if (address < 0x03 || address > 0x77) {
+
+	if (risky_addr) {
+		max_addr = 0x7f;
+	}
+
+	if (address < 0x03 || address > max_addr) {
 		fprintf(stderr, "Error: Chip address out of range "
-			"(0x03-0x77)!\n");
+			"(0x03-0x%02x)!\n", max_addr);
 		return -2;
 	}
 
diff --git a/tools/i2cbusses.h b/tools/i2cbusses.h
index 26143a5..81ff983 100644
--- a/tools/i2cbusses.h
+++ b/tools/i2cbusses.h
@@ -35,7 +35,7 @@ struct i2c_adap *gather_i2c_busses(void);
 void free_adapters(struct i2c_adap *adapters);
 
 int lookup_i2c_bus(const char *i2cbus_arg);
-int parse_i2c_address(const char *address_arg);
+int parse_i2c_address(const char *address_arg, int risky_addr);
 int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet);
 int set_slave_addr(int file, int address, int force);
 
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index a7bba72..be0d93f 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
 	int block[256], s_length = 0;
 	int pec = 0, even = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, risky_addr = 0;
 	const char *range = NULL;
 	int first = 0x00, last = 0xff;
 
@@ -130,6 +130,7 @@ int main(int argc, char *argv[])
 		case 'f': force = 1; break;
 		case 'r': range = argv[1+(++flags)]; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -160,7 +161,7 @@ int main(int argc, char *argv[])
 		help();
 		exit(1);
 	}
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0) {
 		help();
 		exit(1);
diff --git a/tools/i2cget.c b/tools/i2cget.c
index 2503942..acc5236 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, risky_addr = 0;
 
 	/* handle (optional) flags first */
 	while (1+flags < argc && argv[1+flags][0] == '-') {
@@ -166,6 +166,7 @@ int main(int argc, char *argv[])
 		case 'V': version = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -187,7 +188,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 0ccc1a0..87c8cf3 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0, readback = 0;
+	int force = 0, yes = 0, version = 0, readback = 0, risky_addr = 0;
 	unsigned char block[I2C_SMBUS_BLOCK_MAX];
 	int len;
 
@@ -179,6 +179,7 @@ int main(int argc, char *argv[])
 			flags++;
 			break;
 		case 'r': readback = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -200,7 +201,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 38b6b4a..e6e9f0a 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
 {
 	char filename[20];
 	int i2cbus, address = -1, file, arg_idx = 1, nmsgs = 0, nmsgs_sent, i;
-	int force = 0, yes = 0, version = 0, verbose = 0;
+	int force = 0, yes = 0, version = 0, verbose = 0, risky_addr = 0;
 	struct i2c_msg msgs[I2C_RDRW_IOCTL_MAX_MSGS];
 	enum parse_state state = PARSE_GET_DESC;
 	unsigned buf_idx = 0;
@@ -139,6 +139,7 @@ int main(int argc, char *argv[])
 		case 'v': verbose = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option \"%s\"!\n",
 				argv[arg_idx]);
@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
 				 */
 
 				if (!force) {
-					address = parse_i2c_address(arg_ptr);
+					address = parse_i2c_address(arg_ptr, risky_addr);
 					if (address < 0)
 						goto err_out_with_arg;
 
-- 
2.11.0

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

* [PATCH 2/3] Update help message for risky_addr option
  2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
  2018-01-05 15:02 ` [PATCH 1/3] Add risky_addr option for i2c tools Romain Porte
@ 2018-01-05 15:02 ` Romain Porte
  2018-01-05 15:02 ` [PATCH 3/3] Update man pages for risky_addr Romain Porte
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-05 15:02 UTC (permalink / raw)
  To: linux-i2c; +Cc: jdelvare, Romain Porte

Add [-a] option to short help message of i2c tools. This is the option
that the user needs to activate for using the risky_addr feature.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.c     | 2 +-
 tools/i2cget.c      | 2 +-
 tools/i2cset.c      | 2 +-
 tools/i2ctransfer.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index be0d93f..733edaa 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -36,7 +36,7 @@
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
+		"Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  ADDRESS is an integer (0x03 - 0x77)\n"
 		"  MODE is one of:\n"
diff --git a/tools/i2cget.c b/tools/i2cget.c
index acc5236..6660991 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -41,7 +41,7 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
+		"Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  ADDRESS is an integer (0x03 - 0x77)\n"
 		"  MODE is one of:\n"
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 87c8cf3..5c3d6d7 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -38,7 +38,7 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
+		"Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  ADDRESS is an integer (0x03 - 0x77)\n"
 		"  MODE is one of:\n"
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index e6e9f0a..256fca7 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -42,7 +42,7 @@ enum parse_state {
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2ctransfer [-f] [-y] [-v] [-V] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
+		"Usage: i2ctransfer [-f] [-y] [-v] [-V] [-a] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  DESC describes the transfer in the form: {r|w}LENGTH[@address]\n"
 		"    1) read/write-flag 2) LENGTH (range 0-65535) 3) I2C address (use last one if omitted)\n"
-- 
2.11.0

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

* [PATCH 3/3] Update man pages for risky_addr
  2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
  2018-01-05 15:02 ` [PATCH 1/3] Add risky_addr option for i2c tools Romain Porte
  2018-01-05 15:02 ` [PATCH 2/3] Update help message for risky_addr option Romain Porte
@ 2018-01-05 15:02 ` Romain Porte
  2018-01-26 18:03 ` Patch proposal for risky i2c addresses in i2c-tools Wolfram Sang
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-05 15:02 UTC (permalink / raw)
  To: linux-i2c; +Cc: jdelvare, Romain Porte

Describe the new -a option in man pages of modified tools.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.8     | 4 ++++
 tools/i2cget.8      | 4 ++++
 tools/i2cset.8      | 4 ++++
 tools/i2ctransfer.8 | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/tools/i2cdump.8 b/tools/i2cdump.8
index fb7217e..22b12e3 100644
--- a/tools/i2cdump.8
+++ b/tools/i2cdump.8
@@ -7,6 +7,7 @@ i2cdump \- examine I2C registers
 .RB [ -f ]
 .RB [ "-r first-last" ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I address
 .RI [ "mode " [ "bank " [ bankreg ]]]
@@ -40,6 +41,9 @@ Disable interactive mode. By default, i2cdump will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts.
+.TP
+.B -a
+Allow using risky addresses between 0x78 and 0x7f. Not recommended.
 .PP
 At least two options must be provided to i2cdump. \fIi2cbus\fR indicates the
 number or name of the I2C bus to be scanned. This number should correspond to one
diff --git a/tools/i2cget.8 b/tools/i2cget.8
index a1a1276..e3117c0 100644
--- a/tools/i2cget.8
+++ b/tools/i2cget.8
@@ -6,6 +6,7 @@ i2cget \- read from I2C/SMBus chip registers
 .B i2cget
 .RB [ -f ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .RI [ "data-address " [ mode ]]
@@ -34,6 +35,9 @@ Disable interactive mode. By default, i2cget will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts. Use with caution.
+.TP
+.B -a
+Allow using risky addresses between 0x78 and 0x7f. Not recommended.
 .PP
 There are two required options to i2cget. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2cset.8 b/tools/i2cset.8
index 19887bd..e3c53dc 100644
--- a/tools/i2cset.8
+++ b/tools/i2cset.8
@@ -8,6 +8,7 @@ i2cset \- set I2C registers
 .RB [ -y ]
 .RB [ "-m mask" ]
 .RB [ -r ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .I data-address
@@ -54,6 +55,9 @@ be the case, as neither I2C nor SMBus guarantees this.
 Read back the value right after writing it, and compare the result with the
 value written. This used to be the default behavior. The same limitations
 apply as those of option \fB-m\fR.
+.TP
+.B -a
+Allow using risky addresses between 0x78 and 0x7f. Not recommended.
 .PP
 There are three required options to i2cset. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8
index 0dd43c9..a0727d9 100644
--- a/tools/i2ctransfer.8
+++ b/tools/i2ctransfer.8
@@ -7,6 +7,7 @@ i2ctransfer \- send user-defined I2C messages in one transfer
 .RB [ -f ]
 .RB [ -y ]
 .RB [ -v ]
+.RB [ -a ]
 .I i2cbus desc
 .RI [ data ]
 .RI [ desc
@@ -61,6 +62,9 @@ It will print infos about all messages sent, i.e. not only for read messages but
 .TP
 .B -V
 Display the version and exit.
+.TP
+.B -a
+Allow using risky addresses between 0x78 and 0x7f. Not recommended.
 
 .SH ARGUMENTS
 .PP
-- 
2.11.0

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

* Re: Patch proposal for risky i2c addresses in i2c-tools
  2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
                   ` (2 preceding siblings ...)
  2018-01-05 15:02 ` [PATCH 3/3] Update man pages for risky_addr Romain Porte
@ 2018-01-26 18:03 ` Wolfram Sang
  2018-01-29 12:26   ` Romain Porte
  2018-01-29 12:40 ` New patchset for risky addr, with lower bound support Romain Porte
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Wolfram Sang @ 2018-01-26 18:03 UTC (permalink / raw)
  To: Romain Porte; +Cc: linux-i2c, jdelvare

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

Hi Romain,

> This patchset proposes a new option for risky i2c addresses between 0x78
> and 0x7f that are currently disabled. This behavior is marked as not
> recommended, but is sometimes needed if you have a device using an
> address in this range.

Yes, meanwhile I also have a board using addresses 0x7c and 0x7f.

> It was inspired by an email from Wolfram Sang [1] that encouraged to add
> this option for using i2c-tools with devices using this address range.

This handles only part of the risky addresses. I once worked on a device
having an EEPROM using 32(!) addresses in the range from 0x00(!!)-0x1f.
And yes, because it was the only device on the bus, that actually worked.

So, the lower boundary should also be removed IMO.

And I'd much prefer a flag like 'R' which represents 'risky' better.

Thanks for doing this!

   Wolfram


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

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

* Re: Patch proposal for risky i2c addresses in i2c-tools
  2018-01-26 18:03 ` Patch proposal for risky i2c addresses in i2c-tools Wolfram Sang
@ 2018-01-29 12:26   ` Romain Porte
  2018-01-29 13:39     ` Peter Rosin
  0 siblings, 1 reply; 20+ messages in thread
From: Romain Porte @ 2018-01-29 12:26 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, jdelvare

Hello Wolfram,

On 26/01/2018 19:03, Wolfram Sang wrote:
> This handles only part of the risky addresses. I once worked on a device
> having an EEPROM using 32(!) addresses in the range from 0x00(!!)-0x1f.
> And yes, because it was the only device on the bus, that actually worked.
>
> So, the lower boundary should also be removed IMO.

Good to know, I will send a new patchset which takes the lower bound 
into account.

> And I'd much prefer a flag like 'R' which represents 'risky' better.

I disagree here, the i2cdetect program is already using the '-a' option 
for scanning risky addresses. I think we should keep consistency between 
options and keep this option named '-a' for the other tools. As per 
i2cdetect's man page:

-a    Force scanning of non-regular addresses. Not recommended

Best regards,

Romain.

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

* New patchset for risky addr, with lower bound support
  2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
                   ` (3 preceding siblings ...)
  2018-01-26 18:03 ` Patch proposal for risky i2c addresses in i2c-tools Wolfram Sang
@ 2018-01-29 12:40 ` Romain Porte
  2018-01-29 12:40   ` [PATCH v2 1/3] Add risky_addr option for i2c tools Romain Porte
                     ` (2 more replies)
  2018-01-29 13:57 ` Patch proposal for risky addr, with updated help messages Romain Porte
  2018-02-02 12:45 ` Patch proposal for using all addresses in i2c-tools Romain Porte
  6 siblings, 3 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-29 12:40 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, linux-i2c

New patchset proposal with Wolfram's suggestions for
supporting risky lower-bound addresses too.

Changes from previous patchset:

 - Updated code for lower bound support from 0x00 to 0x02
 - Updated man pages for lower bound support
 - Fixed GCC warning: use %lx for long intead of %x

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

* [PATCH v2 1/3] Add risky_addr option for i2c tools
  2018-01-29 12:40 ` New patchset for risky addr, with lower bound support Romain Porte
@ 2018-01-29 12:40   ` Romain Porte
  2018-01-29 12:40   ` [PATCH v2 2/3] Update help message for risky_addr option Romain Porte
  2018-01-29 12:40   ` [PATCH v2 3/3] Update man pages for risky_addr Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-29 12:40 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, linux-i2c, Romain Porte

If the user is sure that the reserved 0x77 - 0x7f range is not needed by
its devices, then he can pass the "-a" option for allowing so called
"risky addresses". It is then possible to access devices in this
address range. It also allows addresses < 0x03.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cbusses.c   | 14 +++++++++++---
 tools/i2cbusses.h   |  2 +-
 tools/i2cdump.c     |  5 +++--
 tools/i2cget.c      |  5 +++--
 tools/i2cset.c      |  5 +++--
 tools/i2ctransfer.c |  5 +++--
 6 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
index 41f5b6b..bdc4791 100644
--- a/tools/i2cbusses.c
+++ b/tools/i2cbusses.c
@@ -377,19 +377,27 @@ int lookup_i2c_bus(const char *i2cbus_arg)
  * Parse a CHIP-ADDRESS command line argument and return the corresponding
  * chip address, or a negative value if the address is invalid.
  */
-int parse_i2c_address(const char *address_arg)
+int parse_i2c_address(const char *address_arg, int risky_addr)
 {
 	long address;
 	char *end;
+	long min_addr = 0x03;
+	long max_addr = 0x77;
 
 	address = strtol(address_arg, &end, 0);
 	if (*end || !*address_arg) {
 		fprintf(stderr, "Error: Chip address is not a number!\n");
 		return -1;
 	}
-	if (address < 0x03 || address > 0x77) {
+
+	if (risky_addr) {
+		min_addr = 0x00;
+		max_addr = 0x7f;
+	}
+
+	if (address < min_addr || address > max_addr) {
 		fprintf(stderr, "Error: Chip address out of range "
-			"(0x03-0x77)!\n");
+			"(0x%02lx-0x%02lx)!\n", min_addr, max_addr);
 		return -2;
 	}
 
diff --git a/tools/i2cbusses.h b/tools/i2cbusses.h
index 26143a5..81ff983 100644
--- a/tools/i2cbusses.h
+++ b/tools/i2cbusses.h
@@ -35,7 +35,7 @@ struct i2c_adap *gather_i2c_busses(void);
 void free_adapters(struct i2c_adap *adapters);
 
 int lookup_i2c_bus(const char *i2cbus_arg);
-int parse_i2c_address(const char *address_arg);
+int parse_i2c_address(const char *address_arg, int risky_addr);
 int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet);
 int set_slave_addr(int file, int address, int force);
 
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index a7bba72..be0d93f 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
 	int block[256], s_length = 0;
 	int pec = 0, even = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, risky_addr = 0;
 	const char *range = NULL;
 	int first = 0x00, last = 0xff;
 
@@ -130,6 +130,7 @@ int main(int argc, char *argv[])
 		case 'f': force = 1; break;
 		case 'r': range = argv[1+(++flags)]; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -160,7 +161,7 @@ int main(int argc, char *argv[])
 		help();
 		exit(1);
 	}
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0) {
 		help();
 		exit(1);
diff --git a/tools/i2cget.c b/tools/i2cget.c
index 2503942..acc5236 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, risky_addr = 0;
 
 	/* handle (optional) flags first */
 	while (1+flags < argc && argv[1+flags][0] == '-') {
@@ -166,6 +166,7 @@ int main(int argc, char *argv[])
 		case 'V': version = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -187,7 +188,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 0ccc1a0..87c8cf3 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0, readback = 0;
+	int force = 0, yes = 0, version = 0, readback = 0, risky_addr = 0;
 	unsigned char block[I2C_SMBUS_BLOCK_MAX];
 	int len;
 
@@ -179,6 +179,7 @@ int main(int argc, char *argv[])
 			flags++;
 			break;
 		case 'r': readback = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -200,7 +201,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 38b6b4a..e6e9f0a 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
 {
 	char filename[20];
 	int i2cbus, address = -1, file, arg_idx = 1, nmsgs = 0, nmsgs_sent, i;
-	int force = 0, yes = 0, version = 0, verbose = 0;
+	int force = 0, yes = 0, version = 0, verbose = 0, risky_addr = 0;
 	struct i2c_msg msgs[I2C_RDRW_IOCTL_MAX_MSGS];
 	enum parse_state state = PARSE_GET_DESC;
 	unsigned buf_idx = 0;
@@ -139,6 +139,7 @@ int main(int argc, char *argv[])
 		case 'v': verbose = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option \"%s\"!\n",
 				argv[arg_idx]);
@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
 				 */
 
 				if (!force) {
-					address = parse_i2c_address(arg_ptr);
+					address = parse_i2c_address(arg_ptr, risky_addr);
 					if (address < 0)
 						goto err_out_with_arg;
 
-- 
2.11.0

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

* [PATCH v2 2/3] Update help message for risky_addr option
  2018-01-29 12:40 ` New patchset for risky addr, with lower bound support Romain Porte
  2018-01-29 12:40   ` [PATCH v2 1/3] Add risky_addr option for i2c tools Romain Porte
@ 2018-01-29 12:40   ` Romain Porte
  2018-01-29 13:45     ` Peter Rosin
  2018-01-29 12:40   ` [PATCH v2 3/3] Update man pages for risky_addr Romain Porte
  2 siblings, 1 reply; 20+ messages in thread
From: Romain Porte @ 2018-01-29 12:40 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, linux-i2c, Romain Porte

Add [-a] option to short help message of i2c tools. This is the option
that the user needs to activate for using the risky_addr feature.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.c     | 2 +-
 tools/i2cget.c      | 2 +-
 tools/i2cset.c      | 2 +-
 tools/i2ctransfer.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index be0d93f..733edaa 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -36,7 +36,7 @@
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
+		"Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  ADDRESS is an integer (0x03 - 0x77)\n"
 		"  MODE is one of:\n"
diff --git a/tools/i2cget.c b/tools/i2cget.c
index acc5236..6660991 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -41,7 +41,7 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
+		"Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  ADDRESS is an integer (0x03 - 0x77)\n"
 		"  MODE is one of:\n"
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 87c8cf3..5c3d6d7 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -38,7 +38,7 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
+		"Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  ADDRESS is an integer (0x03 - 0x77)\n"
 		"  MODE is one of:\n"
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index e6e9f0a..256fca7 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -42,7 +42,7 @@ enum parse_state {
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2ctransfer [-f] [-y] [-v] [-V] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
+		"Usage: i2ctransfer [-f] [-y] [-v] [-V] [-a] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  DESC describes the transfer in the form: {r|w}LENGTH[@address]\n"
 		"    1) read/write-flag 2) LENGTH (range 0-65535) 3) I2C address (use last one if omitted)\n"
-- 
2.11.0

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

* [PATCH v2 3/3] Update man pages for risky_addr
  2018-01-29 12:40 ` New patchset for risky addr, with lower bound support Romain Porte
  2018-01-29 12:40   ` [PATCH v2 1/3] Add risky_addr option for i2c tools Romain Porte
  2018-01-29 12:40   ` [PATCH v2 2/3] Update help message for risky_addr option Romain Porte
@ 2018-01-29 12:40   ` Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-29 12:40 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, linux-i2c, Romain Porte

Describe the new -a option in man pages of modified tools.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.8     | 4 ++++
 tools/i2cget.8      | 4 ++++
 tools/i2cset.8      | 4 ++++
 tools/i2ctransfer.8 | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/tools/i2cdump.8 b/tools/i2cdump.8
index fb7217e..1b98b64 100644
--- a/tools/i2cdump.8
+++ b/tools/i2cdump.8
@@ -7,6 +7,7 @@ i2cdump \- examine I2C registers
 .RB [ -f ]
 .RB [ "-r first-last" ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I address
 .RI [ "mode " [ "bank " [ bankreg ]]]
@@ -40,6 +41,9 @@ Disable interactive mode. By default, i2cdump will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 At least two options must be provided to i2cdump. \fIi2cbus\fR indicates the
 number or name of the I2C bus to be scanned. This number should correspond to one
diff --git a/tools/i2cget.8 b/tools/i2cget.8
index a1a1276..26a0ea0 100644
--- a/tools/i2cget.8
+++ b/tools/i2cget.8
@@ -6,6 +6,7 @@ i2cget \- read from I2C/SMBus chip registers
 .B i2cget
 .RB [ -f ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .RI [ "data-address " [ mode ]]
@@ -34,6 +35,9 @@ Disable interactive mode. By default, i2cget will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts. Use with caution.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 There are two required options to i2cget. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2cset.8 b/tools/i2cset.8
index 19887bd..4faa061 100644
--- a/tools/i2cset.8
+++ b/tools/i2cset.8
@@ -8,6 +8,7 @@ i2cset \- set I2C registers
 .RB [ -y ]
 .RB [ "-m mask" ]
 .RB [ -r ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .I data-address
@@ -54,6 +55,9 @@ be the case, as neither I2C nor SMBus guarantees this.
 Read back the value right after writing it, and compare the result with the
 value written. This used to be the default behavior. The same limitations
 apply as those of option \fB-m\fR.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 There are three required options to i2cset. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8
index 0dd43c9..cf8dae7 100644
--- a/tools/i2ctransfer.8
+++ b/tools/i2ctransfer.8
@@ -7,6 +7,7 @@ i2ctransfer \- send user-defined I2C messages in one transfer
 .RB [ -f ]
 .RB [ -y ]
 .RB [ -v ]
+.RB [ -a ]
 .I i2cbus desc
 .RI [ data ]
 .RI [ desc
@@ -61,6 +62,9 @@ It will print infos about all messages sent, i.e. not only for read messages but
 .TP
 .B -V
 Display the version and exit.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 
 .SH ARGUMENTS
 .PP
-- 
2.11.0

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

* Re: Patch proposal for risky i2c addresses in i2c-tools
  2018-01-29 12:26   ` Romain Porte
@ 2018-01-29 13:39     ` Peter Rosin
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Rosin @ 2018-01-29 13:39 UTC (permalink / raw)
  To: Romain Porte, Wolfram Sang; +Cc: linux-i2c, jdelvare

On 2018-01-29 13:26, Romain Porte wrote:
> Hello Wolfram,
> 
> On 26/01/2018 19:03, Wolfram Sang wrote:
>> This handles only part of the risky addresses. I once worked on a device
>> having an EEPROM using 32(!) addresses in the range from 0x00(!!)-0x1f.
>> And yes, because it was the only device on the bus, that actually worked.
>>
>> So, the lower boundary should also be removed IMO.
> 
> Good to know, I will send a new patchset which takes the lower bound 
> into account.
> 
>> And I'd much prefer a flag like 'R' which represents 'risky' better.
> 
> I disagree here, the i2cdetect program is already using the '-a' option 
> for scanning risky addresses. I think we should keep consistency between 
> options and keep this option named '-a' for the other tools. As per 
> i2cdetect's man page:
> 
> -a    Force scanning of non-regular addresses. Not recommended

However, you could rename the variables and rewrite the docs to put
more emphasis on "all" rather than "risky". Then it would be easier
to remember the short option.

$.02

Cheers,
Peter

> Best regards,
> 
> Romain.
> 

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

* Re: [PATCH v2 2/3] Update help message for risky_addr option
  2018-01-29 12:40   ` [PATCH v2 2/3] Update help message for risky_addr option Romain Porte
@ 2018-01-29 13:45     ` Peter Rosin
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Rosin @ 2018-01-29 13:45 UTC (permalink / raw)
  To: Romain Porte, wsa; +Cc: jdelvare, linux-i2c

On 2018-01-29 13:40, Romain Porte wrote:
> Add [-a] option to short help message of i2c tools. This is the option
> that the user needs to activate for using the risky_addr feature.
> 
> Signed-off-by: Romain Porte <romain.porte@nokia.com>
> ---
>  tools/i2cdump.c     | 2 +-
>  tools/i2cget.c      | 2 +-
>  tools/i2cset.c      | 2 +-
>  tools/i2ctransfer.c | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/i2cdump.c b/tools/i2cdump.c
> index be0d93f..733edaa 100644
> --- a/tools/i2cdump.c
> +++ b/tools/i2cdump.c
> @@ -36,7 +36,7 @@
>  static void help(void)
>  {
>  	fprintf(stderr,
> -		"Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
> +		"Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
>  		"  I2CBUS is an integer or an I2C bus name\n"
>  		"  ADDRESS is an integer (0x03 - 0x77)\n"

This is no longer entirely true; you might want to squeeze in something
about -a here. E.g.

		"  ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)\n"

And below for the other instances of course...

Cheers,
Peter

>  		"  MODE is one of:\n"
> diff --git a/tools/i2cget.c b/tools/i2cget.c
> index acc5236..6660991 100644
> --- a/tools/i2cget.c
> +++ b/tools/i2cget.c
> @@ -41,7 +41,7 @@ static void help(void) __attribute__ ((noreturn));
>  static void help(void)
>  {
>  	fprintf(stderr,
> -		"Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
> +		"Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
>  		"  I2CBUS is an integer or an I2C bus name\n"
>  		"  ADDRESS is an integer (0x03 - 0x77)\n"
>  		"  MODE is one of:\n"
> diff --git a/tools/i2cset.c b/tools/i2cset.c
> index 87c8cf3..5c3d6d7 100644
> --- a/tools/i2cset.c
> +++ b/tools/i2cset.c
> @@ -38,7 +38,7 @@ static void help(void) __attribute__ ((noreturn));
>  static void help(void)
>  {
>  	fprintf(stderr,
> -		"Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
> +		"Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
>  		"  I2CBUS is an integer or an I2C bus name\n"
>  		"  ADDRESS is an integer (0x03 - 0x77)\n"
>  		"  MODE is one of:\n"
> diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
> index e6e9f0a..256fca7 100644
> --- a/tools/i2ctransfer.c
> +++ b/tools/i2ctransfer.c
> @@ -42,7 +42,7 @@ enum parse_state {
>  static void help(void)
>  {
>  	fprintf(stderr,
> -		"Usage: i2ctransfer [-f] [-y] [-v] [-V] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
> +		"Usage: i2ctransfer [-f] [-y] [-v] [-V] [-a] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
>  		"  I2CBUS is an integer or an I2C bus name\n"
>  		"  DESC describes the transfer in the form: {r|w}LENGTH[@address]\n"
>  		"    1) read/write-flag 2) LENGTH (range 0-65535) 3) I2C address (use last one if omitted)\n"
> 

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

* Patch proposal for risky addr, with updated help messages
  2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
                   ` (4 preceding siblings ...)
  2018-01-29 12:40 ` New patchset for risky addr, with lower bound support Romain Porte
@ 2018-01-29 13:57 ` Romain Porte
  2018-01-29 13:57   ` [PATCH v3 1/3] Add risky_addr option for i2c tools Romain Porte
                     ` (2 more replies)
  2018-02-02 12:45 ` Patch proposal for using all addresses in i2c-tools Romain Porte
  6 siblings, 3 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-29 13:57 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c

Nice remark from Peter Rosin about not updated help messages.
I however did not update the i2ctransfert help message due to
no mention to i2c address limits in the original help message.

Changes from PATCH v2:

 - Updated help messages in tools in order to see -a influence
   where explicit i2c limits are mentionned to the user.

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

* [PATCH v3 1/3] Add risky_addr option for i2c tools
  2018-01-29 13:57 ` Patch proposal for risky addr, with updated help messages Romain Porte
@ 2018-01-29 13:57   ` Romain Porte
  2018-01-29 13:57   ` [PATCH v3 2/3] Update help message for risky_addr option Romain Porte
  2018-01-29 13:57   ` [PATCH v3 3/3] Update man pages for risky_addr Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-29 13:57 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c, Romain Porte

If the user is sure that the reserved 0x77 - 0x7f range is not needed by
its devices, then he can pass the "-a" option for allowing so called
"risky addresses". It is then possible to access devices in this
address range. It also allows addresses < 0x03.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cbusses.c   | 14 +++++++++++---
 tools/i2cbusses.h   |  2 +-
 tools/i2cdump.c     |  5 +++--
 tools/i2cget.c      |  5 +++--
 tools/i2cset.c      |  5 +++--
 tools/i2ctransfer.c |  5 +++--
 6 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
index 41f5b6b..bdc4791 100644
--- a/tools/i2cbusses.c
+++ b/tools/i2cbusses.c
@@ -377,19 +377,27 @@ int lookup_i2c_bus(const char *i2cbus_arg)
  * Parse a CHIP-ADDRESS command line argument and return the corresponding
  * chip address, or a negative value if the address is invalid.
  */
-int parse_i2c_address(const char *address_arg)
+int parse_i2c_address(const char *address_arg, int risky_addr)
 {
 	long address;
 	char *end;
+	long min_addr = 0x03;
+	long max_addr = 0x77;
 
 	address = strtol(address_arg, &end, 0);
 	if (*end || !*address_arg) {
 		fprintf(stderr, "Error: Chip address is not a number!\n");
 		return -1;
 	}
-	if (address < 0x03 || address > 0x77) {
+
+	if (risky_addr) {
+		min_addr = 0x00;
+		max_addr = 0x7f;
+	}
+
+	if (address < min_addr || address > max_addr) {
 		fprintf(stderr, "Error: Chip address out of range "
-			"(0x03-0x77)!\n");
+			"(0x%02lx-0x%02lx)!\n", min_addr, max_addr);
 		return -2;
 	}
 
diff --git a/tools/i2cbusses.h b/tools/i2cbusses.h
index 26143a5..81ff983 100644
--- a/tools/i2cbusses.h
+++ b/tools/i2cbusses.h
@@ -35,7 +35,7 @@ struct i2c_adap *gather_i2c_busses(void);
 void free_adapters(struct i2c_adap *adapters);
 
 int lookup_i2c_bus(const char *i2cbus_arg);
-int parse_i2c_address(const char *address_arg);
+int parse_i2c_address(const char *address_arg, int risky_addr);
 int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet);
 int set_slave_addr(int file, int address, int force);
 
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index a7bba72..be0d93f 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
 	int block[256], s_length = 0;
 	int pec = 0, even = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, risky_addr = 0;
 	const char *range = NULL;
 	int first = 0x00, last = 0xff;
 
@@ -130,6 +130,7 @@ int main(int argc, char *argv[])
 		case 'f': force = 1; break;
 		case 'r': range = argv[1+(++flags)]; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -160,7 +161,7 @@ int main(int argc, char *argv[])
 		help();
 		exit(1);
 	}
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0) {
 		help();
 		exit(1);
diff --git a/tools/i2cget.c b/tools/i2cget.c
index 2503942..acc5236 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, risky_addr = 0;
 
 	/* handle (optional) flags first */
 	while (1+flags < argc && argv[1+flags][0] == '-') {
@@ -166,6 +166,7 @@ int main(int argc, char *argv[])
 		case 'V': version = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -187,7 +188,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 0ccc1a0..87c8cf3 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0, readback = 0;
+	int force = 0, yes = 0, version = 0, readback = 0, risky_addr = 0;
 	unsigned char block[I2C_SMBUS_BLOCK_MAX];
 	int len;
 
@@ -179,6 +179,7 @@ int main(int argc, char *argv[])
 			flags++;
 			break;
 		case 'r': readback = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -200,7 +201,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], risky_addr);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 38b6b4a..e6e9f0a 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
 {
 	char filename[20];
 	int i2cbus, address = -1, file, arg_idx = 1, nmsgs = 0, nmsgs_sent, i;
-	int force = 0, yes = 0, version = 0, verbose = 0;
+	int force = 0, yes = 0, version = 0, verbose = 0, risky_addr = 0;
 	struct i2c_msg msgs[I2C_RDRW_IOCTL_MAX_MSGS];
 	enum parse_state state = PARSE_GET_DESC;
 	unsigned buf_idx = 0;
@@ -139,6 +139,7 @@ int main(int argc, char *argv[])
 		case 'v': verbose = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': risky_addr = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option \"%s\"!\n",
 				argv[arg_idx]);
@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
 				 */
 
 				if (!force) {
-					address = parse_i2c_address(arg_ptr);
+					address = parse_i2c_address(arg_ptr, risky_addr);
 					if (address < 0)
 						goto err_out_with_arg;
 
-- 
2.11.0

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

* [PATCH v3 2/3] Update help message for risky_addr option
  2018-01-29 13:57 ` Patch proposal for risky addr, with updated help messages Romain Porte
  2018-01-29 13:57   ` [PATCH v3 1/3] Add risky_addr option for i2c tools Romain Porte
@ 2018-01-29 13:57   ` Romain Porte
  2018-01-29 13:57   ` [PATCH v3 3/3] Update man pages for risky_addr Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-29 13:57 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c, Romain Porte

Add [-a] option to short help message of i2c tools. This is the option
that the user needs to activate for using the risky_addr feature.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.c     | 4 ++--
 tools/i2cget.c      | 4 ++--
 tools/i2cset.c      | 4 ++--
 tools/i2ctransfer.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index be0d93f..3bd6d39 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -36,9 +36,9 @@
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
+		"Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
-		"  ADDRESS is an integer (0x03 - 0x77)\n"
+		"  ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)\n"
 		"  MODE is one of:\n"
 		"    b (byte, default)\n"
 		"    w (word)\n"
diff --git a/tools/i2cget.c b/tools/i2cget.c
index acc5236..9aa2d01 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -41,9 +41,9 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
+		"Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
-		"  ADDRESS is an integer (0x03 - 0x77)\n"
+		"  ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)\n"
 		"  MODE is one of:\n"
 		"    b (read byte data, default)\n"
 		"    w (read word data)\n"
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 87c8cf3..7e9984e 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -38,9 +38,9 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
+		"Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
-		"  ADDRESS is an integer (0x03 - 0x77)\n"
+		"  ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)\n"
 		"  MODE is one of:\n"
 		"    c (byte, no value)\n"
 		"    b (byte data, default)\n"
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index e6e9f0a..256fca7 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -42,7 +42,7 @@ enum parse_state {
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2ctransfer [-f] [-y] [-v] [-V] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
+		"Usage: i2ctransfer [-f] [-y] [-v] [-V] [-a] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  DESC describes the transfer in the form: {r|w}LENGTH[@address]\n"
 		"    1) read/write-flag 2) LENGTH (range 0-65535) 3) I2C address (use last one if omitted)\n"
-- 
2.11.0

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

* [PATCH v3 3/3] Update man pages for risky_addr
  2018-01-29 13:57 ` Patch proposal for risky addr, with updated help messages Romain Porte
  2018-01-29 13:57   ` [PATCH v3 1/3] Add risky_addr option for i2c tools Romain Porte
  2018-01-29 13:57   ` [PATCH v3 2/3] Update help message for risky_addr option Romain Porte
@ 2018-01-29 13:57   ` Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-01-29 13:57 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c, Romain Porte

Describe the new -a option in man pages of modified tools.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.8     | 4 ++++
 tools/i2cget.8      | 4 ++++
 tools/i2cset.8      | 4 ++++
 tools/i2ctransfer.8 | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/tools/i2cdump.8 b/tools/i2cdump.8
index fb7217e..1b98b64 100644
--- a/tools/i2cdump.8
+++ b/tools/i2cdump.8
@@ -7,6 +7,7 @@ i2cdump \- examine I2C registers
 .RB [ -f ]
 .RB [ "-r first-last" ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I address
 .RI [ "mode " [ "bank " [ bankreg ]]]
@@ -40,6 +41,9 @@ Disable interactive mode. By default, i2cdump will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 At least two options must be provided to i2cdump. \fIi2cbus\fR indicates the
 number or name of the I2C bus to be scanned. This number should correspond to one
diff --git a/tools/i2cget.8 b/tools/i2cget.8
index a1a1276..26a0ea0 100644
--- a/tools/i2cget.8
+++ b/tools/i2cget.8
@@ -6,6 +6,7 @@ i2cget \- read from I2C/SMBus chip registers
 .B i2cget
 .RB [ -f ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .RI [ "data-address " [ mode ]]
@@ -34,6 +35,9 @@ Disable interactive mode. By default, i2cget will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts. Use with caution.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 There are two required options to i2cget. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2cset.8 b/tools/i2cset.8
index 19887bd..4faa061 100644
--- a/tools/i2cset.8
+++ b/tools/i2cset.8
@@ -8,6 +8,7 @@ i2cset \- set I2C registers
 .RB [ -y ]
 .RB [ "-m mask" ]
 .RB [ -r ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .I data-address
@@ -54,6 +55,9 @@ be the case, as neither I2C nor SMBus guarantees this.
 Read back the value right after writing it, and compare the result with the
 value written. This used to be the default behavior. The same limitations
 apply as those of option \fB-m\fR.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 There are three required options to i2cset. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8
index 0dd43c9..cf8dae7 100644
--- a/tools/i2ctransfer.8
+++ b/tools/i2ctransfer.8
@@ -7,6 +7,7 @@ i2ctransfer \- send user-defined I2C messages in one transfer
 .RB [ -f ]
 .RB [ -y ]
 .RB [ -v ]
+.RB [ -a ]
 .I i2cbus desc
 .RI [ data ]
 .RI [ desc
@@ -61,6 +62,9 @@ It will print infos about all messages sent, i.e. not only for read messages but
 .TP
 .B -V
 Display the version and exit.
+.TP
+.B -a
+Allow using risky addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 
 .SH ARGUMENTS
 .PP
-- 
2.11.0

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

* Patch proposal for using all addresses in i2c-tools
  2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
                   ` (5 preceding siblings ...)
  2018-01-29 13:57 ` Patch proposal for risky addr, with updated help messages Romain Porte
@ 2018-02-02 12:45 ` Romain Porte
  2018-02-02 12:45   ` [PATCH v4 1/3] Add all_addrs option for i2c tools Romain Porte
                     ` (2 more replies)
  6 siblings, 3 replies; 20+ messages in thread
From: Romain Porte @ 2018-02-02 12:45 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c

This new patchset mainly removes any references to 'risky' addresses,
but uses the 'all' addresses instead. This reflects the name of the
chosen '-a' option that is already present in i2cdetect.

Changes from previous version:

 - Use 'all_addrs' name instead of 'risky_addr'
 - Remove 'risky' mentions in man pages
 - Remove 'risky' mentions in commits

Please review.

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

* [PATCH v4 1/3] Add all_addrs option for i2c tools
  2018-02-02 12:45 ` Patch proposal for using all addresses in i2c-tools Romain Porte
@ 2018-02-02 12:45   ` Romain Porte
  2018-02-02 12:45   ` [PATCH v4 2/3] Update help message for all_addrs option Romain Porte
  2018-02-02 12:45   ` [PATCH v4 3/3] Update man pages for all_addrs Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-02-02 12:45 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c, Romain Porte

If the user is sure that the reserved 0x00 - 0x02 and 0x77 - 0x7f ranges are
not needed by its devices, then he can pass the "-a" option for allowing all
theorical addresses to be used. It is then possible to access devices in this
address range.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cbusses.c   | 14 +++++++++++---
 tools/i2cbusses.h   |  2 +-
 tools/i2cdump.c     |  5 +++--
 tools/i2cget.c      |  5 +++--
 tools/i2cset.c      |  5 +++--
 tools/i2ctransfer.c |  5 +++--
 6 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
index 41f5b6b..ad06332 100644
--- a/tools/i2cbusses.c
+++ b/tools/i2cbusses.c
@@ -377,19 +377,27 @@ int lookup_i2c_bus(const char *i2cbus_arg)
  * Parse a CHIP-ADDRESS command line argument and return the corresponding
  * chip address, or a negative value if the address is invalid.
  */
-int parse_i2c_address(const char *address_arg)
+int parse_i2c_address(const char *address_arg, int all_addrs)
 {
 	long address;
 	char *end;
+	long min_addr = 0x03;
+	long max_addr = 0x77;
 
 	address = strtol(address_arg, &end, 0);
 	if (*end || !*address_arg) {
 		fprintf(stderr, "Error: Chip address is not a number!\n");
 		return -1;
 	}
-	if (address < 0x03 || address > 0x77) {
+
+	if (all_addrs) {
+		min_addr = 0x00;
+		max_addr = 0x7f;
+	}
+
+	if (address < min_addr || address > max_addr) {
 		fprintf(stderr, "Error: Chip address out of range "
-			"(0x03-0x77)!\n");
+			"(0x%02lx-0x%02lx)!\n", min_addr, max_addr);
 		return -2;
 	}
 
diff --git a/tools/i2cbusses.h b/tools/i2cbusses.h
index 26143a5..a192c7f 100644
--- a/tools/i2cbusses.h
+++ b/tools/i2cbusses.h
@@ -35,7 +35,7 @@ struct i2c_adap *gather_i2c_busses(void);
 void free_adapters(struct i2c_adap *adapters);
 
 int lookup_i2c_bus(const char *i2cbus_arg);
-int parse_i2c_address(const char *address_arg);
+int parse_i2c_address(const char *address_arg, int all_addrs);
 int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet);
 int set_slave_addr(int file, int address, int force);
 
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index a7bba72..567ef03 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
 	int block[256], s_length = 0;
 	int pec = 0, even = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, all_addrs = 0;
 	const char *range = NULL;
 	int first = 0x00, last = 0xff;
 
@@ -130,6 +130,7 @@ int main(int argc, char *argv[])
 		case 'f': force = 1; break;
 		case 'r': range = argv[1+(++flags)]; break;
 		case 'y': yes = 1; break;
+		case 'a': all_addrs = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -160,7 +161,7 @@ int main(int argc, char *argv[])
 		help();
 		exit(1);
 	}
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], all_addrs);
 	if (address < 0) {
 		help();
 		exit(1);
diff --git a/tools/i2cget.c b/tools/i2cget.c
index 2503942..34b4af1 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0;
+	int force = 0, yes = 0, version = 0, all_addrs = 0;
 
 	/* handle (optional) flags first */
 	while (1+flags < argc && argv[1+flags][0] == '-') {
@@ -166,6 +166,7 @@ int main(int argc, char *argv[])
 		case 'V': version = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': all_addrs = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -187,7 +188,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], all_addrs);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 0ccc1a0..e250837 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
 	char filename[20];
 	int pec = 0;
 	int flags = 0;
-	int force = 0, yes = 0, version = 0, readback = 0;
+	int force = 0, yes = 0, version = 0, readback = 0, all_addrs = 0;
 	unsigned char block[I2C_SMBUS_BLOCK_MAX];
 	int len;
 
@@ -179,6 +179,7 @@ int main(int argc, char *argv[])
 			flags++;
 			break;
 		case 'r': readback = 1; break;
+		case 'a': all_addrs = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option "
 				"\"%s\"!\n", argv[1+flags]);
@@ -200,7 +201,7 @@ int main(int argc, char *argv[])
 	if (i2cbus < 0)
 		help();
 
-	address = parse_i2c_address(argv[flags+2]);
+	address = parse_i2c_address(argv[flags+2], all_addrs);
 	if (address < 0)
 		help();
 
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 38b6b4a..0dce067 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
 {
 	char filename[20];
 	int i2cbus, address = -1, file, arg_idx = 1, nmsgs = 0, nmsgs_sent, i;
-	int force = 0, yes = 0, version = 0, verbose = 0;
+	int force = 0, yes = 0, version = 0, verbose = 0, all_addrs = 0;
 	struct i2c_msg msgs[I2C_RDRW_IOCTL_MAX_MSGS];
 	enum parse_state state = PARSE_GET_DESC;
 	unsigned buf_idx = 0;
@@ -139,6 +139,7 @@ int main(int argc, char *argv[])
 		case 'v': verbose = 1; break;
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
+		case 'a': all_addrs = 1; break;
 		default:
 			fprintf(stderr, "Error: Unsupported option \"%s\"!\n",
 				argv[arg_idx]);
@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
 				 */
 
 				if (!force) {
-					address = parse_i2c_address(arg_ptr);
+					address = parse_i2c_address(arg_ptr, all_addrs);
 					if (address < 0)
 						goto err_out_with_arg;
 
-- 
2.11.0

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

* [PATCH v4 2/3] Update help message for all_addrs option
  2018-02-02 12:45 ` Patch proposal for using all addresses in i2c-tools Romain Porte
  2018-02-02 12:45   ` [PATCH v4 1/3] Add all_addrs option for i2c tools Romain Porte
@ 2018-02-02 12:45   ` Romain Porte
  2018-02-02 12:45   ` [PATCH v4 3/3] Update man pages for all_addrs Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-02-02 12:45 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c, Romain Porte

Add [-a] option to short help message of i2c tools. This is the option
that the user needs to activate for using the all_addrs feature.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.c     | 4 ++--
 tools/i2cget.c      | 4 ++--
 tools/i2cset.c      | 4 ++--
 tools/i2ctransfer.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index 567ef03..3bd2077 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -36,9 +36,9 @@
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
+		"Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
-		"  ADDRESS is an integer (0x03 - 0x77)\n"
+		"  ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)\n"
 		"  MODE is one of:\n"
 		"    b (byte, default)\n"
 		"    w (word)\n"
diff --git a/tools/i2cget.c b/tools/i2cget.c
index 34b4af1..d2ed56a 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -41,9 +41,9 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
+		"Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
-		"  ADDRESS is an integer (0x03 - 0x77)\n"
+		"  ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)\n"
 		"  MODE is one of:\n"
 		"    b (read byte data, default)\n"
 		"    w (read word data)\n"
diff --git a/tools/i2cset.c b/tools/i2cset.c
index e250837..e82dc52 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -38,9 +38,9 @@ static void help(void) __attribute__ ((noreturn));
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
+		"Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
-		"  ADDRESS is an integer (0x03 - 0x77)\n"
+		"  ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)\n"
 		"  MODE is one of:\n"
 		"    c (byte, no value)\n"
 		"    b (byte data, default)\n"
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 0dce067..8e9ce63 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -42,7 +42,7 @@ enum parse_state {
 static void help(void)
 {
 	fprintf(stderr,
-		"Usage: i2ctransfer [-f] [-y] [-v] [-V] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
+		"Usage: i2ctransfer [-f] [-y] [-v] [-V] [-a] I2CBUS DESC [DATA] [DESC [DATA]]...\n"
 		"  I2CBUS is an integer or an I2C bus name\n"
 		"  DESC describes the transfer in the form: {r|w}LENGTH[@address]\n"
 		"    1) read/write-flag 2) LENGTH (range 0-65535) 3) I2C address (use last one if omitted)\n"
-- 
2.11.0

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

* [PATCH v4 3/3] Update man pages for all_addrs
  2018-02-02 12:45 ` Patch proposal for using all addresses in i2c-tools Romain Porte
  2018-02-02 12:45   ` [PATCH v4 1/3] Add all_addrs option for i2c tools Romain Porte
  2018-02-02 12:45   ` [PATCH v4 2/3] Update help message for all_addrs option Romain Porte
@ 2018-02-02 12:45   ` Romain Porte
  2 siblings, 0 replies; 20+ messages in thread
From: Romain Porte @ 2018-02-02 12:45 UTC (permalink / raw)
  To: wsa; +Cc: jdelvare, peda, linux-i2c, Romain Porte

Describe the new -a option in man pages of modified tools.

Signed-off-by: Romain Porte <romain.porte@nokia.com>
---
 tools/i2cdump.8     | 4 ++++
 tools/i2cget.8      | 4 ++++
 tools/i2cset.8      | 4 ++++
 tools/i2ctransfer.8 | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/tools/i2cdump.8 b/tools/i2cdump.8
index fb7217e..2240f3c 100644
--- a/tools/i2cdump.8
+++ b/tools/i2cdump.8
@@ -7,6 +7,7 @@ i2cdump \- examine I2C registers
 .RB [ -f ]
 .RB [ "-r first-last" ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I address
 .RI [ "mode " [ "bank " [ bankreg ]]]
@@ -40,6 +41,9 @@ Disable interactive mode. By default, i2cdump will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts.
+.TP
+.B -a
+Allow using addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 At least two options must be provided to i2cdump. \fIi2cbus\fR indicates the
 number or name of the I2C bus to be scanned. This number should correspond to one
diff --git a/tools/i2cget.8 b/tools/i2cget.8
index a1a1276..8b48ad7 100644
--- a/tools/i2cget.8
+++ b/tools/i2cget.8
@@ -6,6 +6,7 @@ i2cget \- read from I2C/SMBus chip registers
 .B i2cget
 .RB [ -f ]
 .RB [ -y ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .RI [ "data-address " [ mode ]]
@@ -34,6 +35,9 @@ Disable interactive mode. By default, i2cget will wait for a confirmation
 from the user before messing with the I2C bus. When this flag is used, it
 will perform the operation directly. This is mainly meant to be used in
 scripts. Use with caution.
+.TP
+.B -a
+Allow using addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 There are two required options to i2cget. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2cset.8 b/tools/i2cset.8
index 19887bd..cd53aba 100644
--- a/tools/i2cset.8
+++ b/tools/i2cset.8
@@ -8,6 +8,7 @@ i2cset \- set I2C registers
 .RB [ -y ]
 .RB [ "-m mask" ]
 .RB [ -r ]
+.RB [ -a ]
 .I i2cbus
 .I chip-address
 .I data-address
@@ -54,6 +55,9 @@ be the case, as neither I2C nor SMBus guarantees this.
 Read back the value right after writing it, and compare the result with the
 value written. This used to be the default behavior. The same limitations
 apply as those of option \fB-m\fR.
+.TP
+.B -a
+Allow using addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 .PP
 There are three required options to i2cset. \fIi2cbus\fR indicates the number
 or name of the I2C bus to be scanned.  This number should correspond to one of
diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8
index 0dd43c9..99123fa 100644
--- a/tools/i2ctransfer.8
+++ b/tools/i2ctransfer.8
@@ -7,6 +7,7 @@ i2ctransfer \- send user-defined I2C messages in one transfer
 .RB [ -f ]
 .RB [ -y ]
 .RB [ -v ]
+.RB [ -a ]
 .I i2cbus desc
 .RI [ data ]
 .RI [ desc
@@ -61,6 +62,9 @@ It will print infos about all messages sent, i.e. not only for read messages but
 .TP
 .B -V
 Display the version and exit.
+.TP
+.B -a
+Allow using addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
 
 .SH ARGUMENTS
 .PP
-- 
2.11.0

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

end of thread, other threads:[~2018-02-02 12:46 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-05 15:02 Patch proposal for risky i2c addresses in i2c-tools Romain Porte
2018-01-05 15:02 ` [PATCH 1/3] Add risky_addr option for i2c tools Romain Porte
2018-01-05 15:02 ` [PATCH 2/3] Update help message for risky_addr option Romain Porte
2018-01-05 15:02 ` [PATCH 3/3] Update man pages for risky_addr Romain Porte
2018-01-26 18:03 ` Patch proposal for risky i2c addresses in i2c-tools Wolfram Sang
2018-01-29 12:26   ` Romain Porte
2018-01-29 13:39     ` Peter Rosin
2018-01-29 12:40 ` New patchset for risky addr, with lower bound support Romain Porte
2018-01-29 12:40   ` [PATCH v2 1/3] Add risky_addr option for i2c tools Romain Porte
2018-01-29 12:40   ` [PATCH v2 2/3] Update help message for risky_addr option Romain Porte
2018-01-29 13:45     ` Peter Rosin
2018-01-29 12:40   ` [PATCH v2 3/3] Update man pages for risky_addr Romain Porte
2018-01-29 13:57 ` Patch proposal for risky addr, with updated help messages Romain Porte
2018-01-29 13:57   ` [PATCH v3 1/3] Add risky_addr option for i2c tools Romain Porte
2018-01-29 13:57   ` [PATCH v3 2/3] Update help message for risky_addr option Romain Porte
2018-01-29 13:57   ` [PATCH v3 3/3] Update man pages for risky_addr Romain Porte
2018-02-02 12:45 ` Patch proposal for using all addresses in i2c-tools Romain Porte
2018-02-02 12:45   ` [PATCH v4 1/3] Add all_addrs option for i2c tools Romain Porte
2018-02-02 12:45   ` [PATCH v4 2/3] Update help message for all_addrs option Romain Porte
2018-02-02 12:45   ` [PATCH v4 3/3] Update man pages for all_addrs Romain Porte

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.