Browse Source

tools: restrict all addresses defined by the standard

The I2C standard reserves addresses 0x03-0x07. Adapt our tools to that.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
tags/v4.2
Wolfram Sang 6 years ago
committed by Wolfram Sang
parent
commit
78edfefbcc
  1. 1
      CHANGES
  2. 2
      tools/i2cbusses.c
  3. 2
      tools/i2cdetect.8
  4. 2
      tools/i2cdetect.c
  5. 4
      tools/i2cdump.8
  6. 2
      tools/i2cdump.c
  7. 4
      tools/i2cget.8
  8. 2
      tools/i2cget.c
  9. 4
      tools/i2cset.8
  10. 2
      tools/i2cset.c
  11. 4
      tools/i2ctransfer.8

1
CHANGES

@ -3,6 +3,7 @@ i2c-tools CHANGES
master
tools: Consistently use snprintf instead of sprintf
Restrict addresses 0x03-0x07, too (defined by I2C standard)
decode-dimms: Print SPD revision for DDR3 too
Move SDR-specific code
i2ctransfer: Mention '-a' everywhere in the manpage

2
tools/i2cbusses.c

@ -381,7 +381,7 @@ int parse_i2c_address(const char *address_arg, int all_addrs)
{
long address;
char *end;
long min_addr = 0x03;
long min_addr = 0x08;
long max_addr = 0x77;
address = strtol(address_arg, &end, 0);

2
tools/i2cdetect.8

@ -26,7 +26,7 @@ outputs a table with the list of detected devices on the specified bus.
\fIi2cbus\fR indicates the number or name of the I2C bus to be scanned, and
should correspond to one of the busses listed by \fIi2cdetect -l\fR.
The optional parameters \fIfirst\fR and \fIlast\fR restrict the scanning
range (default: from 0x03 to 0x77).
range (default: from 0x08 to 0x77).
.PP
As there is no standard I2C detection command, i2cdetect uses arbitrary
SMBus commands (namely SMBus quick write and SMBus receive byte) to probe

2
tools/i2cdetect.c

@ -204,7 +204,7 @@ int main(int argc, char *argv[])
char filename[20];
unsigned long funcs;
int mode = MODE_AUTO;
int first = 0x03, last = 0x77;
int first = 0x08, last = 0x77;
int flags = 0;
int yes = 0, version = 0, list = 0;

4
tools/i2cdump.8

@ -43,12 +43,12 @@ 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.
Allow using addresses between 0x00 - 0x07 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
of the busses listed by \fIi2cdetect -l\fR. \fIaddress\fR indicates the
address to be scanned on that bus, and is an integer between 0x03 and 0x77.
address to be scanned on that bus, and is an integer between 0x08 and 0x77.
.PP
The \fImode\fR parameter, if specified, is one of the letters \fBb\fP, \fBw\fP,
\fBs\fP, or \fBi\fP, corresponding to a read size of a single byte, a 16-bit

2
tools/i2cdump.c

@ -38,7 +38,7 @@ static void help(void)
fprintf(stderr,
"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, or 0x00 - 0x7f if -a is given)\n"
" ADDRESS is an integer (0x08 - 0x77, or 0x00 - 0x7f if -a is given)\n"
" MODE is one of:\n"
" b (byte, default)\n"
" w (word)\n"

4
tools/i2cget.8

@ -37,12 +37,12 @@ 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.
Allow using addresses between 0x00 - 0x07 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
the busses listed by \fIi2cdetect -l\fR. \fIchip-address\fR specifies the
address of the chip on that bus, and is an integer between 0x03 and 0x77.
address of the chip on that bus, and is an integer between 0x08 and 0x77.
.PP
\fIdata-address\fR specifies the address on that chip to read from, and is
an integer between 0x00 and 0xFF. If omitted, the currently active register

2
tools/i2cget.c

@ -43,7 +43,7 @@ static void help(void)
fprintf(stderr,
"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, or 0x00 - 0x7f if -a is given)\n"
" ADDRESS is an integer (0x08 - 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"

4
tools/i2cset.8

@ -57,12 +57,12 @@ 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.
Allow using addresses between 0x00 - 0x07 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
the busses listed by \fIi2cdetect -l\fR. \fIchip-address\fR specifies the
address of the chip on that bus, and is an integer between 0x03 and 0x77.
address of the chip on that bus, and is an integer between 0x08 and 0x77.
\fIdata-address\fR specifies the address on that chip to write to, and is an
integer between 0x00 and 0xFF.
.PP

2
tools/i2cset.c

@ -40,7 +40,7 @@ static void help(void)
fprintf(stderr,
"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, or 0x00 - 0x7f if -a is given)\n"
" ADDRESS is an integer (0x08 - 0x77, or 0x00 - 0x7f if -a is given)\n"
" MODE is one of:\n"
" c (byte, no value)\n"
" b (byte data, default)\n"

4
tools/i2ctransfer.8

@ -64,7 +64,7 @@ It will print infos about all messages sent, i.e. not only for read messages but
Display the version and exit.
.TP
.B -a
Allow using addresses between 0x00 - 0x02 and 0x78 - 0x7f. Not recommended.
Allow using addresses between 0x00 - 0x07 and 0x78 - 0x7f. Not recommended.
.SH ARGUMENTS
.PP
@ -95,7 +95,7 @@ It is parsed as an unsigned 16 bit integer, but note that the Linux Kernel appli
.B [@address]
specifies the 7-bit address of the chip to be accessed for this message, and is an integer.
If omitted, reuse the previous address.
Normally, addresses outside the range of 0x03-0x77 and addresses with a kernel driver attached to them will be blocked.
Normally, addresses outside the range of 0x08-0x77 and addresses with a kernel driver attached to them will be blocked.
This can be overridden with
.I -a
(all) or

Loading…
Cancel
Save