aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/i2c_tools.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index b78860277..4b26b7bdc 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -64,11 +64,11 @@
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
-#define I2C_MAX_REGS 256
+#define I2CDUMP_NUM_REGS 256
-#define DETECT_MODE_AUTO 0
-#define DETECT_MODE_QUICK 1
-#define DETECT_MODE_READ 2
+#define I2CDETECT_MODE_AUTO 0
+#define I2CDETECT_MODE_QUICK 1
+#define I2CDETECT_MODE_READ 2
/*
* 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
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;
if (mode == I2C_SMBUS_BLOCK_DATA || mode == I2C_SMBUS_I2C_BLOCK_DATA) {
res = i2c_smbus_read_block_data(buf_fd, 0, cblock);
blen = res;
} 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(
buf_fd, res, I2C_SMBUS_BLOCK_MAX,
cblock + res);
@@ -736,14 +736,14 @@ static int read_block_data(int buf_fd, int mode, int *block)
}
}
- if (res >= I2C_MAX_REGS)
- res = I2C_MAX_REGS;
+ if (res >= I2CDUMP_NUM_REGS)
+ res = I2CDUMP_NUM_REGS;
for (i = 0; i < res; i++)
block[i] = cblock[i];
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;
}
@@ -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"
" 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)
break;
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);
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 long funcs;
@@ -1231,9 +1231,9 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
}
if (opts & opt_r)
- mode = DETECT_MODE_READ;
+ mode = I2CDETECT_MODE_READ;
else if (opts & opt_q)
- mode = DETECT_MODE_QUICK;
+ mode = I2CDETECT_MODE_QUICK;
if (opts & opt_a) {
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))) {
no_support("detection commands");
} 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");
} 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");
}
- if (mode == DETECT_MODE_AUTO) {
+ if (mode == I2CDETECT_MODE_AUTO) {
if (!(funcs & I2C_FUNC_SMBUS_QUICK))
will_skip("SMBus Quick Write");
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++) {
fflush_all();
- if (mode == DETECT_MODE_AUTO) {
+ if (mode == I2CDETECT_MODE_AUTO) {
if ((i+j >= 0x30 && i+j <= 0x37) ||
(i+j >= 0x50 && i+j <= 0x5F))
- mode = DETECT_MODE_READ;
+ mode = I2CDETECT_MODE_READ;
else
- mode = DETECT_MODE_QUICK;
+ mode = I2CDETECT_MODE_QUICK;
}
/* Skip unwanted addresses. */
if (i+j < first
|| i+j > last
- || (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE))
- || (mode == DETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)))
+ || (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE))
+ || (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)))
{
printf(" ");
continue;
@@ -1303,14 +1303,14 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
}
switch (mode) {
- case DETECT_MODE_READ:
+ case I2CDETECT_MODE_READ:
/*
* This is known to lock SMBus on various
* write-only chips (mainly clock chips).
*/
status = i2c_smbus_read_byte(fd);
break;
- default: /* DETECT_MODE_QUICK: */
+ default: /* I2CDETECT_MODE_QUICK: */
/*
* This is known to corrupt the Atmel
* AT24RF08 EEPROM.