diff options
Diffstat (limited to 'miscutils/i2c_tools.c')
-rw-r--r-- | miscutils/i2c_tools.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 7a2e8534a..82a559f74 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c | |||
@@ -344,7 +344,7 @@ static void get_funcs_matrix(int fd, unsigned long *funcs) | |||
344 | static void check_funcs_test_end(int funcs, int pec, const char *err) | 344 | static void check_funcs_test_end(int funcs, int pec, const char *err) |
345 | { | 345 | { |
346 | if (pec && !(funcs & (I2C_FUNC_SMBUS_PEC | I2C_FUNC_I2C))) | 346 | if (pec && !(funcs & (I2C_FUNC_SMBUS_PEC | I2C_FUNC_I2C))) |
347 | bb_error_msg("warning: adapter does not support PEC"); | 347 | bb_simple_error_msg("warning: adapter does not support PEC"); |
348 | 348 | ||
349 | if (err) | 349 | if (err) |
350 | bb_error_msg_and_die( | 350 | bb_error_msg_and_die( |
@@ -392,7 +392,7 @@ static void check_read_funcs(int fd, int mode, int data_addr, int pec) | |||
392 | break; | 392 | break; |
393 | #endif /* ENABLE_I2CDUMP */ | 393 | #endif /* ENABLE_I2CDUMP */ |
394 | default: | 394 | default: |
395 | bb_error_msg_and_die("internal error"); | 395 | bb_simple_error_msg_and_die("internal error"); |
396 | } | 396 | } |
397 | check_funcs_test_end(funcs, pec, err); | 397 | check_funcs_test_end(funcs, pec, err); |
398 | } | 398 | } |
@@ -438,7 +438,7 @@ static void confirm_or_abort(void) | |||
438 | { | 438 | { |
439 | fprintf(stderr, "Continue? [y/N] "); | 439 | fprintf(stderr, "Continue? [y/N] "); |
440 | if (!bb_ask_y_confirmation()) | 440 | if (!bb_ask_y_confirmation()) |
441 | bb_error_msg_and_die("aborting"); | 441 | bb_simple_error_msg_and_die("aborting"); |
442 | } | 442 | } |
443 | 443 | ||
444 | /* | 444 | /* |
@@ -449,20 +449,20 @@ static void confirm_or_abort(void) | |||
449 | */ | 449 | */ |
450 | static void confirm_action(int bus_addr, int mode, int data_addr, int pec) | 450 | static void confirm_action(int bus_addr, int mode, int data_addr, int pec) |
451 | { | 451 | { |
452 | bb_error_msg("WARNING! This program can confuse your I2C bus"); | 452 | bb_simple_error_msg("WARNING! This program can confuse your I2C bus"); |
453 | 453 | ||
454 | /* Don't let the user break his/her EEPROMs */ | 454 | /* Don't let the user break his/her EEPROMs */ |
455 | if (bus_addr >= 0x50 && bus_addr <= 0x57 && pec) { | 455 | if (bus_addr >= 0x50 && bus_addr <= 0x57 && pec) { |
456 | bb_error_msg_and_die("this is I2C not smbus - using PEC on I2C " | 456 | bb_simple_error_msg_and_die("this is I2C not smbus - using PEC on I2C " |
457 | "devices may result in data loss, aborting"); | 457 | "devices may result in data loss, aborting"); |
458 | } | 458 | } |
459 | 459 | ||
460 | if (mode == I2C_SMBUS_BYTE && data_addr >= 0 && pec) | 460 | if (mode == I2C_SMBUS_BYTE && data_addr >= 0 && pec) |
461 | bb_error_msg("WARNING! May interpret a write byte command " | 461 | bb_simple_error_msg("WARNING! May interpret a write byte command " |
462 | "with PEC as a write byte data command"); | 462 | "with PEC as a write byte data command"); |
463 | 463 | ||
464 | if (pec) | 464 | if (pec) |
465 | bb_error_msg("PEC checking enabled"); | 465 | bb_simple_error_msg("PEC checking enabled"); |
466 | 466 | ||
467 | confirm_or_abort(); | 467 | confirm_or_abort(); |
468 | } | 468 | } |
@@ -507,7 +507,7 @@ int i2cget_main(int argc UNUSED_PARAM, char **argv) | |||
507 | case 'w': mode = I2C_SMBUS_WORD_DATA; break; | 507 | case 'w': mode = I2C_SMBUS_WORD_DATA; break; |
508 | case 'c': mode = I2C_SMBUS_BYTE; break; | 508 | case 'c': mode = I2C_SMBUS_BYTE; break; |
509 | default: | 509 | default: |
510 | bb_error_msg("invalid mode"); | 510 | bb_simple_error_msg("invalid mode"); |
511 | bb_show_usage(); | 511 | bb_show_usage(); |
512 | } | 512 | } |
513 | pec = argv[3][1] == 'p'; | 513 | pec = argv[3][1] == 'p'; |
@@ -529,7 +529,7 @@ int i2cget_main(int argc UNUSED_PARAM, char **argv) | |||
529 | if (data_addr >= 0) { | 529 | if (data_addr >= 0) { |
530 | status = i2c_smbus_write_byte(fd, data_addr); | 530 | status = i2c_smbus_write_byte(fd, data_addr); |
531 | if (status < 0) | 531 | if (status < 0) |
532 | bb_error_msg("warning - write failed"); | 532 | bb_simple_error_msg("warning - write failed"); |
533 | } | 533 | } |
534 | status = i2c_smbus_read_byte(fd); | 534 | status = i2c_smbus_read_byte(fd); |
535 | break; | 535 | break; |
@@ -542,7 +542,7 @@ int i2cget_main(int argc UNUSED_PARAM, char **argv) | |||
542 | close(fd); | 542 | close(fd); |
543 | 543 | ||
544 | if (status < 0) | 544 | if (status < 0) |
545 | bb_perror_msg_and_die("read failed"); | 545 | bb_simple_perror_msg_and_die("read failed"); |
546 | 546 | ||
547 | printf("0x%0*x\n", mode == I2C_SMBUS_WORD_DATA ? 4 : 2, status); | 547 | printf("0x%0*x\n", mode == I2C_SMBUS_WORD_DATA ? 4 : 2, status); |
548 | 548 | ||
@@ -611,7 +611,7 @@ int i2cset_main(int argc, char **argv) | |||
611 | case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; | 611 | case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; |
612 | break; | 612 | break; |
613 | default: | 613 | default: |
614 | bb_error_msg("invalid mode"); | 614 | bb_simple_error_msg("invalid mode"); |
615 | bb_show_usage(); | 615 | bb_show_usage(); |
616 | } | 616 | } |
617 | 617 | ||
@@ -620,11 +620,11 @@ int i2cset_main(int argc, char **argv) | |||
620 | || mode == I2C_SMBUS_I2C_BLOCK_DATA | 620 | || mode == I2C_SMBUS_I2C_BLOCK_DATA |
621 | ) { | 621 | ) { |
622 | if (pec && mode == I2C_SMBUS_I2C_BLOCK_DATA) | 622 | if (pec && mode == I2C_SMBUS_I2C_BLOCK_DATA) |
623 | bb_error_msg_and_die( | 623 | bb_simple_error_msg_and_die( |
624 | "PEC not supported for I2C " | 624 | "PEC not supported for I2C " |
625 | "block writes"); | 625 | "block writes"); |
626 | if (opts & opt_m) | 626 | if (opts & opt_m) |
627 | bb_error_msg_and_die( | 627 | bb_simple_error_msg_and_die( |
628 | "mask not supported for block " | 628 | "mask not supported for block " |
629 | "writes"); | 629 | "writes"); |
630 | } | 630 | } |
@@ -685,7 +685,7 @@ int i2cset_main(int argc, char **argv) | |||
685 | } | 685 | } |
686 | 686 | ||
687 | if (tmpval < 0) | 687 | if (tmpval < 0) |
688 | bb_perror_msg_and_die("can't read old value"); | 688 | bb_simple_perror_msg_and_die("can't read old value"); |
689 | 689 | ||
690 | val = (val & mask) | (tmpval & ~mask); | 690 | val = (val & mask) | (tmpval & ~mask); |
691 | 691 | ||
@@ -724,7 +724,7 @@ int i2cset_main(int argc, char **argv) | |||
724 | break; | 724 | break; |
725 | } | 725 | } |
726 | if (status < 0) | 726 | if (status < 0) |
727 | bb_perror_msg_and_die("write failed"); | 727 | bb_simple_perror_msg_and_die("write failed"); |
728 | 728 | ||
729 | if (pec) | 729 | if (pec) |
730 | i2c_set_pec(fd, 0); /* Clear PEC. */ | 730 | i2c_set_pec(fd, 0); /* Clear PEC. */ |
@@ -978,12 +978,12 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) | |||
978 | case 's': mode = I2C_SMBUS_BLOCK_DATA; break; | 978 | case 's': mode = I2C_SMBUS_BLOCK_DATA; break; |
979 | case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; break; | 979 | case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; break; |
980 | default: | 980 | default: |
981 | bb_error_msg_and_die("invalid mode"); | 981 | bb_simple_error_msg_and_die("invalid mode"); |
982 | } | 982 | } |
983 | 983 | ||
984 | if (argv[2][1] == 'p') { | 984 | if (argv[2][1] == 'p') { |
985 | if (argv[2][0] == 'W' || argv[2][0] == 'i') { | 985 | if (argv[2][0] == 'W' || argv[2][0] == 'i') { |
986 | bb_error_msg_and_die( | 986 | bb_simple_error_msg_and_die( |
987 | "pec not supported for -W and -i"); | 987 | "pec not supported for -W and -i"); |
988 | } else { | 988 | } else { |
989 | pec = 1; | 989 | pec = 1; |
@@ -994,7 +994,7 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) | |||
994 | if (opts & opt_r) { | 994 | if (opts & opt_r) { |
995 | first = strtol(opt_r_str, &dash, 0); | 995 | first = strtol(opt_r_str, &dash, 0); |
996 | if (dash == opt_r_str || *dash != '-' || first > 0xff) | 996 | if (dash == opt_r_str || *dash != '-' || first > 0xff) |
997 | bb_error_msg_and_die("invalid range"); | 997 | bb_simple_error_msg_and_die("invalid range"); |
998 | last = xstrtou_range(++dash, 0, first, 0xff); | 998 | last = xstrtou_range(++dash, 0, first, 0xff); |
999 | 999 | ||
1000 | /* Range is not available for every mode. */ | 1000 | /* Range is not available for every mode. */ |
@@ -1007,7 +1007,7 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) | |||
1007 | break; | 1007 | break; |
1008 | /* Fall through */ | 1008 | /* Fall through */ |
1009 | default: | 1009 | default: |
1010 | bb_error_msg_and_die( | 1010 | bb_simple_error_msg_and_die( |
1011 | "range not compatible with selected mode"); | 1011 | "range not compatible with selected mode"); |
1012 | } | 1012 | } |
1013 | } | 1013 | } |
@@ -1032,7 +1032,7 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) | |||
1032 | if (mode == I2C_SMBUS_BYTE) { | 1032 | if (mode == I2C_SMBUS_BYTE) { |
1033 | res = i2c_smbus_write_byte(fd, first); | 1033 | res = i2c_smbus_write_byte(fd, first); |
1034 | if (res < 0) | 1034 | if (res < 0) |
1035 | bb_perror_msg_and_die("write start address"); | 1035 | bb_simple_perror_msg_and_die("write start address"); |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | dump_data(fd, mode, first, last, block, blen); | 1038 | dump_data(fd, mode, first, last, block, blen); |
@@ -1398,7 +1398,7 @@ static void check_i2c_func(int fd) | |||
1398 | get_funcs_matrix(fd, &funcs); | 1398 | get_funcs_matrix(fd, &funcs); |
1399 | 1399 | ||
1400 | if (!(funcs & I2C_FUNC_I2C)) | 1400 | if (!(funcs & I2C_FUNC_I2C)) |
1401 | bb_error_msg_and_die("adapter does not support I2C transfers"); | 1401 | bb_simple_error_msg_and_die("adapter does not support I2C transfers"); |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | //usage:#define i2ctransfer_trivial_usage | 1404 | //usage:#define i2ctransfer_trivial_usage |
@@ -1451,7 +1451,7 @@ int i2ctransfer_main(int argc UNUSED_PARAM, char **argv) | |||
1451 | char *end; | 1451 | char *end; |
1452 | 1452 | ||
1453 | if (nmsgs >= I2C_RDWR_IOCTL_MAX_MSGS) | 1453 | if (nmsgs >= I2C_RDWR_IOCTL_MAX_MSGS) |
1454 | bb_error_msg_and_die("too many messages, max: "I2C_RDWR_IOCTL_MAX_MSGS_STR); | 1454 | bb_simple_error_msg_and_die("too many messages, max: "I2C_RDWR_IOCTL_MAX_MSGS_STR); |
1455 | 1455 | ||
1456 | flags = 0; | 1456 | flags = 0; |
1457 | arg_ptr = *argv; | 1457 | arg_ptr = *argv; |