diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 2dac8493f..89c7ece77 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -459,9 +459,12 @@ static int bb_ioctl_alt(int fd, int cmd, unsigned char *args, int alt, const cha return bb_ioctl(fd, cmd, args, string); } -static void on_off(unsigned int value); +static void on_off(int value) +{ + printf(value ? " (on)\n" : " (off)\n"); +} -static void print_flag_on_off(unsigned long get_arg, const char *s, unsigned long arg) +static void print_flag_on_off(int get_arg, const char *s, unsigned long arg) { if (get_arg) { printf(" setting %s to %ld", s, arg); @@ -476,7 +479,7 @@ static void bb_ioctl_on_off(int fd, int request, void *argp, const char *string, bb_perror_msg(" %s", string); else { printf(" %s\t= %2ld", str, (unsigned long) argp); - on_off((unsigned long) argp); + on_off(((unsigned long) argp) != 0); } } @@ -701,7 +704,7 @@ static void identify(uint16_t *id_supplied) jj >>= 1; } } - printf("%s\n", (!kk) ? "\n\tLikely used CD-ROM ATAPI-1" : "" ); + printf("%s\n", kk ? "" : "\n\tLikely used CD-ROM ATAPI-1"); /* the cdrom stuff is more like ATA-2 than anything else, so: */ like_std = 2; } @@ -714,7 +717,8 @@ static void identify(uint16_t *id_supplied) if ((eqpt != CDROM) && (like_std == 1)) { jj = val[GEN_CONFIG] >> 1; for (ii = 1; ii < 15; ii++) { - if (jj & 0x0001) printf("\t%s\n", ata1_cfg_str[ii]); + if (jj & 0x0001) + printf("\t%s\n", ata1_cfg_str[ii]); jj >>=1; } } @@ -740,7 +744,7 @@ static void identify(uint16_t *id_supplied) /* addressing...CHS? See section 6.2 of ATA specs 4 or 5 */ ll = (uint32_t)val[LBA_SECTS_MSB] << 16 | val[LBA_SECTS_LSB]; mm = 0; bbbig = 0; - if ( (ll > 0x00FBFC10) && (!val[LCYLS])) + if ((ll > 0x00FBFC10) && (!val[LCYLS])) printf("\tCHS addressing not supported\n"); else { jj = val[WHATS_VALID] & OK_W54_58; @@ -767,9 +771,9 @@ static void identify(uint16_t *id_supplied) if (((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && (val[CMDS_SUPP_1] & SUPPORT_48_BIT) ) { - bbbig = (uint64_t)val[LBA_64_MSB] << 48 | - (uint64_t)val[LBA_48_MSB] << 32 | - (uint64_t)val[LBA_MID] << 16 | + bbbig = (uint64_t)val[LBA_64_MSB] << 48 | + (uint64_t)val[LBA_48_MSB] << 32 | + (uint64_t)val[LBA_MID] << 16 | val[LBA_LSB] ; printf("\tLBA48 user addressable sectors:%11"PRIu64"\n", bbbig); } @@ -1016,62 +1020,71 @@ static void identify(uint16_t *id_supplied) } #endif -static int get_identity, get_geom; -static int do_flush; -static int do_ctimings, do_timings; -static unsigned long set_readahead, get_readahead, Xreadahead; -static unsigned long set_readonly, get_readonly, readonly; -static unsigned long set_unmask, get_unmask, unmask; -static unsigned long set_mult, get_mult, mult; -#if ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA -static unsigned long set_dma, get_dma, dma; -#endif -static unsigned long set_dma_q, get_dma_q, dma_q; -static unsigned long set_nowerr, get_nowerr, nowerr; -static unsigned long set_keep, get_keep, keep; -static unsigned long set_io32bit, get_io32bit, io32bit; -static unsigned long set_piomode, noisy_piomode; +static smallint get_identity, get_geom; +static smallint do_flush; +static smallint do_ctimings, do_timings; +static smallint reread_partn; + +static smallint set_piomode, noisy_piomode; +static smallint set_readahead, get_readahead; +static smallint set_readonly, get_readonly; +static smallint set_unmask, get_unmask; +static smallint set_mult, get_mult; +static smallint set_dma_q, get_dma_q; +static smallint set_nowerr, get_nowerr; +static smallint set_keep, get_keep; +static smallint set_io32bit, get_io32bit; static int piomode; +static unsigned long Xreadahead; +static unsigned long readonly; +static unsigned long unmask; +static unsigned long mult; +static unsigned long dma_q; +static unsigned long nowerr; +static unsigned long keep; +static unsigned long io32bit; +#if ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA +static unsigned long dma; +static smallint set_dma, get_dma; +#endif #ifdef HDIO_DRIVE_CMD -static unsigned long set_dkeep, get_dkeep, dkeep; -static unsigned long set_standby, get_standby, standby_requested; -static unsigned long set_xfermode, get_xfermode; +static smallint set_xfermode, get_xfermode; +static smallint set_dkeep, get_dkeep; +static smallint set_standby, get_standby; +static smallint set_lookahead, get_lookahead; +static smallint set_prefetch, get_prefetch; +static smallint set_defects, get_defects; +static smallint set_wcache, get_wcache; +static smallint set_doorlock, get_doorlock; +static smallint set_seagate, get_seagate; +static smallint set_standbynow, get_standbynow; +static smallint set_sleepnow, get_sleepnow; +static smallint get_powermode; +static smallint set_apmmode, get_apmmode; static int xfermode_requested; -static unsigned long set_lookahead, get_lookahead, lookahead; -static unsigned long set_prefetch, get_prefetch, prefetch; -static unsigned long set_defects, get_defects, defects; -static unsigned long set_wcache, get_wcache, wcache; -static unsigned long set_doorlock, get_doorlock, doorlock; -static unsigned long set_seagate, get_seagate; -static unsigned long set_standbynow, get_standbynow; -static unsigned long set_sleepnow, get_sleepnow; -static unsigned long get_powermode; -static unsigned long set_apmmode, get_apmmode, apmmode; -#endif -#if ENABLE_FEATURE_HDPARM_GET_IDENTITY -static int get_IDentity; -#endif -#if ENABLE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF -static unsigned long unregister_hwif; -static unsigned long hwif; +static unsigned long dkeep; +static unsigned long standby_requested; +static unsigned long lookahead; +static unsigned long prefetch; +static unsigned long defects; +static unsigned long wcache; +static unsigned long doorlock; +static unsigned long apmmode; #endif +USE_FEATURE_HDPARM_GET_IDENTITY( static smallint get_IDentity;) +USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( static smallint set_busstate, get_busstate;) +USE_FEATURE_HDPARM_HDIO_DRIVE_RESET( static smallint perform_reset;) +USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( static smallint perform_tristate;) +USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(static smallint unregister_hwif;) +USE_FEATURE_HDPARM_HDIO_SCAN_HWIF( static smallint scan_hwif;) +USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( static unsigned long busstate;) +USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( static unsigned long tristate;) +USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(static unsigned long hwif;) #if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF -static unsigned long scan_hwif; static unsigned long hwif_data; static unsigned long hwif_ctrl; static unsigned long hwif_irq; #endif -#if ENABLE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF -static unsigned long set_busstate, get_busstate, busstate; -#endif -static int reread_partn; - -#if ENABLE_FEATURE_HDPARM_HDIO_DRIVE_RESET -static int perform_reset; -#endif /* FEATURE_HDPARM_HDIO_DRIVE_RESET */ -#if ENABLE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF -static unsigned long perform_tristate, tristate; -#endif /* FEATURE_HDPARM_HDIO_TRISTATE_HWIF */ // Historically, if there was no HDIO_OBSOLETE_IDENTITY, then // then the HDIO_GET_IDENTITY only returned 142 bytes. @@ -1101,11 +1114,11 @@ static void dump_identity(const struct hd_driveid *id) printf("\n Model=%.40s, FwRev=%.8s, SerialNo=%.20s\n Config={", id->model, id->fw_rev, id->serial_no); - for (i=0; i<=15; i++) { + for (i = 0; i <= 15; i++) { if (id->config & (1<cyls, id->heads, id->sectors, id->track_bytes, id->sector_bytes, id->ecc_bytes, @@ -1128,8 +1141,8 @@ static void dump_identity(const struct hd_driveid *id) printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s", id->cur_cyls, id->cur_heads, id->cur_sectors, (BB_BIG_ENDIAN) ? - (long unsigned int)(id->cur_capacity0 << 16) | id->cur_capacity1 : - (long unsigned int)(id->cur_capacity1 << 16) | id->cur_capacity0, + (unsigned long)(id->cur_capacity0 << 16) | id->cur_capacity1 : + (unsigned long)(id->cur_capacity1 << 16) | id->cur_capacity0, ((id->capability&2) == 0) ? "no" : "yes"); if (id->capability & 2) @@ -1218,7 +1231,7 @@ static void dump_identity(const struct hd_driveid *id) printf("\n Drive conforms to: %s: ", (id->minor_rev_num <= 31) ? minor_str[id->minor_rev_num] : "Unknown"); if (id->major_rev_num != 0x0000 && /* NOVAL_0 */ id->major_rev_num != 0xFFFF) { /* NOVAL_1 */ - for (i=0; i <= 15; i++) { + for (i = 0; i <= 15; i++) { if (id->major_rev_num & (1<