From 35a929de328558040fcd3b2ff696350bb9cb8af4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 20 Nov 2008 19:41:19 +0000 Subject: [PATCH] Make reading back the written value optional. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5393 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + tools/i2cset.8 | 6 ++++++ tools/i2cset.c | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index bacec56..a93cd97 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ SVN Add support for short writes (SMBus send byte) Better error message on missing adapter functionality Set the data value mask with -m + Make reading back the written value optional i2c-stub-from-dump: Add support for partial dumps Report if only garbage is found in dump file Behave properly when i2c-stub is already loaded 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 */