diff options
author | Bartosz Golaszewski <bartekgola@gmail.com> | 2015-09-04 10:38:48 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-09-21 13:15:01 +0200 |
commit | 2beb52499eccaee26e7e5c6fc10df73f6802efd9 (patch) | |
tree | 29bd1b27a06c8ce84b0e83da42c8770038bf2d07 | |
parent | d9892fa0c3abf28b71996e5bc7c133f29f987a7b (diff) | |
download | busybox-w32-2beb52499eccaee26e7e5c6fc10df73f6802efd9.tar.gz busybox-w32-2beb52499eccaee26e7e5c6fc10df73f6802efd9.tar.bz2 busybox-w32-2beb52499eccaee26e7e5c6fc10df73f6802efd9.zip |
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>
-rw-r--r-- | miscutils/i2c_tools.c | 46 |
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 @@ | |||
64 | #include <linux/i2c.h> | 64 | #include <linux/i2c.h> |
65 | #include <linux/i2c-dev.h> | 65 | #include <linux/i2c-dev.h> |
66 | 66 | ||
67 | #define I2C_MAX_REGS 256 | 67 | #define I2CDUMP_NUM_REGS 256 |
68 | 68 | ||
69 | #define DETECT_MODE_AUTO 0 | 69 | #define I2CDETECT_MODE_AUTO 0 |
70 | #define DETECT_MODE_QUICK 1 | 70 | #define I2CDETECT_MODE_QUICK 1 |
71 | #define DETECT_MODE_READ 2 | 71 | #define I2CDETECT_MODE_READ 2 |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * This is needed for ioctl_or_perror_and_die() since it only accepts pointers. | 74 | * 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) | |||
720 | #if ENABLE_I2CDUMP | 720 | #if ENABLE_I2CDUMP |
721 | static int read_block_data(int buf_fd, int mode, int *block) | 721 | static int read_block_data(int buf_fd, int mode, int *block) |
722 | { | 722 | { |
723 | uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2C_MAX_REGS]; | 723 | uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2CDUMP_NUM_REGS]; |
724 | int res, blen = 0, tmp, i; | 724 | int res, blen = 0, tmp, i; |
725 | 725 | ||
726 | if (mode == I2C_SMBUS_BLOCK_DATA || mode == I2C_SMBUS_I2C_BLOCK_DATA) { | 726 | if (mode == I2C_SMBUS_BLOCK_DATA || mode == I2C_SMBUS_I2C_BLOCK_DATA) { |
727 | res = i2c_smbus_read_block_data(buf_fd, 0, cblock); | 727 | res = i2c_smbus_read_block_data(buf_fd, 0, cblock); |
728 | blen = res; | 728 | blen = res; |
729 | } else { | 729 | } else { |
730 | for (res = 0; res < I2C_MAX_REGS; res += tmp) { | 730 | for (res = 0; res < I2CDUMP_NUM_REGS; res += tmp) { |
731 | tmp = i2c_smbus_read_i2c_block_data( | 731 | tmp = i2c_smbus_read_i2c_block_data( |
732 | buf_fd, res, I2C_SMBUS_BLOCK_MAX, | 732 | buf_fd, res, I2C_SMBUS_BLOCK_MAX, |
733 | cblock + res); | 733 | cblock + res); |
@@ -736,14 +736,14 @@ static int read_block_data(int buf_fd, int mode, int *block) | |||
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | if (res >= I2C_MAX_REGS) | 739 | if (res >= I2CDUMP_NUM_REGS) |
740 | res = I2C_MAX_REGS; | 740 | res = I2CDUMP_NUM_REGS; |
741 | 741 | ||
742 | for (i = 0; i < res; i++) | 742 | for (i = 0; i < res; i++) |
743 | block[i] = cblock[i]; | 743 | block[i] = cblock[i]; |
744 | 744 | ||
745 | if (mode != I2C_SMBUS_BLOCK_DATA) | 745 | if (mode != I2C_SMBUS_BLOCK_DATA) |
746 | for (i = res; i < I2C_MAX_REGS; i++) | 746 | for (i = res; i < I2CDUMP_NUM_REGS; i++) |
747 | block[i] = -1; | 747 | block[i] = -1; |
748 | } | 748 | } |
749 | 749 | ||
@@ -759,7 +759,7 @@ static void dump_data(int bus_fd, int mode, unsigned first, | |||
759 | printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f" | 759 | printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f" |
760 | " 0123456789abcdef\n"); | 760 | " 0123456789abcdef\n"); |
761 | 761 | ||
762 | for (i = 0; i < I2C_MAX_REGS; i += 0x10) { | 762 | for (i = 0; i < I2CDUMP_NUM_REGS; i += 0x10) { |
763 | if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen) | 763 | if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen) |
764 | break; | 764 | break; |
765 | if (i/16 < first/16) | 765 | if (i/16 < first/16) |
@@ -1200,7 +1200,7 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
1200 | opt_F = (1 << 4), opt_l = (1 << 5); | 1200 | opt_F = (1 << 4), opt_l = (1 << 5); |
1201 | const char *const optstr = "yaqrFl"; | 1201 | const char *const optstr = "yaqrFl"; |
1202 | 1202 | ||
1203 | int fd, bus_num, i, j, mode = DETECT_MODE_AUTO, status; | 1203 | int fd, bus_num, i, j, mode = I2CDETECT_MODE_AUTO, status; |
1204 | unsigned first = 0x03, last = 0x77, opts; | 1204 | unsigned first = 0x03, last = 0x77, opts; |
1205 | unsigned long funcs; | 1205 | unsigned long funcs; |
1206 | 1206 | ||
@@ -1231,9 +1231,9 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | if (opts & opt_r) | 1233 | if (opts & opt_r) |
1234 | mode = DETECT_MODE_READ; | 1234 | mode = I2CDETECT_MODE_READ; |
1235 | else if (opts & opt_q) | 1235 | else if (opts & opt_q) |
1236 | mode = DETECT_MODE_QUICK; | 1236 | mode = I2CDETECT_MODE_QUICK; |
1237 | 1237 | ||
1238 | if (opts & opt_a) { | 1238 | if (opts & opt_a) { |
1239 | first = 0x00; | 1239 | first = 0x00; |
@@ -1250,14 +1250,14 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
1250 | if (!(funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) { | 1250 | if (!(funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) { |
1251 | no_support("detection commands"); | 1251 | no_support("detection commands"); |
1252 | } else | 1252 | } else |
1253 | if (mode == DETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)) { | 1253 | if (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)) { |
1254 | no_support("SMBus Quick Write command"); | 1254 | no_support("SMBus Quick Write command"); |
1255 | } else | 1255 | } else |
1256 | if (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { | 1256 | if (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { |
1257 | no_support("SMBus Receive Byte command"); | 1257 | no_support("SMBus Receive Byte command"); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | if (mode == DETECT_MODE_AUTO) { | 1260 | if (mode == I2CDETECT_MODE_AUTO) { |
1261 | if (!(funcs & I2C_FUNC_SMBUS_QUICK)) | 1261 | if (!(funcs & I2C_FUNC_SMBUS_QUICK)) |
1262 | will_skip("SMBus Quick Write"); | 1262 | will_skip("SMBus Quick Write"); |
1263 | if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) | 1263 | if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) |
@@ -1273,19 +1273,19 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
1273 | for(j = 0; j < 16; j++) { | 1273 | for(j = 0; j < 16; j++) { |
1274 | fflush_all(); | 1274 | fflush_all(); |
1275 | 1275 | ||
1276 | if (mode == DETECT_MODE_AUTO) { | 1276 | if (mode == I2CDETECT_MODE_AUTO) { |
1277 | if ((i+j >= 0x30 && i+j <= 0x37) || | 1277 | if ((i+j >= 0x30 && i+j <= 0x37) || |
1278 | (i+j >= 0x50 && i+j <= 0x5F)) | 1278 | (i+j >= 0x50 && i+j <= 0x5F)) |
1279 | mode = DETECT_MODE_READ; | 1279 | mode = I2CDETECT_MODE_READ; |
1280 | else | 1280 | else |
1281 | mode = DETECT_MODE_QUICK; | 1281 | mode = I2CDETECT_MODE_QUICK; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | /* Skip unwanted addresses. */ | 1284 | /* Skip unwanted addresses. */ |
1285 | if (i+j < first | 1285 | if (i+j < first |
1286 | || i+j > last | 1286 | || i+j > last |
1287 | || (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) | 1287 | || (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) |
1288 | || (mode == DETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK))) | 1288 | || (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK))) |
1289 | { | 1289 | { |
1290 | printf(" "); | 1290 | printf(" "); |
1291 | continue; | 1291 | continue; |
@@ -1303,14 +1303,14 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | switch (mode) { | 1305 | switch (mode) { |
1306 | case DETECT_MODE_READ: | 1306 | case I2CDETECT_MODE_READ: |
1307 | /* | 1307 | /* |
1308 | * This is known to lock SMBus on various | 1308 | * This is known to lock SMBus on various |
1309 | * write-only chips (mainly clock chips). | 1309 | * write-only chips (mainly clock chips). |
1310 | */ | 1310 | */ |
1311 | status = i2c_smbus_read_byte(fd); | 1311 | status = i2c_smbus_read_byte(fd); |
1312 | break; | 1312 | break; |
1313 | default: /* DETECT_MODE_QUICK: */ | 1313 | default: /* I2CDETECT_MODE_QUICK: */ |
1314 | /* | 1314 | /* |
1315 | * This is known to corrupt the Atmel | 1315 | * This is known to corrupt the Atmel |
1316 | * AT24RF08 EEPROM. | 1316 | * AT24RF08 EEPROM. |