diff options
| author | Ron Yorston <rmy@pobox.com> | 2015-10-13 14:45:51 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2015-10-13 14:45:51 +0100 |
| commit | 8e509f11bceeec419abc718300bef7422d1fee4c (patch) | |
| tree | fdfbc752ad94102e3613a5d7254f14a93eaf7f56 /miscutils | |
| parent | 420f5edfe7676fe6e7cddbbf15c04649d096e422 (diff) | |
| parent | 4d0c1ea4784c9844f8468d97ca5c26d3c70f9921 (diff) | |
| download | busybox-w32-8e509f11bceeec419abc718300bef7422d1fee4c.tar.gz busybox-w32-8e509f11bceeec419abc718300bef7422d1fee4c.tar.bz2 busybox-w32-8e509f11bceeec419abc718300bef7422d1fee4c.zip | |
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/devfsd.c | 19 | ||||
| -rw-r--r-- | miscutils/hdparm.c | 58 | ||||
| -rw-r--r-- | miscutils/i2c_tools.c | 210 | ||||
| -rw-r--r-- | miscutils/last.c | 3 |
4 files changed, 96 insertions, 194 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 5a6aec6bd..9256567cc 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
| @@ -1142,19 +1142,19 @@ static void signal_handler(int sig) | |||
| 1142 | 1142 | ||
| 1143 | static const char *get_variable(const char *variable, void *info) | 1143 | static const char *get_variable(const char *variable, void *info) |
| 1144 | { | 1144 | { |
| 1145 | static char sbuf[sizeof(int)*3 + 2]; /* sign and NUL */ | ||
| 1146 | static char *hostname; | 1145 | static char *hostname; |
| 1147 | 1146 | ||
| 1148 | struct get_variable_info *gv_info = info; | 1147 | struct get_variable_info *gv_info = info; |
| 1149 | const char *field_names[] = { | 1148 | const char *field_names[] = { |
| 1150 | "hostname", "mntpt", "devpath", "devname", | 1149 | "hostname", "mntpt", "devpath", "devname", "uid", "gid", "mode", |
| 1151 | "uid", "gid", "mode", hostname, mount_point, | 1150 | NULL, mount_point, gv_info->devpath, gv_info->devname, NULL |
| 1152 | gv_info->devpath, gv_info->devname, NULL | ||
| 1153 | }; | 1151 | }; |
| 1154 | int i; | 1152 | int i; |
| 1155 | 1153 | ||
| 1156 | if (!hostname) | 1154 | if (!hostname) |
| 1157 | hostname = safe_gethostname(); | 1155 | hostname = safe_gethostname(); |
| 1156 | field_names[7] = hostname; | ||
| 1157 | |||
| 1158 | /* index_in_str_array returns i>=0 */ | 1158 | /* index_in_str_array returns i>=0 */ |
| 1159 | i = index_in_str_array(field_names, variable); | 1159 | i = index_in_str_array(field_names, variable); |
| 1160 | 1160 | ||
| @@ -1164,12 +1164,11 @@ static const char *get_variable(const char *variable, void *info) | |||
| 1164 | return field_names[i + 7]; | 1164 | return field_names[i + 7]; |
| 1165 | 1165 | ||
| 1166 | if (i == 4) | 1166 | if (i == 4) |
| 1167 | sprintf(sbuf, "%u", gv_info->info->uid); | 1167 | return auto_string(xasprintf("%u", gv_info->info->uid)); |
| 1168 | else if (i == 5) | 1168 | if (i == 5) |
| 1169 | sprintf(sbuf, "%u", gv_info->info->gid); | 1169 | return auto_string(xasprintf("%u", gv_info->info->gid)); |
| 1170 | else if (i == 6) | 1170 | /* i == 6 */ |
| 1171 | sprintf(sbuf, "%o", gv_info->info->mode); | 1171 | return auto_string(xasprintf("%o", gv_info->info->mode)); |
| 1172 | return sbuf; | ||
| 1173 | } /* End Function get_variable */ | 1172 | } /* End Function get_variable */ |
| 1174 | 1173 | ||
| 1175 | static void service(struct stat statbuf, char *path) | 1174 | static void service(struct stat statbuf, char *path) |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index f0e9c9d75..9c486e7aa 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
| @@ -763,9 +763,9 @@ static void identify(uint16_t *val) | |||
| 763 | ) { | 763 | ) { |
| 764 | like_std = 5; | 764 | like_std = 5; |
| 765 | if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL)) | 765 | if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL)) |
| 766 | printf("powers-up in standby; SET FEATURES subcmd spins-up.\n"); | 766 | puts("powers-up in standby; SET FEATURES subcmd spins-up."); |
| 767 | if (((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE)) | 767 | if (((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE)) |
| 768 | printf("\n\tWARNING: ID response incomplete.\n\tFollowing data may be incorrect.\n\n"); | 768 | puts("\n\tWARNING: ID response incomplete.\n\tFollowing data may be incorrect.\n"); |
| 769 | } | 769 | } |
| 770 | 770 | ||
| 771 | /* output the model and serial numbers and the fw revision */ | 771 | /* output the model and serial numbers and the fw revision */ |
| @@ -875,7 +875,7 @@ static void identify(uint16_t *val) | |||
| 875 | if (min_std == 0xffff) | 875 | if (min_std == 0xffff) |
| 876 | min_std = like_std > 4 ? like_std - 3 : 1; | 876 | min_std = like_std > 4 ? like_std - 3 : 1; |
| 877 | 877 | ||
| 878 | printf("Configuration:\n"); | 878 | puts("Configuration:"); |
| 879 | /* more info from the general configuration word */ | 879 | /* more info from the general configuration word */ |
| 880 | if ((eqpt != CDROM) && (like_std == 1)) { | 880 | if ((eqpt != CDROM) && (like_std == 1)) { |
| 881 | jj = val[GEN_CONFIG] >> 1; | 881 | jj = val[GEN_CONFIG] >> 1; |
| @@ -909,7 +909,7 @@ static void identify(uint16_t *val) | |||
| 909 | mm = 0; | 909 | mm = 0; |
| 910 | bbbig = 0; | 910 | bbbig = 0; |
| 911 | if ((ll > 0x00FBFC10) && (!val[LCYLS])) | 911 | if ((ll > 0x00FBFC10) && (!val[LCYLS])) |
| 912 | printf("\tCHS addressing not supported\n"); | 912 | puts("\tCHS addressing not supported"); |
| 913 | else { | 913 | else { |
| 914 | jj = val[WHATS_VALID] & OK_W54_58; | 914 | jj = val[WHATS_VALID] & OK_W54_58; |
| 915 | printf("\tLogical\t\tmax\tcurrent\n" | 915 | printf("\tLogical\t\tmax\tcurrent\n" |
| @@ -980,7 +980,7 @@ static void identify(uint16_t *val) | |||
| 980 | !(val[CAPAB_0] & IORDY_SUP) ? "(may be)" : "", | 980 | !(val[CAPAB_0] & IORDY_SUP) ? "(may be)" : "", |
| 981 | (val[CAPAB_0] & IORDY_OFF) ? "" :"not"); | 981 | (val[CAPAB_0] & IORDY_OFF) ? "" :"not"); |
| 982 | } else | 982 | } else |
| 983 | printf("no IORDY\n"); | 983 | puts("no IORDY"); |
| 984 | 984 | ||
| 985 | if ((like_std == 1) && val[BUF_TYPE]) { | 985 | if ((like_std == 1) && val[BUF_TYPE]) { |
| 986 | printf("\tBuffer type: %04x: %s%s\n", val[BUF_TYPE], | 986 | printf("\tBuffer type: %04x: %s%s\n", val[BUF_TYPE], |
| @@ -1012,13 +1012,13 @@ static void identify(uint16_t *val) | |||
| 1012 | } | 1012 | } |
| 1013 | printf("\tR/W multiple sector transfer: "); | 1013 | printf("\tR/W multiple sector transfer: "); |
| 1014 | if ((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER)) | 1014 | if ((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER)) |
| 1015 | printf("not supported\n"); | 1015 | puts("not supported"); |
| 1016 | else { | 1016 | else { |
| 1017 | printf("Max = %u\tCurrent = ", val[SECTOR_XFER_MAX] & SECTOR_XFER); | 1017 | printf("Max = %u\tCurrent = ", val[SECTOR_XFER_MAX] & SECTOR_XFER); |
| 1018 | if (val[SECTOR_XFER_CUR] & MULTIPLE_SETTING_VALID) | 1018 | if (val[SECTOR_XFER_CUR] & MULTIPLE_SETTING_VALID) |
| 1019 | printf("%u\n", val[SECTOR_XFER_CUR] & SECTOR_XFER); | 1019 | printf("%u\n", val[SECTOR_XFER_CUR] & SECTOR_XFER); |
| 1020 | else | 1020 | else |
| 1021 | printf("?\n"); | 1021 | puts("?"); |
| 1022 | } | 1022 | } |
| 1023 | if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) { | 1023 | if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) { |
| 1024 | /* We print out elsewhere whether the APM feature is enabled or | 1024 | /* We print out elsewhere whether the APM feature is enabled or |
| @@ -1040,7 +1040,7 @@ static void identify(uint16_t *val) | |||
| 1040 | } else { | 1040 | } else { |
| 1041 | /* ATAPI */ | 1041 | /* ATAPI */ |
| 1042 | if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ)) | 1042 | if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ)) |
| 1043 | printf("\tATA sw reset required\n"); | 1043 | puts("\tATA sw reset required"); |
| 1044 | 1044 | ||
| 1045 | if (val[PKT_REL] || val[SVC_NBSY]) { | 1045 | if (val[PKT_REL] || val[SVC_NBSY]) { |
| 1046 | printf("\tOverlap support:"); | 1046 | printf("\tOverlap support:"); |
| @@ -1056,7 +1056,7 @@ static void identify(uint16_t *val) | |||
| 1056 | /* DMA stuff. Check that only one DMA mode is selected. */ | 1056 | /* DMA stuff. Check that only one DMA mode is selected. */ |
| 1057 | printf("\tDMA: "); | 1057 | printf("\tDMA: "); |
| 1058 | if (!(val[CAPAB_0] & DMA_SUP)) | 1058 | if (!(val[CAPAB_0] & DMA_SUP)) |
| 1059 | printf("not supported\n"); | 1059 | puts("not supported"); |
| 1060 | else { | 1060 | else { |
| 1061 | if (val[DMA_MODE] && !val[SINGLE_DMA] && !val[MULTI_DMA]) | 1061 | if (val[DMA_MODE] && !val[SINGLE_DMA] && !val[MULTI_DMA]) |
| 1062 | printf(" sdma%u\n", (val[DMA_MODE] & MODE) >> 8); | 1062 | printf(" sdma%u\n", (val[DMA_MODE] & MODE) >> 8); |
| @@ -1079,7 +1079,7 @@ static void identify(uint16_t *val) | |||
| 1079 | bb_putchar('\n'); | 1079 | bb_putchar('\n'); |
| 1080 | 1080 | ||
| 1081 | if ((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP)) | 1081 | if ((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP)) |
| 1082 | printf("\t\tInterleaved DMA support\n"); | 1082 | puts("\t\tInterleaved DMA support"); |
| 1083 | 1083 | ||
| 1084 | if ((val[WHATS_VALID] & OK_W64_70) | 1084 | if ((val[WHATS_VALID] & OK_W64_70) |
| 1085 | && (val[DMA_TIME_MIN] || val[DMA_TIME_NORM]) | 1085 | && (val[DMA_TIME_MIN] || val[DMA_TIME_NORM]) |
| @@ -1121,8 +1121,8 @@ static void identify(uint16_t *val) | |||
| 1121 | } | 1121 | } |
| 1122 | 1122 | ||
| 1123 | if ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) { | 1123 | if ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) { |
| 1124 | printf("Commands/features:\n" | 1124 | puts("Commands/features:\n" |
| 1125 | "\tEnabled\tSupported:\n"); | 1125 | "\tEnabled\tSupported:"); |
| 1126 | jj = val[CMDS_SUPP_0]; | 1126 | jj = val[CMDS_SUPP_0]; |
| 1127 | kk = val[CMDS_EN_0]; | 1127 | kk = val[CMDS_EN_0]; |
| 1128 | for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) { | 1128 | for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) { |
| @@ -1150,7 +1150,7 @@ static void identify(uint16_t *val) | |||
| 1150 | if ((eqpt != CDROM) && (like_std > 3) | 1150 | if ((eqpt != CDROM) && (like_std > 3) |
| 1151 | && (val[SECU_STATUS] || val[ERASE_TIME] || val[ENH_ERASE_TIME]) | 1151 | && (val[SECU_STATUS] || val[ERASE_TIME] || val[ENH_ERASE_TIME]) |
| 1152 | ) { | 1152 | ) { |
| 1153 | printf("Security:\n"); | 1153 | puts("Security:"); |
| 1154 | if (val[PSWD_CODE] && (val[PSWD_CODE] != NOVAL_1)) | 1154 | if (val[PSWD_CODE] && (val[PSWD_CODE] != NOVAL_1)) |
| 1155 | printf("\tMaster password revision code = %u\n", val[PSWD_CODE]); | 1155 | printf("\tMaster password revision code = %u\n", val[PSWD_CODE]); |
| 1156 | jj = val[SECU_STATUS]; | 1156 | jj = val[SECU_STATUS]; |
| @@ -1366,7 +1366,7 @@ static NOINLINE void dump_identity(const struct hd_driveid *id) | |||
| 1366 | } | 1366 | } |
| 1367 | } | 1367 | } |
| 1368 | #endif /* __NEW_HD_DRIVE_ID */ | 1368 | #endif /* __NEW_HD_DRIVE_ID */ |
| 1369 | printf("\n\n * current active mode\n\n"); | 1369 | puts("\n\n * current active mode\n"); |
| 1370 | } | 1370 | } |
| 1371 | #endif | 1371 | #endif |
| 1372 | 1372 | ||
| @@ -1507,7 +1507,7 @@ static void bus_state_value(unsigned value) | |||
| 1507 | else if (value == BUSSTATE_OFF) | 1507 | else if (value == BUSSTATE_OFF) |
| 1508 | on_off(0); | 1508 | on_off(0); |
| 1509 | else if (value == BUSSTATE_TRISTATE) | 1509 | else if (value == BUSSTATE_TRISTATE) |
| 1510 | printf(" (tristate)\n"); | 1510 | puts(" (tristate)"); |
| 1511 | else | 1511 | else |
| 1512 | printf(" (unknown: %u)\n", value); | 1512 | printf(" (unknown: %u)\n", value); |
| 1513 | } | 1513 | } |
| @@ -1531,7 +1531,7 @@ static void interpret_standby(uint8_t standby) | |||
| 1531 | printf("vendor-specific"); | 1531 | printf("vendor-specific"); |
| 1532 | if (standby == 254) | 1532 | if (standby == 254) |
| 1533 | printf("reserved"); | 1533 | printf("reserved"); |
| 1534 | printf(")\n"); | 1534 | puts(")"); |
| 1535 | } | 1535 | } |
| 1536 | 1536 | ||
| 1537 | static const uint8_t xfermode_val[] ALIGN1 = { | 1537 | static const uint8_t xfermode_val[] ALIGN1 = { |
| @@ -1582,7 +1582,7 @@ static void interpret_xfermode(unsigned xfermode) | |||
| 1582 | printf("UltraDMA mode%u", xfermode - 64); | 1582 | printf("UltraDMA mode%u", xfermode - 64); |
| 1583 | else | 1583 | else |
| 1584 | printf("unknown"); | 1584 | printf("unknown"); |
| 1585 | printf(")\n"); | 1585 | puts(")"); |
| 1586 | } | 1586 | } |
| 1587 | #endif /* HDIO_DRIVE_CMD */ | 1587 | #endif /* HDIO_DRIVE_CMD */ |
| 1588 | 1588 | ||
| @@ -1633,7 +1633,7 @@ static void process_dev(char *devname) | |||
| 1633 | if (noisy_piomode) { | 1633 | if (noisy_piomode) { |
| 1634 | printf(" attempting to "); | 1634 | printf(" attempting to "); |
| 1635 | if (piomode == 255) | 1635 | if (piomode == 255) |
| 1636 | printf("auto-tune PIO mode\n"); | 1636 | puts("auto-tune PIO mode"); |
| 1637 | else if (piomode < 100) | 1637 | else if (piomode < 100) |
| 1638 | printf("set PIO mode to %d\n", piomode); | 1638 | printf("set PIO mode to %d\n", piomode); |
| 1639 | else if (piomode < 200) | 1639 | else if (piomode < 200) |
| @@ -1762,7 +1762,7 @@ static void process_dev(char *devname) | |||
| 1762 | #ifndef WIN_STANDBYNOW2 | 1762 | #ifndef WIN_STANDBYNOW2 |
| 1763 | #define WIN_STANDBYNOW2 0x94 | 1763 | #define WIN_STANDBYNOW2 0x94 |
| 1764 | #endif | 1764 | #endif |
| 1765 | printf(" issuing standby command\n"); | 1765 | puts(" issuing standby command"); |
| 1766 | args[0] = WIN_STANDBYNOW1; | 1766 | args[0] = WIN_STANDBYNOW1; |
| 1767 | ioctl_alt_or_warn(HDIO_DRIVE_CMD, args, WIN_STANDBYNOW2); | 1767 | ioctl_alt_or_warn(HDIO_DRIVE_CMD, args, WIN_STANDBYNOW2); |
| 1768 | } | 1768 | } |
| @@ -1773,13 +1773,13 @@ static void process_dev(char *devname) | |||
| 1773 | #ifndef WIN_SLEEPNOW2 | 1773 | #ifndef WIN_SLEEPNOW2 |
| 1774 | #define WIN_SLEEPNOW2 0x99 | 1774 | #define WIN_SLEEPNOW2 0x99 |
| 1775 | #endif | 1775 | #endif |
| 1776 | printf(" issuing sleep command\n"); | 1776 | puts(" issuing sleep command"); |
| 1777 | args[0] = WIN_SLEEPNOW1; | 1777 | args[0] = WIN_SLEEPNOW1; |
| 1778 | ioctl_alt_or_warn(HDIO_DRIVE_CMD, args, WIN_SLEEPNOW2); | 1778 | ioctl_alt_or_warn(HDIO_DRIVE_CMD, args, WIN_SLEEPNOW2); |
| 1779 | } | 1779 | } |
| 1780 | if (set_seagate) { | 1780 | if (set_seagate) { |
| 1781 | args[0] = 0xfb; | 1781 | args[0] = 0xfb; |
| 1782 | printf(" disabling Seagate auto powersaving mode\n"); | 1782 | puts(" disabling Seagate auto powersaving mode"); |
| 1783 | ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args); | 1783 | ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args); |
| 1784 | } | 1784 | } |
| 1785 | if (getset_standby == IS_SET) { | 1785 | if (getset_standby == IS_SET) { |
| @@ -1815,17 +1815,17 @@ static void process_dev(char *devname) | |||
| 1815 | if (!ioctl_or_warn(fd, HDIO_GET_32BIT, &parm)) { | 1815 | if (!ioctl_or_warn(fd, HDIO_GET_32BIT, &parm)) { |
| 1816 | printf(" IO_support\t=%3ld (", parm); | 1816 | printf(" IO_support\t=%3ld (", parm); |
| 1817 | if (parm == 0) | 1817 | if (parm == 0) |
| 1818 | printf("default 16-bit)\n"); | 1818 | puts("default 16-bit)"); |
| 1819 | else if (parm == 2) | 1819 | else if (parm == 2) |
| 1820 | printf("16-bit)\n"); | 1820 | puts("16-bit)"); |
| 1821 | else if (parm == 1) | 1821 | else if (parm == 1) |
| 1822 | printf("32-bit)\n"); | 1822 | puts("32-bit)"); |
| 1823 | else if (parm == 3) | 1823 | else if (parm == 3) |
| 1824 | printf("32-bit w/sync)\n"); | 1824 | puts("32-bit w/sync)"); |
| 1825 | else if (parm == 8) | 1825 | else if (parm == 8) |
| 1826 | printf("Request-Queue-Bypass)\n"); | 1826 | puts("Request-Queue-Bypass)"); |
| 1827 | else | 1827 | else |
| 1828 | printf("\?\?\?)\n"); | 1828 | puts("\?\?\?)"); |
| 1829 | } | 1829 | } |
| 1830 | } | 1830 | } |
| 1831 | if (getset_unmask) { | 1831 | if (getset_unmask) { |
| @@ -1837,7 +1837,7 @@ static void process_dev(char *devname) | |||
| 1837 | if (!ioctl_or_warn(fd, HDIO_GET_DMA, &parm)) { | 1837 | if (!ioctl_or_warn(fd, HDIO_GET_DMA, &parm)) { |
| 1838 | printf(fmt, "using_dma", parm); | 1838 | printf(fmt, "using_dma", parm); |
| 1839 | if (parm == 8) | 1839 | if (parm == 8) |
| 1840 | printf(" (DMA-Assisted-PIO)\n"); | 1840 | puts(" (DMA-Assisted-PIO)"); |
| 1841 | else | 1841 | else |
| 1842 | on_off(parm != 0); | 1842 | on_off(parm != 0); |
| 1843 | } | 1843 | } |
| @@ -1921,7 +1921,7 @@ static void process_dev(char *devname) | |||
| 1921 | id.multsect_valid &= ~1; | 1921 | id.multsect_valid &= ~1; |
| 1922 | dump_identity(&id); | 1922 | dump_identity(&id); |
| 1923 | } else if (errno == -ENOMSG) | 1923 | } else if (errno == -ENOMSG) |
| 1924 | printf(" no identification info available\n"); | 1924 | puts(" no identification info available"); |
| 1925 | else if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */ | 1925 | else if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */ |
| 1926 | bb_perror_msg("HDIO_GET_IDENTITY"); | 1926 | bb_perror_msg("HDIO_GET_IDENTITY"); |
| 1927 | else | 1927 | else |
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 38d90ff10..d77e6bacf 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c | |||
| @@ -61,112 +61,14 @@ | |||
| 61 | 61 | ||
| 62 | #include "libbb.h" | 62 | #include "libbb.h" |
| 63 | 63 | ||
| 64 | /* | 64 | #include <linux/i2c.h> |
| 65 | * /dev/i2c-X ioctl commands. The ioctl's parameter is always an unsigned long, | 65 | #include <linux/i2c-dev.h> |
| 66 | * except for: | ||
| 67 | * - I2C_FUNCS, takes pointer to an unsigned long | ||
| 68 | * - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data | ||
| 69 | * - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data | ||
| 70 | */ | ||
| 71 | |||
| 72 | /* | ||
| 73 | * NOTE: Slave address is 7 or 10 bits, but 10-bit addresses | ||
| 74 | * are not supported due to code brokenness. | ||
| 75 | */ | ||
| 76 | 66 | ||
| 77 | /* Use this slave address. */ | 67 | #define I2CDUMP_NUM_REGS 256 |
| 78 | #define I2C_SLAVE 0x0703 | ||
| 79 | /* Use this slave address, even if it is already in use by a driver. */ | ||
| 80 | #define I2C_SLAVE_FORCE 0x0706 | ||
| 81 | /* 0 for 7 bit addrs, != 0 for 10 bit. */ | ||
| 82 | #define I2C_TENBIT 0x0704 | ||
| 83 | /* Get the adapter functionality mask. */ | ||
| 84 | #define I2C_FUNCS 0x0705 | ||
| 85 | /* Combined R/W transfer (one STOP only). */ | ||
| 86 | #define I2C_RDWR 0x0707 | ||
| 87 | /* != 0 to use PEC with SMBus. */ | ||
| 88 | #define I2C_PEC 0x0708 | ||
| 89 | /* SMBus transfer. */ | ||
| 90 | #define I2C_SMBUS 0x0720 | ||
| 91 | |||
| 92 | /* Structure used in the I2C_SMBUS ioctl call. */ | ||
| 93 | struct i2c_smbus_ioctl_data { | ||
| 94 | uint8_t read_write; | ||
| 95 | uint8_t command; | ||
| 96 | uint32_t size; | ||
| 97 | union i2c_smbus_data *data; | ||
| 98 | }; | ||
| 99 | |||
| 100 | /* Structure used in the I2C_RDWR ioctl call. */ | ||
| 101 | struct i2c_rdwr_ioctl_data { | ||
| 102 | struct i2c_msg *msgs; /* Pointers to i2c_msgs. */ | ||
| 103 | uint32_t nmsgs; /* Number of i2c_msgs. */ | ||
| 104 | }; | ||
| 105 | |||
| 106 | /* As specified in SMBus standard. */ | ||
| 107 | #define I2C_SMBUS_BLOCK_MAX 32 | ||
| 108 | /* Not specified but we use same structure. */ | ||
| 109 | #define I2C_SMBUS_I2C_BLOCK_MAX 32 | ||
| 110 | |||
| 111 | /* Data for SMBus Messages. */ | ||
| 112 | union i2c_smbus_data { | ||
| 113 | uint8_t byte; | ||
| 114 | uint16_t word; | ||
| 115 | /* block[0] is used for length and one more for PEC */ | ||
| 116 | uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; | ||
| 117 | }; | ||
| 118 | 68 | ||
| 119 | #define I2C_RDRW_IOCTL_MAX_MSGS 42 | 69 | #define I2CDETECT_MODE_AUTO 0 |
| 120 | #define I2C_MAX_REGS 256 | 70 | #define I2CDETECT_MODE_QUICK 1 |
| 121 | 71 | #define I2CDETECT_MODE_READ 2 | |
| 122 | /* Smbus_access read or write markers. */ | ||
| 123 | #define I2C_SMBUS_READ 1 | ||
| 124 | #define I2C_SMBUS_WRITE 0 | ||
| 125 | |||
| 126 | /* SMBus transaction types (size parameter in the below functions). */ | ||
| 127 | #define I2C_SMBUS_QUICK 0 | ||
| 128 | #define I2C_SMBUS_BYTE 1 | ||
| 129 | #define I2C_SMBUS_BYTE_DATA 2 | ||
| 130 | #define I2C_SMBUS_WORD_DATA 3 | ||
| 131 | #define I2C_SMBUS_PROC_CALL 4 | ||
| 132 | #define I2C_SMBUS_BLOCK_DATA 5 | ||
| 133 | #define I2C_SMBUS_I2C_BLOCK_BROKEN 6 | ||
| 134 | #define I2C_SMBUS_BLOCK_PROC_CALL 7 | ||
| 135 | #define I2C_SMBUS_I2C_BLOCK_DATA 8 | ||
| 136 | |||
| 137 | #define DETECT_MODE_AUTO 0 | ||
| 138 | #define DETECT_MODE_QUICK 1 | ||
| 139 | #define DETECT_MODE_READ 2 | ||
| 140 | |||
| 141 | /* Defines to determine what functionality is present. */ | ||
| 142 | #define I2C_FUNC_I2C 0x00000001 | ||
| 143 | #define I2C_FUNC_10BIT_ADDR 0x00000002 | ||
| 144 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 | ||
| 145 | #define I2C_FUNC_SMBUS_PEC 0x00000008 | ||
| 146 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 | ||
| 147 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 | ||
| 148 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 | ||
| 149 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 | ||
| 150 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 | ||
| 151 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 | ||
| 152 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 | ||
| 153 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 | ||
| 154 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 | ||
| 155 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 | ||
| 156 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 | ||
| 157 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 | ||
| 158 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 | ||
| 159 | |||
| 160 | #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ | ||
| 161 | I2C_FUNC_SMBUS_WRITE_BYTE) | ||
| 162 | #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ | ||
| 163 | I2C_FUNC_SMBUS_WRITE_BYTE_DATA) | ||
| 164 | #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ | ||
| 165 | I2C_FUNC_SMBUS_WRITE_WORD_DATA) | ||
| 166 | #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ | ||
| 167 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) | ||
| 168 | #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ | ||
| 169 | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) | ||
| 170 | 72 | ||
| 171 | /* | 73 | /* |
| 172 | * 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. |
| @@ -456,7 +358,7 @@ static void check_read_funcs(int fd, int mode, int data_addr, int pec) | |||
| 456 | break; | 358 | break; |
| 457 | #endif /* ENABLE_I2CDUMP */ | 359 | #endif /* ENABLE_I2CDUMP */ |
| 458 | default: | 360 | default: |
| 459 | bb_error_msg_and_die("Programmer goofed!"); | 361 | bb_error_msg_and_die("internal error"); |
| 460 | } | 362 | } |
| 461 | check_funcs_test_end(funcs, pec, err); | 363 | check_funcs_test_end(funcs, pec, err); |
| 462 | } | 364 | } |
| @@ -799,7 +701,7 @@ int i2cset_main(int argc, char **argv) | |||
| 799 | } | 701 | } |
| 800 | 702 | ||
| 801 | if (status < 0) { | 703 | if (status < 0) { |
| 802 | printf("Warning - readback failed\n"); | 704 | puts("Warning - readback failed"); |
| 803 | } else | 705 | } else |
| 804 | if (status != val) { | 706 | if (status != val) { |
| 805 | printf("Warning - data mismatch - wrote " | 707 | printf("Warning - data mismatch - wrote " |
| @@ -818,14 +720,14 @@ int i2cset_main(int argc, char **argv) | |||
| 818 | #if ENABLE_I2CDUMP | 720 | #if ENABLE_I2CDUMP |
| 819 | 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) |
| 820 | { | 722 | { |
| 821 | uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2C_MAX_REGS]; | 723 | uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2CDUMP_NUM_REGS]; |
| 822 | int res, blen = 0, tmp, i; | 724 | int res, blen = 0, tmp, i; |
| 823 | 725 | ||
| 824 | 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) { |
| 825 | res = i2c_smbus_read_block_data(buf_fd, 0, cblock); | 727 | res = i2c_smbus_read_block_data(buf_fd, 0, cblock); |
| 826 | blen = res; | 728 | blen = res; |
| 827 | } else { | 729 | } else { |
| 828 | for (res = 0; res < I2C_MAX_REGS; res += tmp) { | 730 | for (res = 0; res < I2CDUMP_NUM_REGS; res += tmp) { |
| 829 | tmp = i2c_smbus_read_i2c_block_data( | 731 | tmp = i2c_smbus_read_i2c_block_data( |
| 830 | buf_fd, res, I2C_SMBUS_BLOCK_MAX, | 732 | buf_fd, res, I2C_SMBUS_BLOCK_MAX, |
| 831 | cblock + res); | 733 | cblock + res); |
| @@ -834,14 +736,14 @@ static int read_block_data(int buf_fd, int mode, int *block) | |||
| 834 | } | 736 | } |
| 835 | } | 737 | } |
| 836 | 738 | ||
| 837 | if (res >= I2C_MAX_REGS) | 739 | if (res >= I2CDUMP_NUM_REGS) |
| 838 | res = I2C_MAX_REGS; | 740 | res = I2CDUMP_NUM_REGS; |
| 839 | 741 | ||
| 840 | for (i = 0; i < res; i++) | 742 | for (i = 0; i < res; i++) |
| 841 | block[i] = cblock[i]; | 743 | block[i] = cblock[i]; |
| 842 | 744 | ||
| 843 | if (mode != I2C_SMBUS_BLOCK_DATA) | 745 | if (mode != I2C_SMBUS_BLOCK_DATA) |
| 844 | for (i = res; i < I2C_MAX_REGS; i++) | 746 | for (i = res; i < I2CDUMP_NUM_REGS; i++) |
| 845 | block[i] = -1; | 747 | block[i] = -1; |
| 846 | } | 748 | } |
| 847 | 749 | ||
| @@ -854,10 +756,10 @@ static void dump_data(int bus_fd, int mode, unsigned first, | |||
| 854 | { | 756 | { |
| 855 | int i, j, res; | 757 | int i, j, res; |
| 856 | 758 | ||
| 857 | printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f" | 759 | puts(" 0 1 2 3 4 5 6 7 8 9 a b c d e f" |
| 858 | " 0123456789abcdef\n"); | 760 | " 0123456789abcdef"); |
| 859 | 761 | ||
| 860 | for (i = 0; i < I2C_MAX_REGS; i += 0x10) { | 762 | for (i = 0; i < I2CDUMP_NUM_REGS; i += 0x10) { |
| 861 | if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen) | 763 | if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen) |
| 862 | break; | 764 | break; |
| 863 | if (i/16 < first/16) | 765 | if (i/16 < first/16) |
| @@ -924,22 +826,22 @@ static void dump_data(int bus_fd, int mode, unsigned first, | |||
| 924 | break; | 826 | break; |
| 925 | /* Skip unwanted registers */ | 827 | /* Skip unwanted registers */ |
| 926 | if (i+j < first || i+j > last) { | 828 | if (i+j < first || i+j > last) { |
| 927 | printf(" "); | 829 | bb_putchar(' '); |
| 928 | continue; | 830 | continue; |
| 929 | } | 831 | } |
| 930 | 832 | ||
| 931 | res = block[i+j]; | 833 | res = block[i+j]; |
| 932 | if (res < 0) { | 834 | if (res < 0) { |
| 933 | printf("X"); | 835 | bb_putchar('X'); |
| 934 | } else if (res == 0x00 || res == 0xff) { | 836 | } else if (res == 0x00 || res == 0xff) { |
| 935 | printf("."); | 837 | bb_putchar('.'); |
| 936 | } else if (res < 32 || res >= 127) { | 838 | } else if (res < 32 || res >= 127) { |
| 937 | printf("?"); | 839 | bb_putchar('?'); |
| 938 | } else { | 840 | } else { |
| 939 | printf("%c", res); | 841 | bb_putchar(res); |
| 940 | } | 842 | } |
| 941 | } | 843 | } |
| 942 | printf("\n"); | 844 | bb_putchar('\n'); |
| 943 | } | 845 | } |
| 944 | } | 846 | } |
| 945 | 847 | ||
| @@ -948,7 +850,7 @@ static void dump_word_data(int bus_fd, unsigned first, unsigned last) | |||
| 948 | int i, j, rv; | 850 | int i, j, rv; |
| 949 | 851 | ||
| 950 | /* Word data. */ | 852 | /* Word data. */ |
| 951 | printf(" 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f\n"); | 853 | puts(" 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f"); |
| 952 | for (i = 0; i < 256; i += 8) { | 854 | for (i = 0; i < 256; i += 8) { |
| 953 | if (i/8 < first/8) | 855 | if (i/8 < first/8) |
| 954 | continue; | 856 | continue; |
| @@ -969,7 +871,7 @@ static void dump_word_data(int bus_fd, unsigned first, unsigned last) | |||
| 969 | else | 871 | else |
| 970 | printf("%04x ", rv & 0xffff); | 872 | printf("%04x ", rv & 0xffff); |
| 971 | } | 873 | } |
| 972 | printf("\n"); | 874 | bb_putchar('\n'); |
| 973 | } | 875 | } |
| 974 | } | 876 | } |
| 975 | 877 | ||
| @@ -1120,33 +1022,33 @@ static const struct i2c_func i2c_funcs_tab[] = { | |||
| 1120 | { .value = I2C_FUNC_I2C, | 1022 | { .value = I2C_FUNC_I2C, |
| 1121 | .name = "I2C" }, | 1023 | .name = "I2C" }, |
| 1122 | { .value = I2C_FUNC_SMBUS_QUICK, | 1024 | { .value = I2C_FUNC_SMBUS_QUICK, |
| 1123 | .name = "SMBus Quick Command" }, | 1025 | .name = "SMBus quick command" }, |
| 1124 | { .value = I2C_FUNC_SMBUS_WRITE_BYTE, | 1026 | { .value = I2C_FUNC_SMBUS_WRITE_BYTE, |
| 1125 | .name = "SMBus Send Byte" }, | 1027 | .name = "SMBus send byte" }, |
| 1126 | { .value = I2C_FUNC_SMBUS_READ_BYTE, | 1028 | { .value = I2C_FUNC_SMBUS_READ_BYTE, |
| 1127 | .name = "SMBus Receive Byte" }, | 1029 | .name = "SMBus receive byte" }, |
| 1128 | { .value = I2C_FUNC_SMBUS_WRITE_BYTE_DATA, | 1030 | { .value = I2C_FUNC_SMBUS_WRITE_BYTE_DATA, |
| 1129 | .name = "SMBus Write Byte" }, | 1031 | .name = "SMBus write byte" }, |
| 1130 | { .value = I2C_FUNC_SMBUS_READ_BYTE_DATA, | 1032 | { .value = I2C_FUNC_SMBUS_READ_BYTE_DATA, |
| 1131 | .name = "SMBus Read Byte" }, | 1033 | .name = "SMBus read byte" }, |
| 1132 | { .value = I2C_FUNC_SMBUS_WRITE_WORD_DATA, | 1034 | { .value = I2C_FUNC_SMBUS_WRITE_WORD_DATA, |
| 1133 | .name = "SMBus Write Word" }, | 1035 | .name = "SMBus write word" }, |
| 1134 | { .value = I2C_FUNC_SMBUS_READ_WORD_DATA, | 1036 | { .value = I2C_FUNC_SMBUS_READ_WORD_DATA, |
| 1135 | .name = "SMBus Read Word" }, | 1037 | .name = "SMBus read word" }, |
| 1136 | { .value = I2C_FUNC_SMBUS_PROC_CALL, | 1038 | { .value = I2C_FUNC_SMBUS_PROC_CALL, |
| 1137 | .name = "SMBus Process Call" }, | 1039 | .name = "SMBus process call" }, |
| 1138 | { .value = I2C_FUNC_SMBUS_WRITE_BLOCK_DATA, | 1040 | { .value = I2C_FUNC_SMBUS_WRITE_BLOCK_DATA, |
| 1139 | .name = "SMBus Block Write" }, | 1041 | .name = "SMBus block write" }, |
| 1140 | { .value = I2C_FUNC_SMBUS_READ_BLOCK_DATA, | 1042 | { .value = I2C_FUNC_SMBUS_READ_BLOCK_DATA, |
| 1141 | .name = "SMBus Block Read" }, | 1043 | .name = "SMBus block read" }, |
| 1142 | { .value = I2C_FUNC_SMBUS_BLOCK_PROC_CALL, | 1044 | { .value = I2C_FUNC_SMBUS_BLOCK_PROC_CALL, |
| 1143 | .name = "SMBus Block Process Call" }, | 1045 | .name = "SMBus block process call" }, |
| 1144 | { .value = I2C_FUNC_SMBUS_PEC, | 1046 | { .value = I2C_FUNC_SMBUS_PEC, |
| 1145 | .name = "SMBus PEC" }, | 1047 | .name = "SMBus PEC" }, |
| 1146 | { .value = I2C_FUNC_SMBUS_WRITE_I2C_BLOCK, | 1048 | { .value = I2C_FUNC_SMBUS_WRITE_I2C_BLOCK, |
| 1147 | .name = "I2C Block Write" }, | 1049 | .name = "I2C block write" }, |
| 1148 | { .value = I2C_FUNC_SMBUS_READ_I2C_BLOCK, | 1050 | { .value = I2C_FUNC_SMBUS_READ_I2C_BLOCK, |
| 1149 | .name = "I2C Block Read" }, | 1051 | .name = "I2C block read" }, |
| 1150 | { .value = 0, .name = NULL } | 1052 | { .value = 0, .name = NULL } |
| 1151 | }; | 1053 | }; |
| 1152 | 1054 | ||
| @@ -1298,7 +1200,7 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
| 1298 | opt_F = (1 << 4), opt_l = (1 << 5); | 1200 | opt_F = (1 << 4), opt_l = (1 << 5); |
| 1299 | const char *const optstr = "yaqrFl"; | 1201 | const char *const optstr = "yaqrFl"; |
| 1300 | 1202 | ||
| 1301 | int fd, bus_num, i, j, mode = DETECT_MODE_AUTO, status; | 1203 | int fd, bus_num, i, j, mode = I2CDETECT_MODE_AUTO, status; |
| 1302 | unsigned first = 0x03, last = 0x77, opts; | 1204 | unsigned first = 0x03, last = 0x77, opts; |
| 1303 | unsigned long funcs; | 1205 | unsigned long funcs; |
| 1304 | 1206 | ||
| @@ -1329,9 +1231,9 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
| 1329 | } | 1231 | } |
| 1330 | 1232 | ||
| 1331 | if (opts & opt_r) | 1233 | if (opts & opt_r) |
| 1332 | mode = DETECT_MODE_READ; | 1234 | mode = I2CDETECT_MODE_READ; |
| 1333 | else if (opts & opt_q) | 1235 | else if (opts & opt_q) |
| 1334 | mode = DETECT_MODE_QUICK; | 1236 | mode = I2CDETECT_MODE_QUICK; |
| 1335 | 1237 | ||
| 1336 | if (opts & opt_a) { | 1238 | if (opts & opt_a) { |
| 1337 | first = 0x00; | 1239 | first = 0x00; |
| @@ -1348,42 +1250,42 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
| 1348 | if (!(funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) { | 1250 | if (!(funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) { |
| 1349 | no_support("detection commands"); | 1251 | no_support("detection commands"); |
| 1350 | } else | 1252 | } else |
| 1351 | if (mode == DETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)) { | 1253 | if (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)) { |
| 1352 | no_support("SMBus Quick Write command"); | 1254 | no_support("SMBus quick write"); |
| 1353 | } else | 1255 | } else |
| 1354 | if (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { | 1256 | if (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { |
| 1355 | no_support("SMBus Receive Byte command"); | 1257 | no_support("SMBus receive byte"); |
| 1356 | } | 1258 | } |
| 1357 | 1259 | ||
| 1358 | if (mode == DETECT_MODE_AUTO) { | 1260 | if (mode == I2CDETECT_MODE_AUTO) { |
| 1359 | if (!(funcs & I2C_FUNC_SMBUS_QUICK)) | 1261 | if (!(funcs & I2C_FUNC_SMBUS_QUICK)) |
| 1360 | will_skip("SMBus Quick Write"); | 1262 | will_skip("SMBus quick write"); |
| 1361 | if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) | 1263 | if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) |
| 1362 | will_skip("SMBus Receive Byte"); | 1264 | will_skip("SMBus receive byte"); |
| 1363 | } | 1265 | } |
| 1364 | 1266 | ||
| 1365 | if (!(opts & opt_y)) | 1267 | if (!(opts & opt_y)) |
| 1366 | confirm_action(-1, -1, -1, 0); | 1268 | confirm_action(-1, -1, -1, 0); |
| 1367 | 1269 | ||
| 1368 | printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); | 1270 | puts(" 0 1 2 3 4 5 6 7 8 9 a b c d e f"); |
| 1369 | for (i = 0; i < 128; i += 16) { | 1271 | for (i = 0; i < 128; i += 16) { |
| 1370 | printf("%02x: ", i); | 1272 | printf("%02x: ", i); |
| 1371 | for(j = 0; j < 16; j++) { | 1273 | for(j = 0; j < 16; j++) { |
| 1372 | fflush_all(); | 1274 | fflush_all(); |
| 1373 | 1275 | ||
| 1374 | if (mode == DETECT_MODE_AUTO) { | 1276 | if (mode == I2CDETECT_MODE_AUTO) { |
| 1375 | if ((i+j >= 0x30 && i+j <= 0x37) || | 1277 | if ((i+j >= 0x30 && i+j <= 0x37) || |
| 1376 | (i+j >= 0x50 && i+j <= 0x5F)) | 1278 | (i+j >= 0x50 && i+j <= 0x5F)) |
| 1377 | mode = DETECT_MODE_READ; | 1279 | mode = I2CDETECT_MODE_READ; |
| 1378 | else | 1280 | else |
| 1379 | mode = DETECT_MODE_QUICK; | 1281 | mode = I2CDETECT_MODE_QUICK; |
| 1380 | } | 1282 | } |
| 1381 | 1283 | ||
| 1382 | /* Skip unwanted addresses. */ | 1284 | /* Skip unwanted addresses. */ |
| 1383 | if (i+j < first | 1285 | if (i+j < first |
| 1384 | || i+j > last | 1286 | || i+j > last |
| 1385 | || (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) | 1287 | || (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) |
| 1386 | || (mode == DETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK))) | 1288 | || (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK))) |
| 1387 | { | 1289 | { |
| 1388 | printf(" "); | 1290 | printf(" "); |
| 1389 | continue; | 1291 | continue; |
| @@ -1401,14 +1303,14 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
| 1401 | } | 1303 | } |
| 1402 | 1304 | ||
| 1403 | switch (mode) { | 1305 | switch (mode) { |
| 1404 | case DETECT_MODE_READ: | 1306 | case I2CDETECT_MODE_READ: |
| 1405 | /* | 1307 | /* |
| 1406 | * This is known to lock SMBus on various | 1308 | * This is known to lock SMBus on various |
| 1407 | * write-only chips (mainly clock chips). | 1309 | * write-only chips (mainly clock chips). |
| 1408 | */ | 1310 | */ |
| 1409 | status = i2c_smbus_read_byte(fd); | 1311 | status = i2c_smbus_read_byte(fd); |
| 1410 | break; | 1312 | break; |
| 1411 | default: /* DETECT_MODE_QUICK: */ | 1313 | default: /* I2CDETECT_MODE_QUICK: */ |
| 1412 | /* | 1314 | /* |
| 1413 | * This is known to corrupt the Atmel | 1315 | * This is known to corrupt the Atmel |
| 1414 | * AT24RF08 EEPROM. | 1316 | * AT24RF08 EEPROM. |
| @@ -1423,7 +1325,7 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
| 1423 | else | 1325 | else |
| 1424 | printf("%02x ", i+j); | 1326 | printf("%02x ", i+j); |
| 1425 | } | 1327 | } |
| 1426 | printf("\n"); | 1328 | bb_putchar('\n'); |
| 1427 | } | 1329 | } |
| 1428 | 1330 | ||
| 1429 | return 0; | 1331 | return 0; |
diff --git a/miscutils/last.c b/miscutils/last.c index 6d8b58463..f8f34371a 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
| @@ -34,7 +34,8 @@ | |||
| 34 | && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)) | 34 | && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)) |
| 35 | #error struct utmpx member char[] size(s) have changed! | 35 | #error struct utmpx member char[] size(s) have changed! |
| 36 | #elif defined __UT_LINESIZE \ | 36 | #elif defined __UT_LINESIZE \ |
| 37 | && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 64) || (__UT_HOSTSIZE != 256)) | 37 | && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 32) || (__UT_HOSTSIZE != 256)) |
| 38 | /* __UT_NAMESIZE was checked with 64 above, but glibc-2.11 definitely uses 32! */ | ||
| 38 | #error struct utmpx member char[] size(s) have changed! | 39 | #error struct utmpx member char[] size(s) have changed! |
| 39 | #endif | 40 | #endif |
| 40 | 41 | ||
