"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/i2cdump.c" between
i2c-tools-4.2.tar.gz and i2c-tools-4.3.tar.gz

About: i2c-tools are an heterogeneous set of I2C tools for Linux (originally part of the lm-sensors package).

i2cdump.c  (i2c-tools-4.2):i2cdump.c  (i2c-tools-4.3)
/* /*
i2cdump.c - a user-space program to dump I2C registers i2cdump.c - a user-space program to dump I2C registers
Copyright (C) 2002-2003 Frodo Looijaard <frodol@dds.nl>, and Copyright (C) 2002-2003 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com> 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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 46 skipping to change at line 46
static void help(void) static void help(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MO DE [BANK [BANKREG]]]\n" "Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MO DE [BANK [BANKREG]]]\n"
" I2CBUS is an integer or an I2C bus name\n" " I2CBUS is an integer or an I2C bus name\n"
" ADDRESS is an integer (0x08 - 0x77, or 0x00 - 0x7f if -a is gi ven)\n" " ADDRESS is an integer (0x08 - 0x77, or 0x00 - 0x7f if -a is gi ven)\n"
" MODE is one of:\n" " MODE is one of:\n"
" b (byte, default)\n" " b (byte, default)\n"
" w (word)\n" " w (word)\n"
" W (word on even register addresses)\n" " W (word on even register addresses)\n"
" s (SMBus block)\n" " s (SMBus block, deprecated)\n"
" i (I2C block)\n" " i (I2C block)\n"
" c (consecutive byte)\n" " c (consecutive byte)\n"
" Append p for SMBus PEC\n"); " Append p for SMBus PEC\n");
} }
static int check_funcs(int file, int size, int pec) static int check_funcs(int file, int size, int pec)
{ {
unsigned long funcs; unsigned long funcs;
/* check adapter functionality */ /* check adapter functionality */
skipping to change at line 184 skipping to change at line 184
size = I2C_SMBUS_BYTE_DATA; size = I2C_SMBUS_BYTE_DATA;
pec = argv[flags+3][1] == 'p'; pec = argv[flags+3][1] == 'p';
} else if (!strncmp(argv[flags+3], "w", 1)) { } else if (!strncmp(argv[flags+3], "w", 1)) {
size = I2C_SMBUS_WORD_DATA; size = I2C_SMBUS_WORD_DATA;
pec = argv[flags+3][1] == 'p'; pec = argv[flags+3][1] == 'p';
} else if (!strncmp(argv[flags+3], "W", 1)) { } else if (!strncmp(argv[flags+3], "W", 1)) {
size = I2C_SMBUS_WORD_DATA; size = I2C_SMBUS_WORD_DATA;
even = 1; even = 1;
} else if (!strncmp(argv[flags+3], "s", 1)) { } else if (!strncmp(argv[flags+3], "s", 1)) {
size = I2C_SMBUS_BLOCK_DATA; size = I2C_SMBUS_BLOCK_DATA;
fprintf(stderr,
"SMBus block mode is deprecated, please use i2cget instea
d\n");
pec = argv[flags+3][1] == 'p'; pec = argv[flags+3][1] == 'p';
} else if (!strncmp(argv[flags+3], "c", 1)) { } else if (!strncmp(argv[flags+3], "c", 1)) {
size = I2C_SMBUS_BYTE; size = I2C_SMBUS_BYTE;
pec = argv[flags+3][1] == 'p'; pec = argv[flags+3][1] == 'p';
} else if (!strcmp(argv[flags+3], "i")) } else if (!strcmp(argv[flags+3], "i"))
size = I2C_SMBUS_I2C_BLOCK_DATA; size = I2C_SMBUS_I2C_BLOCK_DATA;
else { else {
fprintf(stderr, "Error: Invalid mode!\n"); fprintf(stderr, "Error: Invalid mode!\n");
help(); help();
exit(1); exit(1);
skipping to change at line 254 skipping to change at line 256
if (end == dash || *end != '\0' if (end == dash || *end != '\0'
|| last < first || last > 0xff) { || last < first || last > 0xff) {
fprintf(stderr, "Error: Invalid range parameter!\n"); fprintf(stderr, "Error: Invalid range parameter!\n");
exit(1); exit(1);
} }
/* Check mode constraints */ /* Check mode constraints */
switch (size) { switch (size) {
case I2C_SMBUS_BYTE: case I2C_SMBUS_BYTE:
case I2C_SMBUS_BYTE_DATA: case I2C_SMBUS_BYTE_DATA:
case I2C_SMBUS_I2C_BLOCK_DATA:
break; break;
case I2C_SMBUS_WORD_DATA: case I2C_SMBUS_WORD_DATA:
if (!even || (!(first%2) && last%2)) if (!even || (!(first%2) && last%2))
break; break;
/* Fall through */ /* Fall through */
default: default:
fprintf(stderr, fprintf(stderr,
"Error: Range parameter not compatible with selec ted mode!\n"); "Error: Range parameter not compatible with selec ted mode!\n");
exit(1); exit(1);
} }
skipping to change at line 344 skipping to change at line 347
if (size == I2C_SMBUS_BLOCK_DATA if (size == I2C_SMBUS_BLOCK_DATA
|| size == I2C_SMBUS_I2C_BLOCK_DATA) { || size == I2C_SMBUS_I2C_BLOCK_DATA) {
unsigned char cblock[288]; unsigned char cblock[288];
if (size == I2C_SMBUS_BLOCK_DATA) { if (size == I2C_SMBUS_BLOCK_DATA) {
res = i2c_smbus_read_block_data(file, bank, res = i2c_smbus_read_block_data(file, bank,
cblock); cblock);
/* Remember returned block length for a nicer /* Remember returned block length for a nicer
display later */ display later */
s_length = res; s_length = res;
last = res - 1;
} else { } else {
for (res = 0; res < 256; res += i) { for (res = first; res <= last; res += i) {
i = i2c_smbus_read_i2c_block_data(file, i = i2c_smbus_read_i2c_block_data(file,
res, 32, cblock + res); res, 32, cblock + res);
if (i <= 0) { if (i <= 0) {
res = i; res = i;
break; break;
} }
} }
} }
if (res <= 0) { if (res <= 0) {
fprintf(stderr, "Error: Block read failed, " fprintf(stderr, "Error: Block read failed, "
"return code %d\n", res); "return code %d\n", res);
exit(1); exit(1);
} }
if (res >= 256) for (i = first; i <= last; i++)
res = 256;
for (i = 0; i < res; i++)
block[i] = cblock[i]; block[i] = cblock[i];
if (size != I2C_SMBUS_BLOCK_DATA)
for (i = res; i < 256; i++)
block[i] = -1;
} }
if (size == I2C_SMBUS_BYTE) { if (size == I2C_SMBUS_BYTE) {
res = i2c_smbus_write_byte(file, first); res = i2c_smbus_write_byte(file, first);
if(res != 0) { if(res != 0) {
fprintf(stderr, "Error: Write start address " fprintf(stderr, "Error: Write start address "
"failed, return code %d\n", res); "failed, return code %d\n", res);
exit(1); exit(1);
} }
} }
 End of changes. 8 change blocks. 
9 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)