All of lore.kernel.org
 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 7/7] i2cdump: Remove support for SMBus block mode
Date: Tue, 8 Jun 2021 17:32:28 +0200	[thread overview]
Message-ID: <20210608173228.6cd2284c@endymion> (raw)
In-Reply-To: <20210608172338.0cf520a1@endymion>

Users can turn to i2cget for this feature.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
 tools/i2cdump.8 |    7 ++--
 tools/i2cdump.c |   81 +++++++++++---------------------------------------------
 2 files changed, 20 insertions(+), 68 deletions(-)

--- i2c-tools.orig/tools/i2cdump.8	2021-06-08 17:13:32.294526703 +0200
+++ i2c-tools/tools/i2cdump.8	2021-06-08 17:13:50.600778075 +0200
@@ -51,8 +51,8 @@ of the busses listed by \fIi2cdetect -l\
 address to be scanned on that bus, and is an integer between 0x08 and 0x77.
 .PP
 The \fImode\fR parameter, if specified, is one of the letters \fBb\fP, \fBw\fP,
-\fBs\fP, or \fBi\fP, corresponding to a read size of a single byte, a 16-bit
-word, an SMBus block, an I2C block, respectively. The \fBc\fP mode is a
+or \fBi\fP, corresponding to a read size of a single byte, a 16-bit
+word, an I2C block, respectively. The \fBc\fP mode is a
 little different, it reads all bytes consecutively, and is useful for chips that
 have an address auto-increment feature, such as EEPROMs. The \fBW\fP mode is
 also special, it is similar to \fBw\fP except that a read command will only
@@ -112,8 +112,7 @@ To report bugs or send fixes, please wri
 <linux-i2c@vger.kernel.org> with Cc to the current maintainer:
 Jean Delvare <jdelvare@suse.de>.
 
-SMBus block mode is deprecated and will be removed in a future version
-of this tool.
+SMBus block mode used to be supported by this tool.
 Please use \fIi2cget\fR instead.
 
 .SH SEE ALSO
--- i2c-tools.orig/tools/i2cdump.c	2021-06-08 17:13:21.787382423 +0200
+++ i2c-tools/tools/i2cdump.c	2021-06-08 17:13:33.613544815 +0200
@@ -43,7 +43,6 @@ static void help(void)
 		"    b (byte, default)\n"
 		"    w (word)\n"
 		"    W (word on even register addresses)\n"
-		"    s (SMBus block, deprecated)\n"
 		"    i (I2C block)\n"
 		"    c (consecutive byte)\n"
 		"    Append p for SMBus PEC\n");
@@ -86,13 +85,6 @@ static int check_funcs(int file, int siz
 		}
 		break;
 
-	case I2C_SMBUS_BLOCK_DATA:
-		if (!(funcs & I2C_FUNC_SMBUS_READ_BLOCK_DATA)) {
-			fprintf(stderr, MISSING_FUNC_FMT, "SMBus block read");
-			return -1;
-		}
-		break;
-
 	case I2C_SMBUS_I2C_BLOCK_DATA:
 		if (!(funcs & I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
 			fprintf(stderr, MISSING_FUNC_FMT, "I2C block read");
@@ -116,7 +108,7 @@ int main(int argc, char *argv[])
 	int i, j, res, i2cbus, address, size, file;
 	int bank = 0, bankreg = 0x4E, old_bank = 0;
 	char filename[20];
-	int block[256], s_length = 0;
+	int block[256];
 	int pec = 0, even = 0;
 	int flags = 0;
 	int force = 0, yes = 0, version = 0, all_addrs = 0;
@@ -180,10 +172,9 @@ int main(int argc, char *argv[])
 		size = I2C_SMBUS_WORD_DATA;
 		even = 1;
 	} else if (!strncmp(argv[flags+3], "s", 1)) {
-		size = I2C_SMBUS_BLOCK_DATA;
 		fprintf(stderr,
-			"SMBus Block mode is deprecated, please use i2cget instead\n");
-		pec = argv[flags+3][1] == 'p';
+			"SMBus Block mode is no longer supported, please use i2cget instead\n");
+		exit(1);
 	} else if (!strncmp(argv[flags+3], "c", 1)) {
 		size = I2C_SMBUS_BYTE;
 		pec = argv[flags+3][1] == 'p';
@@ -208,16 +199,10 @@ int main(int argc, char *argv[])
 			help();
 			exit(1);
 		}
