summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2008-11-20 19:41:19 +0000
committerkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2008-11-20 19:41:19 +0000
commit448fc0663482d4513737239aed4ab4b26372fd33 (patch)
tree3fa11800c21f8e565906de71350e1a2561131d7c /tools
parent91f41e6775f87a6f9712142280e8368b6747f9ca (diff)
downloadi2c-tools-448fc0663482d4513737239aed4ab4b26372fd33.tar.gz
Make reading back the written value optional.
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5393 7894878c-1315-0410-8ee3-d5d059ff63e0
Diffstat (limited to 'tools')
-rw-r--r--tools/i2cset.86
-rw-r--r--tools/i2cset.c8
2 files changed, 13 insertions, 1 deletions
diff --git a/tools/i2cset.8 b/tools/i2cset.8
index 51ea8c8..2b4ce3a 100644
--- a/tools/i2cset.8
+++ b/tools/i2cset.8
@@ -7,6 +7,7 @@ i2cset \- set I2C registers
.RB [ -f ]
.RB [ -y ]
.RB [ "-m mask" ]
+.RB [ -r ]
.I i2cbus
.I chip-address
.I data-address
@@ -46,6 +47,11 @@ are taken from \fIvalue\fR, while bits set to 0 will be read from
this parameter assumes that the read and write operations for the specified
mode are symmetrical for the device you are accessing. This may or may not
be the case, as neither I2C nor SMBus guarantees this.
+.TP
+.B -r
+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.
.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/i2cset.c b/tools/i2cset.c
index 3af8e82..9b686bf 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -134,7 +134,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, readback = 0;
/* handle (optional) flags first */
while (1+flags < argc && argv[1+flags][0] == '-') {
@@ -147,6 +147,7 @@ int main(int argc, char *argv[])
maskp = argv[2+flags];
flags++;
break;
+ case 'r': readback = 1; break;
default:
fprintf(stderr, "Error: Unsupported option "
"\"%s\"!\n", argv[1+flags]);
@@ -308,6 +309,11 @@ int main(int argc, char *argv[])
}
}
+ if (!readback) { /* We're done */
+ close(file);
+ exit(0);
+ }
+
switch (size) {
case I2C_SMBUS_BYTE:
/* No readback */