summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2021-07-13 10:16:38 +0200
committerJean Delvare <jdelvare@suse.de>2021-07-13 10:16:38 +0200
commit6b9849376307e91084fc6c871e96d3d209386035 (patch)
tree895dc7030d52665da78bd9505299decd8def7e06
parent230be0e72f2c8ca2d973218060e044c1dada1254 (diff)
downloadi2c-tools-git-6b9849376307e91084fc6c871e96d3d209386035.tar.gz
i2cdump: Add range support with mode i (I2C block)
Implementing range support for I2C block read (mode i) isn't particularly difficult so let's just do that. Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
-rw-r--r--tools/i2cdump.86
-rw-r--r--tools/i2cdump.c10
2 files changed, 8 insertions, 8 deletions
diff --git a/tools/i2cdump.8 b/tools/i2cdump.8
index e039751..95a9861 100644
--- a/tools/i2cdump.8
+++ b/tools/i2cdump.8
@@ -1,4 +1,4 @@
-.TH I2CDUMP 8 "October 2017"
+.TH I2CDUMP 8 "June 2021"
.SH NAME
i2cdump \- examine I2C registers
@@ -32,8 +32,8 @@ kernel driver in question. It can also cause i2cdump to return invalid
results. So use at your own risk and only if you know what you're doing.
.TP
.B -r first-last
-Limit the range of registers being accessed. This option is only available
-with modes \fBb\fP, \fBw\fP, \fBc\fP and \fBW\fP. For mode \fBW\fP,
+Limit the range of registers being accessed. This option is not available
+with mode \fBs\fP. For mode \fBW\fP,
\fBfirst\fR must be even and \fBlast\fR must be odd.
.TP
.B -y
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index 7b291ea..4637089 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -2,7 +2,7 @@
i2cdump.c - a user-space program to dump I2C registers
Copyright (C) 2002-2003 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
- Copyright (C) 2004-2012 Jean Delvare <jdelvare@suse.de>
+ Copyright (C) 2004-2021 Jean Delvare <jdelvare@suse.de>
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
@@ -251,6 +251,7 @@ int main(int argc, char *argv[])
switch (size) {
case I2C_SMBUS_BYTE:
case I2C_SMBUS_BYTE_DATA:
+ case I2C_SMBUS_I2C_BLOCK_DATA:
break;
case I2C_SMBUS_WORD_DATA:
if (!even || (!(first%2) && last%2))
@@ -341,8 +342,9 @@ int main(int argc, char *argv[])
/* Remember returned block length for a nicer
display later */
s_length = res;
+ last = res - 1;
} else {
- for (res = 0; res < 256; res += i) {
+ for (res = first; res <= last; res += i) {
i = i2c_smbus_read_i2c_block_data(file,
res, 32, cblock + res);
if (i <= 0) {
@@ -356,9 +358,7 @@ int main(int argc, char *argv[])
"return code %d\n", res);
exit(1);
}
- if (res >= 256)
- res = 256;
- for (i = 0; i < res; i++)
+ for (i = first; i <= last; i++)
block[i] = cblock[i];
}