-		if (size == I2C_SMBUS_BLOCK_DATA
-		 && (bank < 0 || bank > 0xff)) {
-			fprintf(stderr, "Error: block command out of range!\n");
-			help();
-			exit(1);
-		}
 
 		if (argc > flags + 5) {
 			bankreg = strtol(argv[flags+5], &end, 0);
-			if (*end || size == I2C_SMBUS_BLOCK_DATA) {
+			if (*end) {
 				fprintf(stderr, "Error: Invalid bank register "
 					"number!\n");
 				help();
@@ -250,16 +235,7 @@ int main(int argc, char *argv[])
 		}
 
 		/* Check mode constraints */
-		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))
-				break;
-			/* Fall through */
-		default:
+		if (size == I2C_SMBUS_WORD_DATA && even && (first%2 || !(last%2))) {
 			fprintf(stderr,
 				"Error: Range parameter not compatible with selected mode!\n");
 			exit(1);
@@ -286,7 +262,6 @@ int main(int argc, char *argv[])
 
 		fprintf(stderr, "I will probe file %s, address 0x%x, mode "
 			"%s\n", filename, address,
-			size == I2C_SMBUS_BLOCK_DATA ? "smbus block" :
 			size == I2C_SMBUS_I2C_BLOCK_DATA ? "i2c block" :
 			size == I2C_SMBUS_BYTE ? "byte consecutive read" :
 			size == I2C_SMBUS_BYTE_DATA ? "byte" : "word");
@@ -296,12 +271,8 @@ int main(int argc, char *argv[])
 			fprintf(stderr, "Only probing even register "
 				"addresses.\n");
 		if (bank) {
-			if (size == I2C_SMBUS_BLOCK_DATA)
-				fprintf(stderr, "Using command 0x%02x.\n",
-					bank);
-			else
-				fprintf(stderr, "Probing bank %d using bank "
-					"register 0x%02x.\n", bank, bankreg);
+			fprintf(stderr, "Probing bank %d using bank "
+				"register 0x%02x.\n", bank, bankreg);
 		}
 		if (range) {
 			fprintf(stderr,
@@ -318,7 +289,7 @@ int main(int argc, char *argv[])
 	}
 
 	/* See Winbond w83781d data sheet for bank details */
-	if (bank && size != I2C_SMBUS_BLOCK_DATA) {
+	if (bank) {
 		res = i2c_smbus_read_byte_data(file, bankreg);
 		if (res >= 0) {
 			old_bank = res;
@@ -334,25 +305,15 @@ int main(int argc, char *argv[])
 	/* handle all but word data */
 	if (size != I2C_SMBUS_WORD_DATA || even) {
 		/* do the block transaction */
-		if (size == I2C_SMBUS_BLOCK_DATA
-		 || size == I2C_SMBUS_I2C_BLOCK_DATA) {
+		if (size == I2C_SMBUS_I2C_BLOCK_DATA) {
 			unsigned char cblock[288];
 
-			if (size == I2C_SMBUS_BLOCK_DATA) {
-				res = i2c_smbus_read_block_data(file, bank,
-				      cblock);
-				/* Remember returned block length for a nicer
-				   display later */
-				s_length = res;
-				last = res - 1;
-			} else {
-				for (res = first; res <= last; res += i) {
-					i = i2c_smbus_read_i2c_block_data(file,
-						res, 32, cblock + res);
-					if (i <= 0) {
-						res = i;
-						break;
-					}
+			for (res = first; res <= last; res += i) {
+				i = i2c_smbus_read_i2c_block_data(file,
+					res, 32, cblock + res);
+				if (i <= 0) {
+					res = i;
+					break;
 				}
 			}
 			if (res <= 0) {
@@ -376,8 +337,6 @@ int main(int argc, char *argv[])
 		printf("     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f"
 		       "    0123456789abcdef\n");
 		for (i = 0; i < 256; i+=16) {
-			if (size == I2C_SMBUS_BLOCK_DATA && i >= s_length)
-				break;
 			if (i/16 < first/16)
 				continue;
 			if (i/16 > last/16)
@@ -415,10 +374,7 @@ int main(int argc, char *argv[])
 				} else
 					res = block[i+j];
 
-				if (size == I2C_SMBUS_BLOCK_DATA
-				 && i+j >= s_length) {
-					printf("   ");
-				} else if (res < 0) {
+				if (res < 0) {
 					printf("XX ");
 					if (size == I2C_SMBUS_WORD_DATA)
 						printf("XX ");
@@ -433,9 +389,6 @@ int main(int argc, char *argv[])
 			printf("   ");
 
 			for (j = 0; j < 16; j++) {
-				if (size == I2C_SMBUS_BLOCK_DATA
-				 && i+j >= s_length)
-					break;
 				/* Skip unwanted registers */
 				if (i+j < first || i+j > last) {
 					printf(" ");
@@ -483,7 +436,7 @@ int main(int argc, char *argv[])
 			printf("\n");
 		}
 	}
-	if (bank && size != I2C_SMBUS_BLOCK_DATA) {
+	if (bank) {
 		i2c_smbus_write_byte_data(file, bankreg, old_bank);
 	}
 	exit(0);

-- 
Jean Delvare
SUSE L3 Support

  parent reply	other threads:[~2021-06-08 15:32 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 ` [PATCH 5/7] i2cdump: Add range support with mode i (I2C block) Jean Delvare
2021-06-08 15:31 ` [PATCH 6/7] i2cdump: Deprecate SMBus block mode Jean Delvare
2021-06-08 15:32 ` Jean Delvare [this message]
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=20210608173228.6cd2284c@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.