[PATCH 5/7] i2cdump: Add range support with mode i (I2C block)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implementing range support for I2C block reads (mode i) isn't
particularly difficult so let's just do that.

Signed-off-by: Jean Delvare <jdelvare@xxxxxxx>
---
 tools/i2cdump.8 |    6 +++---
 tools/i2cdump.c |   10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

--- i2c-tools.orig/tools/i2cdump.c	2021-06-08 14:56:02.047402610 +0200
+++ i2c-tools/tools/i2cdump.c	2021-06-08 15:02:52.697979744 +0200
@@ -2,7 +2,7 @@
     i2cdump.c - a user-space program to dump I2C registers
     Copyright (C) 2002-2003  Frodo Looijaard <frodol@xxxxxx>, and
                              Mark D. Studebaker <mdsxyz123@xxxxxxxxx>
-    Copyright (C) 2004-2012  Jean Delvare <jdelvare@xxxxxxx>
+    Copyright (C) 2004-2021  Jean Delvare <jdelvare@xxxxxxx>
 
     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];
 		}
 
--- i2c-tools.orig/tools/i2cdump.8	2021-06-08 14:56:02.047402610 +0200
+++ i2c-tools/tools/i2cdump.8	2021-06-08 15:02:46.451894913 +0200
@@ -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 c
 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

-- 
Jean Delvare
SUSE L3 Support



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux