Browse Source

Consistently restrict the allowed I2C device address to 0x03 - 0x77.

git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5203 7894878c-1315-0410-8ee3-d5d059ff63e0
tags/v3.0.2
Jean Delvare 18 years ago
parent
commit
2e942d16a5
  1. 2
      CHANGES
  2. 2
      tools/i2cdump.8
  3. 4
      tools/i2cdump.c
  4. 4
      tools/i2cget.c
  5. 2
      tools/i2cset.8
  6. 6
      tools/i2cset.c

2
CHANGES

@ -7,10 +7,12 @@ SVN
Shorten the usage message
i2cdump: Support i2c bus passed by name
Shorten the usage message
Restrict the chip address to 0x03-0x77
i2cget: Support i2c bus passed by name
Shorten the usage message
i2cset: Support i2c bus passed by name
Shorten the usage message
Restrict the chip address to 0x03-0x77
3.0.1 (2008-04-04)
Drop the trailing .pl from all perl script names

2
tools/i2cdump.8

@ -45,7 +45,7 @@ scripts.
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 0x00 and 0x7F.
address to be scanned on that bus, and is an integer between 0x03 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

4
tools/i2cdump.c

@ -35,7 +35,7 @@ static void help(void)
fprintf(stderr,
"Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE] [BANK [BANKREG]]\n"
" I2CBUS is an integer or an I2C bus name\n"
" ADDRESS is an integer (0x00 - 0x7f)\n"
" ADDRESS is an integer (0x03 - 0x77)\n"
" MODE is one of:\n"
" b (byte, default)\n"
" w (word)\n"
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
help();
exit(1);
}
if (address < 0 || address > 0x7f) {
if (address < 0x03 || address > 0x77) {
fprintf(stderr, "Error: Address out of range!\n");
help();
exit(1);

4
tools/i2cget.c

@ -1,6 +1,6 @@
/*
i2cget.c - A user-space program to read an I2C register.
Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2005-2008 Jean Delvare <khali@linux-fr.org>
Based on i2cset.c:
Copyright (C) 2001-2003 Frodo Looijaard <frodol@dds.nl>, and
@ -190,7 +190,7 @@ int main(int argc, char *argv[])
help();
address = strtol(argv[flags+2], &end, 0);
if (*end || address < 3 || address > 0x77) {
if (*end || address < 0x03 || address > 0x77) {
fprintf(stderr, "Error: Chip address invalid!\n");
help();
}

2
tools/i2cset.8

@ -42,7 +42,7 @@ scripts.
There are four 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 0x00 and 0x7F.
address of the chip on that bus, and is an integer between 0x03 and 0x77.
\fIdata-address\fR specifies the address on that chip to write to, and is an
integer between 0x00 and 0xFF. \fIvalue\fR is the value to write to that
location on the chip.

6
tools/i2cset.c

@ -2,7 +2,7 @@
i2cset.c - A user-space program to write an I2C register.
Copyright (C) 2001-2003 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2004-2008 Jean Delvare <khali@linux-fr.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -37,7 +37,7 @@ static void help(void)
fprintf(stderr,
"Usage: i2cset [-f] [-y] I2CBUS CHIP-ADDRESS DATA-ADDRESS VALUE [MODE] [MASK]\n"
" I2CBUS is an integer or an I2C bus name\n"
" ADDRESS is an integer (0x00 - 0x7f)\n"
" ADDRESS is an integer (0x03 - 0x77)\n"
" MODE is one of:\n"
" b (byte, default)\n"
" w (word)\n"
@ -84,7 +84,7 @@ int main(int argc, char *argv[])
help();
address = strtol(argv[flags+2], &end, 0);
if (*end || address < 0 || address > 0x7f) {
if (*end || address < 0x03 || address > 0x77) {
fprintf(stderr, "Error: Chip address invalid!\n");
help();
}

Loading…
Cancel
Save