linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>
Cc: Wolfram Sang <wsa@kernel.org>
Subject: [PATCH 5/7] i2cdump: Add range support with mode i (I2C block)
Date: Tue, 8 Jun 2021 17:30:56 +0200	[thread overview]
Message-ID: <20210608173056.1c35beab@endymion> (raw)
In-Reply-To: <20210608172338.0cf520a1@endymion>

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@suse.de>
---
 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@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];
 		}
 
--- 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

  parent reply	other threads:[~2021-06-08 15:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 15:23 [PATCH 0/7] Rework block read support among i2cget and i2cdump Jean Delvare
2021-06-08 15:28 ` [PATCH 1/7] i2cget: Add support for I2C block data Jean Delvare
2021-06-27 10:11   ` Wolfram Sang
2021-07-12  9:36     ` Jean Delvare
2021-06-08 15:29 ` [PATCH 2/7] i2cget: Document the support of I2C block reads Jean Delvare
2021-06-08 15:29 ` [PATCH 3/7] i2cget: Add support for SMBus block read Jean Delvare
2021-06-08 15:30 ` [PATCH 4/7] i2cdump: Remove dead code Jean Delvare
2021-06-08 15:30 ` Jean Delvare [this message]
2021-06-08 15:31 ` [PATCH 6/7] i2cdump: Deprecate SMBus block mode Jean Delvare
2021-06-08 15:32 ` [PATCH 7/7] i2cdump: Remove support for " Jean Delvare
2021-06-26 15:30 ` [PATCH 0/7] Rework block read support among i2cget and i2cdump Wolfram Sang
2021-07-12  9:58   ` Jean Delvare
2021-07-19 15:19     ` Wolfram Sang
2021-06-27 10:27 ` Wolfram Sang
2021-07-13  8:21   ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608173056.1c35beab@endymion \
    --to=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).