summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2021-07-22 16:39:29 +0200
committerJean Delvare <jdelvare@suse.de>2021-07-22 16:39:29 +0200
commit4016b7f1749854b8144d3fb06903afa8ee1d99f3 (patch)
tree0dc64856480ff23a8c5549fbd8f3448aaed849f7
parent64e4a000a953f4dd2a27304caefc7754aff8f934 (diff)
downloadi2c-tools-git-4016b7f1749854b8144d3fb06903afa8ee1d99f3.tar.gz
i2cdump: Remove support for SMBus block mode
Users can turn to i2cget for this feature. 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.87
-rw-r--r--tools/i2cdump.c81
2 files changed, 20 insertions, 68 deletions
diff --git a/tools/i2cdump.8 b/tools/i2cdump.8
index 3014890..d8ed28d 100644
--- a/tools/i2cdump.8
+++ b/tools/i2cdump.8
@@ -51,8 +51,8 @@ of the busses listed by \fIi2cdetect -l\fR. \fIaddress\fR indicates the
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 write to the Linux I2C mailing list
<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
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index b638c3d..e7dfaf1 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -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 size, int pec)
}
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);