i2c-tools: rename remaining defines

Rename the defines not present in linux UAPI headers to better reflect
their purpose.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Bartosz Golaszewski 2015-09-04 10:38:48 +02:00 committed by Denys Vlasenko
parent d9892fa0c3
commit 2beb52499e

View File

@ -64,11 +64,11 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-dev.h> #include <linux/i2c-dev.h>
#define I2C_MAX_REGS 256 #define I2CDUMP_NUM_REGS 256
#define DETECT_MODE_AUTO 0 #define I2CDETECT_MODE_AUTO 0
#define DETECT_MODE_QUICK 1 #define I2CDETECT_MODE_QUICK 1
#define DETECT_MODE_READ 2 #define I2CDETECT_MODE_READ 2
/* /*
* This is needed for ioctl_or_perror_and_die() since it only accepts pointers. * This is needed for ioctl_or_perror_and_die() since it only accepts pointers.
@ -720,14 +720,14 @@ int i2cset_main(int argc, char **argv)
#if ENABLE_I2CDUMP #if ENABLE_I2CDUMP
static int read_block_data(int buf_fd, int mode, int *block) static int read_block_data(int buf_fd, int mode, int *block)
{ {
uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2C_MAX_REGS]; uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2CDUMP_NUM_REGS];
int res, blen = 0, tmp, i; int res, blen = 0, tmp, i;
if (mode == I2C_SMBUS_BLOCK_DATA || mode == I2C_SMBUS_I2C_BLOCK_DATA) { if (mode == I2C_SMBUS_BLOCK_DATA || mode == I2C_SMBUS_I2C_BLOCK_DATA) {
res = i2c_smbus_read_block_data(buf_fd, 0, cblock); res = i2c_smbus_read_block_data(buf_fd, 0, cblock);
blen = res; blen = res;
} else { } else {
for (res = 0; res < I2C_MAX_REGS; res += tmp) { for (res = 0; res < I2CDUMP_NUM_REGS; res += tmp) {
tmp = i2c_smbus_read_i2c_block_data( tmp = i2c_smbus_read_i2c_block_data(
buf_fd, res, I2C_SMBUS_BLOCK_MAX, buf_fd, res, I2C_SMBUS_BLOCK_MAX,
cblock + res); cblock + res);
@ -736,14 +736,14 @@ static int read_block_data(int buf_fd, int mode, int *block)
} }
} }
if (res >= I2C_MAX_REGS) if (res >= I2CDUMP_NUM_REGS)
res = I2C_MAX_REGS; res = I2CDUMP_NUM_REGS;
for (i = 0; i < res; i++) for (i = 0; i < res; i++)
block[i] = cblock[i]; block[i] = cblock[i];
if (mode != I2C_SMBUS_BLOCK_DATA) if (mode != I2C_SMBUS_BLOCK_DATA)
for (i = res; i < I2C_MAX_REGS; i++) for (i = res; i < I2CDUMP_NUM_REGS; i++)
block[i] = -1; block[i] = -1;
} }
@ -759,7 +759,7 @@ static void dump_data(int bus_fd, int mode, unsigned first,
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f" printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f"
" 0123456789abcdef\n"); " 0123456789abcdef\n");
for (i = 0; i < I2C_MAX_REGS; i += 0x10) { for (i = 0; i < I2CDUMP_NUM_REGS; i += 0x10) {
if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen) if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen)
break; break;
if (i/16 < first/16) if (i/16 < first/16)
@ -1200,7 +1200,7 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
opt_F = (1 << 4), opt_l = (1 << 5); opt_F = (1 << 4), opt_l = (1 << 5);
const char *const optstr = "yaqrFl"; const char *const optstr = "yaqrFl";
int fd, bus_num, i, j, mode = DETECT_MODE_AUTO, status; int fd, bus_num, i, j, mode = I2CDETECT_MODE_AUTO, status;
unsigned first = 0x03, last = 0x77, opts; unsigned first = 0x03, last = 0x77, opts;
unsigned long funcs; unsigned long funcs;
@ -1231,9 +1231,9 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
} }
if (opts & opt_r) if (opts & opt_r)
mode = DETECT_MODE_READ; mode = I2CDETECT_MODE_READ;
else if (opts & opt_q) else if (opts & opt_q)
mode = DETECT_MODE_QUICK; mode = I2CDETECT_MODE_QUICK;
if (opts & opt_a) { if (opts & opt_a) {
first = 0x00; first = 0x00;
@ -1250,14 +1250,14 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
if (!(funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) { if (!(funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) {
no_support("detection commands"); no_support("detection commands");
} else } else
if (mode == DETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)) { if (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)) {
no_support("SMBus Quick Write command"); no_support("SMBus Quick Write command");
} else } else
if (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { if (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) {
no_support("SMBus Receive Byte command"); no_support("SMBus Receive Byte command");
} }
if (mode == DETECT_MODE_AUTO) { if (mode == I2CDETECT_MODE_AUTO) {
if (!(funcs & I2C_FUNC_SMBUS_QUICK)) if (!(funcs & I2C_FUNC_SMBUS_QUICK))
will_skip("SMBus Quick Write"); will_skip("SMBus Quick Write");
if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE))
@ -1273,19 +1273,19 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
for(j = 0; j < 16; j++) { for(j = 0; j < 16; j++) {
fflush_all(); fflush_all();
if (mode == DETECT_MODE_AUTO) { if (mode == I2CDETECT_MODE_AUTO) {
if ((i+j >= 0x30 && i+j <= 0x37) || if ((i+j >= 0x30 && i+j <= 0x37) ||
(i+j >= 0x50 && i+j <= 0x5F)) (i+j >= 0x50 && i+j <= 0x5F))
mode = DETECT_MODE_READ; mode = I2CDETECT_MODE_READ;
else else
mode = DETECT_MODE_QUICK; mode = I2CDETECT_MODE_QUICK;
} }
/* Skip unwanted addresses. */ /* Skip unwanted addresses. */
if (i+j < first if (i+j < first
|| i+j > last || i+j > last
|| (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) || (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE))
|| (mode == DETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK))) || (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)))
{ {
printf(" "); printf(" ");
continue; continue;
@ -1303,14 +1303,14 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
} }
switch (mode) { switch (mode) {
case DETECT_MODE_READ: case I2CDETECT_MODE_READ:
/* /*
* This is known to lock SMBus on various * This is known to lock SMBus on various
* write-only chips (mainly clock chips). * write-only chips (mainly clock chips).
*/ */
status = i2c_smbus_read_byte(fd); status = i2c_smbus_read_byte(fd);
break; break;
default: /* DETECT_MODE_QUICK: */ default: /* I2CDETECT_MODE_QUICK: */
/* /*
* This is known to corrupt the Atmel * This is known to corrupt the Atmel
* AT24RF08 EEPROM. * AT24RF08 EEPROM.