diff options
-rw-r--r-- | miscutils/i2c_tools.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index d77e6bacf..c5baaa78e 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c | |||
@@ -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 = I2CDETECT_MODE_AUTO, status; | 1203 | int fd, bus_num, i, j, mode = I2CDETECT_MODE_AUTO, status, cmd; |
1204 | unsigned first = 0x03, last = 0x77, opts; | 1204 | unsigned first = 0x03, last = 0x77, opts; |
1205 | unsigned long funcs; | 1205 | unsigned long funcs; |
1206 | 1206 | ||
@@ -1273,19 +1273,20 @@ 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 | cmd = mode; | ||
1276 | if (mode == I2CDETECT_MODE_AUTO) { | 1277 | if (mode == I2CDETECT_MODE_AUTO) { |
1277 | if ((i+j >= 0x30 && i+j <= 0x37) || | 1278 | if ((i+j >= 0x30 && i+j <= 0x37) || |
1278 | (i+j >= 0x50 && i+j <= 0x5F)) | 1279 | (i+j >= 0x50 && i+j <= 0x5F)) |
1279 | mode = I2CDETECT_MODE_READ; | 1280 | cmd = I2CDETECT_MODE_READ; |
1280 | else | 1281 | else |
1281 | mode = I2CDETECT_MODE_QUICK; | 1282 | cmd = I2CDETECT_MODE_QUICK; |
1282 | } | 1283 | } |
1283 | 1284 | ||
1284 | /* Skip unwanted addresses. */ | 1285 | /* Skip unwanted addresses. */ |
1285 | if (i+j < first | 1286 | if (i+j < first |
1286 | || i+j > last | 1287 | || i+j > last |
1287 | || (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) | 1288 | || (cmd == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) |
1288 | || (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK))) | 1289 | || (cmd == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK))) |
1289 | { | 1290 | { |
1290 | printf(" "); | 1291 | printf(" "); |
1291 | continue; | 1292 | continue; |
@@ -1302,7 +1303,7 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
1302 | "can't set address to 0x%02x", i + j); | 1303 | "can't set address to 0x%02x", i + j); |
1303 | } | 1304 | } |
1304 | 1305 | ||
1305 | switch (mode) { | 1306 | switch (cmd) { |
1306 | case I2CDETECT_MODE_READ: | 1307 | case I2CDETECT_MODE_READ: |
1307 | /* | 1308 | /* |
1308 | * This is known to lock SMBus on various | 1309 | * This is known to lock SMBus on various |