diff options
-rw-r--r-- | miscutils/hdparm.c | 293 |
1 files changed, 146 insertions, 147 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 911688f46..754f53201 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -484,14 +484,14 @@ static int bb_ioctl_alt(int fd, int cmd, unsigned char *args, int alt, const cha | |||
484 | 484 | ||
485 | static void if_printf(unsigned long i, char *fmt, ... ) | 485 | static void if_printf(unsigned long i, char *fmt, ... ) |
486 | { | 486 | { |
487 | va_list ap; | 487 | va_list ap; |
488 | va_start(ap, fmt); | 488 | va_start(ap, fmt); |
489 | if (i) | 489 | if (i) |
490 | vprintf(fmt, ap); | 490 | vprintf(fmt, ap); |
491 | va_end(ap); | 491 | va_end(ap); |
492 | } | 492 | } |
493 | 493 | ||
494 | static void on_off (unsigned int value); | 494 | static void on_off(unsigned int value); |
495 | 495 | ||
496 | static void if_printf_on_off(unsigned long get_arg,const char *fmt, unsigned long arg) | 496 | static void if_printf_on_off(unsigned long get_arg,const char *fmt, unsigned long arg) |
497 | { | 497 | { |
@@ -505,7 +505,7 @@ static void if_printf_on_off(unsigned long get_arg,const char *fmt, unsigned lon | |||
505 | static void bb_ioctl_on_off(int fd, int request, void *argp, const char *string, | 505 | static void bb_ioctl_on_off(int fd, int request, void *argp, const char *string, |
506 | const char * fmt) | 506 | const char * fmt) |
507 | { | 507 | { |
508 | if (ioctl (fd, request, &argp) != 0) | 508 | if (ioctl(fd, request, &argp) != 0) |
509 | bb_perror_msg(" %s", string); | 509 | bb_perror_msg(" %s", string); |
510 | else | 510 | else |
511 | { | 511 | { |
@@ -517,20 +517,20 @@ static void bb_ioctl_on_off(int fd, int request, void *argp, const char *string, | |||
517 | #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY | 517 | #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY |
518 | static void if_else_printf(unsigned long i, char *fmt1, char *fmt2, ... ) | 518 | static void if_else_printf(unsigned long i, char *fmt1, char *fmt2, ... ) |
519 | { | 519 | { |
520 | va_list ap; | 520 | va_list ap; |
521 | va_start(ap, fmt2); | 521 | va_start(ap, fmt2); |
522 | if (i) | 522 | if (i) |
523 | vprintf(fmt1, ap); | 523 | vprintf(fmt1, ap); |
524 | else | 524 | else |
525 | vprintf(fmt2, ap); | 525 | vprintf(fmt2, ap); |
526 | va_end(ap); | 526 | va_end(ap); |
527 | } | 527 | } |
528 | 528 | ||
529 | static void print_ascii(uint16_t *p, uint8_t length); | 529 | static void print_ascii(uint16_t *p, uint8_t length); |
530 | 530 | ||
531 | static void xprint_ascii(uint16_t *val ,int i, char * string, int n) | 531 | static void xprint_ascii(uint16_t *val ,int i, char * string, int n) |
532 | { | 532 | { |
533 | if(val[i]) | 533 | if (val[i]) |
534 | { | 534 | { |
535 | printf("\t%-20s",string); | 535 | printf("\t%-20s",string); |
536 | print_ascii(&val[i], n); | 536 | print_ascii(&val[i], n); |
@@ -552,14 +552,14 @@ static void sync_and_sleep(int i) | |||
552 | 552 | ||
553 | static uint16_t check_if_min_and_set_val(uint16_t a, uint16_t b) | 553 | static uint16_t check_if_min_and_set_val(uint16_t a, uint16_t b) |
554 | { | 554 | { |
555 | if( a < b) | 555 | if ( a < b) |
556 | a = b; | 556 | a = b; |
557 | return a; | 557 | return a; |
558 | } | 558 | } |
559 | 559 | ||
560 | static uint16_t check_if_maj_and_set_val(uint16_t a, uint16_t b) | 560 | static uint16_t check_if_maj_and_set_val(uint16_t a, uint16_t b) |
561 | { | 561 | { |
562 | if( a > b) | 562 | if ( a > b) |
563 | a = b; | 563 | a = b; |
564 | return a; | 564 | return a; |
565 | } | 565 | } |
@@ -579,16 +579,16 @@ static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t * | |||
579 | uint16_t ii; | 579 | uint16_t ii; |
580 | uint8_t err_dma = 0; | 580 | uint8_t err_dma = 0; |
581 | 581 | ||
582 | for(ii = 0; ii <= MODE_MAX; ii++) | 582 | for (ii = 0; ii <= MODE_MAX; ii++) |
583 | { | 583 | { |
584 | if(mode_sel & 0x0001) | 584 | if (mode_sel & 0x0001) |
585 | { | 585 | { |
586 | printf("*%cdma%u ",cc,ii); | 586 | printf("*%cdma%u ",cc,ii); |
587 | if(*have_mode) | 587 | if (*have_mode) |
588 | err_dma = 1; | 588 | err_dma = 1; |
589 | *have_mode = 1; | 589 | *have_mode = 1; |
590 | } | 590 | } |
591 | else if(mode_sup & 0x0001) | 591 | else if (mode_sup & 0x0001) |
592 | printf("%cdma%u ",cc,ii); | 592 | printf("%cdma%u ",cc,ii); |
593 | 593 | ||
594 | mode_sup >>=1; | 594 | mode_sup >>=1; |
@@ -602,11 +602,11 @@ static void print_ascii(uint16_t *p, uint8_t length) { | |||
602 | char cl; | 602 | char cl; |
603 | 603 | ||
604 | /* find first non-space & print it */ | 604 | /* find first non-space & print it */ |
605 | for(ii = 0; ii< length; ii++) | 605 | for (ii = 0; ii< length; ii++) |
606 | { | 606 | { |
607 | if(((char) 0x00ff&((*p)>>8)) != ' ') | 607 | if (((char) 0x00ff&((*p)>>8)) != ' ') |
608 | break; | 608 | break; |
609 | if((cl = (char) 0x00ff&(*p)) != ' ') | 609 | if ((cl = (char) 0x00ff&(*p)) != ' ') |
610 | { | 610 | { |
611 | if_printf((cl != '\0'),"%c",cl); | 611 | if_printf((cl != '\0'),"%c",cl); |
612 | p++; | 612 | p++; |
@@ -616,9 +616,9 @@ static void print_ascii(uint16_t *p, uint8_t length) { | |||
616 | p++; | 616 | p++; |
617 | } | 617 | } |
618 | /* print the rest */ | 618 | /* print the rest */ |
619 | for(; ii< length; ii++) | 619 | for (; ii< length; ii++) |
620 | { | 620 | { |
621 | if(!(*p)) | 621 | if (!(*p)) |
622 | break; /* some older devices have NULLs */ | 622 | break; /* some older devices have NULLs */ |
623 | printf("%c%c",(char)0x00ff&((*p)>>8),(char)(*p)&0x00ff); | 623 | printf("%c%c",(char)0x00ff&((*p)>>8),(char)(*p)&0x00ff); |
624 | p++; | 624 | p++; |
@@ -630,7 +630,7 @@ static void print_ascii(uint16_t *p, uint8_t length) { | |||
630 | others, though, were declared in hdparm.c with global scope; since other | 630 | others, though, were declared in hdparm.c with global scope; since other |
631 | functions in that file have static (file) scope, I assume the difference is | 631 | functions in that file have static (file) scope, I assume the difference is |
632 | intentional. */ | 632 | intentional. */ |
633 | static void identify (uint16_t *id_supplied, const char *devname) | 633 | static void identify(uint16_t *id_supplied, const char *devname) |
634 | { | 634 | { |
635 | 635 | ||
636 | char *id_file = NULL; | 636 | char *id_file = NULL; |
@@ -710,7 +710,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
710 | * specific, it should be safe to check it now, even though we don't | 710 | * specific, it should be safe to check it now, even though we don't |
711 | * know yet what standard this device is using. | 711 | * know yet what standard this device is using. |
712 | */ | 712 | */ |
713 | if((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL) || | 713 | if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL) || |
714 | (val[CONFIG]==PWRD_NID_VAL) || (val[CONFIG]==PWRD_ID_VAL) ) | 714 | (val[CONFIG]==PWRD_NID_VAL) || (val[CONFIG]==PWRD_ID_VAL) ) |
715 | { | 715 | { |
716 | like_std = 5; | 716 | like_std = 5; |
@@ -730,9 +730,9 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
730 | /* major & minor standards version number (Note: these words were not | 730 | /* major & minor standards version number (Note: these words were not |
731 | * defined until ATA-3 & the CDROM std uses different words.) */ | 731 | * defined until ATA-3 & the CDROM std uses different words.) */ |
732 | printf("Standards:"); | 732 | printf("Standards:"); |
733 | if(eqpt != CDROM) | 733 | if (eqpt != CDROM) |
734 | { | 734 | { |
735 | if(val[MINOR] && (val[MINOR] <= MINOR_MAX)) | 735 | if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) |
736 | { | 736 | { |
737 | like_std=check_if_min_and_set_val(like_std, 3); | 737 | like_std=check_if_min_and_set_val(like_std, 3); |
738 | std = actual_ver[val[MINOR]]; | 738 | std = actual_ver[val[MINOR]]; |
@@ -742,17 +742,17 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
742 | /* looks like when they up-issue the std, they obsolete one; | 742 | /* looks like when they up-issue the std, they obsolete one; |
743 | * thus, only the newest 4 issues need be supported. (That's | 743 | * thus, only the newest 4 issues need be supported. (That's |
744 | * what "kk" and "min_std" are all about.) */ | 744 | * what "kk" and "min_std" are all about.) */ |
745 | if(val[MAJOR] && (val[MAJOR] !=NOVAL_1)) | 745 | if (val[MAJOR] && (val[MAJOR] !=NOVAL_1)) |
746 | { | 746 | { |
747 | printf("\n\tSupported: "); | 747 | printf("\n\tSupported: "); |
748 | jj = val[MAJOR] << 1; | 748 | jj = val[MAJOR] << 1; |
749 | kk = like_std >4 ? like_std-4: 0; | 749 | kk = like_std >4 ? like_std-4: 0; |
750 | for(ii = 14; (ii >0)&&(ii>kk); ii--) | 750 | for (ii = 14; (ii >0)&&(ii>kk); ii--) |
751 | { | 751 | { |
752 | if(jj & 0x8000) | 752 | if (jj & 0x8000) |
753 | { | 753 | { |
754 | printf("%u ", ii); | 754 | printf("%u ", ii); |
755 | if(like_std < ii) | 755 | if (like_std < ii) |
756 | { | 756 | { |
757 | like_std = ii; | 757 | like_std = ii; |
758 | kk = like_std >4 ? like_std-4: 0; | 758 | kk = like_std >4 ? like_std-4: 0; |
@@ -769,7 +769,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
769 | */ | 769 | */ |
770 | like_std=check_if_min_and_set_val(like_std, std); | 770 | like_std=check_if_min_and_set_val(like_std, std); |
771 | 771 | ||
772 | if(((std == 5) || (!std && (like_std < 6))) && | 772 | if (((std == 5) || (!std && (like_std < 6))) && |
773 | ((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && | 773 | ((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && |
774 | (( val[CMDS_SUPP_1] & CMDS_W83) > 0x00ff)) || | 774 | (( val[CMDS_SUPP_1] & CMDS_W83) > 0x00ff)) || |
775 | ((( val[CMDS_SUPP_2] & VALID) == VALID_VAL) && | 775 | ((( val[CMDS_SUPP_2] & VALID) == VALID_VAL) && |
@@ -777,7 +777,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
777 | { | 777 | { |
778 | like_std = 6; | 778 | like_std = 6; |
779 | } | 779 | } |
780 | else if(((std == 4) || (!std && (like_std < 5))) && | 780 | else if (((std == 4) || (!std && (like_std < 5))) && |
781 | ((((val[INTEGRITY] & SIG) == SIG_VAL) && !chksum) || | 781 | ((((val[INTEGRITY] & SIG) == SIG_VAL) && !chksum) || |
782 | (( val[HWRST_RSLT] & VALID) == VALID_VAL) || | 782 | (( val[HWRST_RSLT] & VALID) == VALID_VAL) || |
783 | ((( val[CMDS_SUPP_1] & VALID) == VALID_VAL) && | 783 | ((( val[CMDS_SUPP_1] & VALID) == VALID_VAL) && |
@@ -785,7 +785,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
785 | { | 785 | { |
786 | like_std = 5; | 786 | like_std = 5; |
787 | } | 787 | } |
788 | else if(((std == 3) || (!std && (like_std < 4))) && | 788 | else if (((std == 3) || (!std && (like_std < 4))) && |
789 | ((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && | 789 | ((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && |
790 | ((( val[CMDS_SUPP_1] & CMDS_W83) > 0x0000) || | 790 | ((( val[CMDS_SUPP_1] & CMDS_W83) > 0x0000) || |
791 | (( val[CMDS_SUPP_0] & CMDS_W82) > 0x000f))) || | 791 | (( val[CMDS_SUPP_0] & CMDS_W82) > 0x000f))) || |
@@ -795,20 +795,20 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
795 | { | 795 | { |
796 | like_std = 4; | 796 | like_std = 4; |
797 | } | 797 | } |
798 | else if(((std == 2) || (!std && (like_std < 3))) && | 798 | else if (((std == 2) || (!std && (like_std < 3))) && |
799 | ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) ) | 799 | ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) ) |
800 | { | 800 | { |
801 | like_std = 3; | 801 | like_std = 3; |
802 | } | 802 | } |
803 | else if(((std == 1) || (!std && (like_std < 2))) && | 803 | else if (((std == 1) || (!std && (like_std < 2))) && |
804 | ((val[CAPAB_0] & (IORDY_SUP | IORDY_OFF)) || | 804 | ((val[CAPAB_0] & (IORDY_SUP | IORDY_OFF)) || |
805 | (val[WHATS_VALID] & OK_W64_70)) ) | 805 | (val[WHATS_VALID] & OK_W64_70)) ) |
806 | { | 806 | { |
807 | like_std = 2; | 807 | like_std = 2; |
808 | } | 808 | } |
809 | if(!std) | 809 | if (!std) |
810 | printf("\n\tLikely used: %u\n",like_std); | 810 | printf("\n\tLikely used: %u\n",like_std); |
811 | else if(like_std > std) | 811 | else if (like_std > std) |
812 | printf("& some of %u\n",like_std); | 812 | printf("& some of %u\n",like_std); |
813 | else | 813 | else |
814 | printf("\n"); | 814 | printf("\n"); |
@@ -817,17 +817,17 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
817 | { | 817 | { |
818 | /* TBD: do CDROM stuff more thoroughly. For now... */ | 818 | /* TBD: do CDROM stuff more thoroughly. For now... */ |
819 | kk = 0; | 819 | kk = 0; |
820 | if(val[CDR_MINOR] == 9) | 820 | if (val[CDR_MINOR] == 9) |
821 | { | 821 | { |
822 | kk = 1; | 822 | kk = 1; |
823 | printf("\n\tUsed: ATAPI for CD-ROMs, SFF-8020i, r2.5"); | 823 | printf("\n\tUsed: ATAPI for CD-ROMs, SFF-8020i, r2.5"); |
824 | } | 824 | } |
825 | if(val[CDR_MAJOR] && (val[CDR_MAJOR] !=NOVAL_1)) | 825 | if (val[CDR_MAJOR] && (val[CDR_MAJOR] !=NOVAL_1)) |
826 | { | 826 | { |
827 | kk = 1; | 827 | kk = 1; |
828 | printf("\n\tSupported: CD-ROM ATAPI"); | 828 | printf("\n\tSupported: CD-ROM ATAPI"); |
829 | jj = val[CDR_MAJOR] >> 1; | 829 | jj = val[CDR_MAJOR] >> 1; |
830 | for(ii = 1; ii <15; ii++) | 830 | for (ii = 1; ii <15; ii++) |
831 | { | 831 | { |
832 | if_printf((jj & 0x0001),"-%u ", ii); | 832 | if_printf((jj & 0x0001),"-%u ", ii); |
833 | jj >>= 1; | 833 | jj >>= 1; |
@@ -838,21 +838,21 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
838 | like_std = 2; | 838 | like_std = 2; |
839 | } | 839 | } |
840 | 840 | ||
841 | if(min_std == 0xffff) | 841 | if (min_std == 0xffff) |
842 | min_std = like_std > 4 ? like_std - 3 : 1; | 842 | min_std = like_std > 4 ? like_std - 3 : 1; |
843 | 843 | ||
844 | printf("Configuration:\n"); | 844 | printf("Configuration:\n"); |
845 | /* more info from the general configuration word */ | 845 | /* more info from the general configuration word */ |
846 | if((eqpt != CDROM) && (like_std == 1)) | 846 | if ((eqpt != CDROM) && (like_std == 1)) |
847 | { | 847 | { |
848 | jj = val[GEN_CONFIG] >> 1; | 848 | jj = val[GEN_CONFIG] >> 1; |
849 | for(ii = 1; ii < 15; ii++) | 849 | for (ii = 1; ii < 15; ii++) |
850 | { | 850 | { |
851 | if_printf((jj & 0x0001),"\t%s\n",ata1_cfg_str[ii]); | 851 | if_printf((jj & 0x0001),"\t%s\n",ata1_cfg_str[ii]); |
852 | jj >>=1; | 852 | jj >>=1; |
853 | } | 853 | } |
854 | } | 854 | } |
855 | if(dev == ATAPI_DEV) | 855 | if (dev == ATAPI_DEV) |
856 | { | 856 | { |
857 | printf("\tDRQ response: "); /* Data Request (DRQ) */ | 857 | printf("\tDRQ response: "); /* Data Request (DRQ) */ |
858 | switch(val[GEN_CONFIG] & DRQ_RESPONSE_TIME) | 858 | switch(val[GEN_CONFIG] & DRQ_RESPONSE_TIME) |
@@ -900,15 +900,15 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
900 | if_printf(((min_std == 1) && (val[TRACK_BYTES] || val[SECT_BYTES])), | 900 | if_printf(((min_std == 1) && (val[TRACK_BYTES] || val[SECT_BYTES])), |
901 | "\tbytes/track: %u\tbytes/sector: %u\n",val[TRACK_BYTES], val[SECT_BYTES]); | 901 | "\tbytes/track: %u\tbytes/sector: %u\n",val[TRACK_BYTES], val[SECT_BYTES]); |
902 | 902 | ||
903 | if(jj) | 903 | if (jj) |
904 | { | 904 | { |
905 | mm = (uint32_t)val[CAPACITY_MSB] << 16 | val[CAPACITY_LSB]; | 905 | mm = (uint32_t)val[CAPACITY_MSB] << 16 | val[CAPACITY_LSB]; |
906 | if(like_std < 3) | 906 | if (like_std < 3) |
907 | { | 907 | { |
908 | /* check Endian of capacity bytes */ | 908 | /* check Endian of capacity bytes */ |
909 | nn = val[LCYLS_CUR] * val[LHEADS_CUR] * val[LSECTS_CUR]; | 909 | nn = val[LCYLS_CUR] * val[LHEADS_CUR] * val[LSECTS_CUR]; |
910 | oo = (uint32_t)val[CAPACITY_LSB] << 16 | val[CAPACITY_MSB]; | 910 | oo = (uint32_t)val[CAPACITY_LSB] << 16 | val[CAPACITY_MSB]; |
911 | if(abs(mm - nn) > abs(oo - nn)) | 911 | if (abs(mm - nn) > abs(oo - nn)) |
912 | mm = oo; | 912 | mm = oo; |
913 | } | 913 | } |
914 | printf("\tCHS current addressable sectors:%11u\n",mm); | 914 | printf("\tCHS current addressable sectors:%11u\n",mm); |
@@ -916,7 +916,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
916 | } | 916 | } |
917 | /* LBA addressing */ | 917 | /* LBA addressing */ |
918 | printf("\tLBA user addressable sectors:%11u\n",ll); | 918 | printf("\tLBA user addressable sectors:%11u\n",ll); |
919 | if( ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && | 919 | if ( ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && |
920 | (val[CMDS_SUPP_1] & SUPPORT_48_BIT) ) | 920 | (val[CMDS_SUPP_1] & SUPPORT_48_BIT) ) |
921 | { | 921 | { |
922 | bbbig = (uint64_t)val[LBA_64_MSB] << 48 | | 922 | bbbig = (uint64_t)val[LBA_64_MSB] << 48 | |
@@ -939,16 +939,16 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
939 | /* hw support of commands (capabilities) */ | 939 | /* hw support of commands (capabilities) */ |
940 | printf("Capabilities:\n\t"); | 940 | printf("Capabilities:\n\t"); |
941 | 941 | ||
942 | if(dev == ATAPI_DEV) | 942 | if (dev == ATAPI_DEV) |
943 | { | 943 | { |
944 | if(eqpt != CDROM) | 944 | if (eqpt != CDROM) |
945 | if_printf((val[CAPAB_0] & CMD_Q_SUP),"Cmd queuing, "); | 945 | if_printf((val[CAPAB_0] & CMD_Q_SUP),"Cmd queuing, "); |
946 | 946 | ||
947 | if_printf((val[CAPAB_0] & OVLP_SUP),"Cmd overlap, "); | 947 | if_printf((val[CAPAB_0] & OVLP_SUP),"Cmd overlap, "); |
948 | } | 948 | } |
949 | if_printf((val[CAPAB_0] & LBA_SUP),"LBA, "); | 949 | if_printf((val[CAPAB_0] & LBA_SUP),"LBA, "); |
950 | 950 | ||
951 | if(like_std != 1) | 951 | if (like_std != 1) |
952 | { | 952 | { |
953 | printf("IORDY"); | 953 | printf("IORDY"); |
954 | if_printf((!(val[CAPAB_0] & IORDY_SUP)),"(may be)"); | 954 | if_printf((!(val[CAPAB_0] & IORDY_SUP)),"(may be)"); |
@@ -958,7 +958,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
958 | else | 958 | else |
959 | printf("no IORDY\n"); | 959 | printf("no IORDY\n"); |
960 | 960 | ||
961 | if((like_std == 1) && val[BUF_TYPE]) | 961 | if ((like_std == 1) && val[BUF_TYPE]) |
962 | { | 962 | { |
963 | kk = val[BUF_TYPE]; | 963 | kk = val[BUF_TYPE]; |
964 | printf("\tBuffer type: %04x: ",kk); | 964 | printf("\tBuffer type: %04x: ",kk); |
@@ -967,38 +967,38 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
967 | printf("\n"); | 967 | printf("\n"); |
968 | } | 968 | } |
969 | jj = 0; | 969 | jj = 0; |
970 | if((min_std == 1) && (val[BUFFER__SIZE] && (val[BUFFER__SIZE] != NOVAL_1))) | 970 | if ((min_std == 1) && (val[BUFFER__SIZE] && (val[BUFFER__SIZE] != NOVAL_1))) |
971 | { | 971 | { |
972 | printf("\tBuffer size: %.1fkB",(float)val[BUFFER__SIZE]/2); | 972 | printf("\tBuffer size: %.1fkB",(float)val[BUFFER__SIZE]/2); |
973 | jj = 1; | 973 | jj = 1; |
974 | } | 974 | } |
975 | if((min_std < 4) && (val[RW_LONG])) | 975 | if ((min_std < 4) && (val[RW_LONG])) |
976 | { | 976 | { |
977 | printf("\tbytes avail on r/w long: %u",val[RW_LONG]); | 977 | printf("\tbytes avail on r/w long: %u",val[RW_LONG]); |
978 | jj = 1; | 978 | jj = 1; |
979 | } | 979 | } |
980 | if((eqpt != CDROM) && (like_std > 3)) | 980 | if ((eqpt != CDROM) && (like_std > 3)) |
981 | { | 981 | { |
982 | printf("\tQueue depth: %u",(val[QUEUE_DEPTH] & DEPTH_BITS)+1); | 982 | printf("\tQueue depth: %u",(val[QUEUE_DEPTH] & DEPTH_BITS)+1); |
983 | jj = 1; | 983 | jj = 1; |
984 | } | 984 | } |
985 | if_printf(jj,"\n"); | 985 | if_printf(jj,"\n"); |
986 | 986 | ||
987 | if(dev == ATA_DEV) | 987 | if (dev == ATA_DEV) |
988 | { | 988 | { |
989 | if(like_std == 1) | 989 | if (like_std == 1) |
990 | printf("\tCan%s perform double-word IO\n",(!val[DWORD_IO]) ?"not":""); | 990 | printf("\tCan%s perform double-word IO\n",(!val[DWORD_IO]) ?"not":""); |
991 | else | 991 | else |
992 | { | 992 | { |
993 | printf("\tStandby timer values: spec'd by "); | 993 | printf("\tStandby timer values: spec'd by "); |
994 | if_else_printf((val[CAPAB_0] & STD_STBY),"Standard","Vendor"); | 994 | if_else_printf((val[CAPAB_0] & STD_STBY),"Standard","Vendor"); |
995 | if((like_std > 3) && ((val[CAPAB_1] & VALID) == VALID_VAL)) | 995 | if ((like_std > 3) && ((val[CAPAB_1] & VALID) == VALID_VAL)) |
996 | printf(", %s device specific minimum\n",(val[CAPAB_1] & MIN_STANDBY_TIMER)?"with":"no"); | 996 | printf(", %s device specific minimum\n",(val[CAPAB_1] & MIN_STANDBY_TIMER)?"with":"no"); |
997 | else | 997 | else |
998 | printf("\n"); | 998 | printf("\n"); |
999 | } | 999 | } |
1000 | printf("\tR/W multiple sector transfer: "); | 1000 | printf("\tR/W multiple sector transfer: "); |
1001 | if((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER)) | 1001 | if ((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER)) |
1002 | printf("not supported\n"); | 1002 | printf("not supported\n"); |
1003 | else | 1003 | else |
1004 | { | 1004 | { |
@@ -1006,7 +1006,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1006 | if_else_printf((val[SECTOR_XFER_CUR] & MULTIPLE_SETTING_VALID), | 1006 | if_else_printf((val[SECTOR_XFER_CUR] & MULTIPLE_SETTING_VALID), |
1007 | "%u\n","?\n",val[SECTOR_XFER_CUR] & SECTOR_XFER); | 1007 | "%u\n","?\n",val[SECTOR_XFER_CUR] & SECTOR_XFER); |
1008 | } | 1008 | } |
1009 | if((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) | 1009 | if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) |
1010 | { | 1010 | { |
1011 | /* We print out elsewhere whether the APM feature is enabled or | 1011 | /* We print out elsewhere whether the APM feature is enabled or |
1012 | not. If it's not enabled, let's not repeat the info; just print | 1012 | not. If it's not enabled, let's not repeat the info; just print |
@@ -1020,7 +1020,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1020 | else | 1020 | else |
1021 | printf("unknown setting (0x%04x)\n", val[ADV_PWR]); | 1021 | printf("unknown setting (0x%04x)\n", val[ADV_PWR]); |
1022 | } | 1022 | } |
1023 | if(like_std > 5) | 1023 | if (like_std > 5) |
1024 | { | 1024 | { |
1025 | if_printf(val[ACOUSTIC],"\tRecommended acoustic management value: %u, current value: %u\n", | 1025 | if_printf(val[ACOUSTIC],"\tRecommended acoustic management value: %u, current value: %u\n", |
1026 | (val[ACOUSTIC] >> 8) & 0x00ff, val[ACOUSTIC] & 0x00ff); | 1026 | (val[ACOUSTIC] >> 8) & 0x00ff, val[ACOUSTIC] & 0x00ff); |
@@ -1029,10 +1029,10 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1029 | else | 1029 | else |
1030 | { | 1030 | { |
1031 | /* ATAPI */ | 1031 | /* ATAPI */ |
1032 | if(eqpt != CDROM) | 1032 | if (eqpt != CDROM) |
1033 | if_printf((val[CAPAB_0] & SWRST_REQ),"\tATA sw reset required\n"); | 1033 | if_printf((val[CAPAB_0] & SWRST_REQ),"\tATA sw reset required\n"); |
1034 | 1034 | ||
1035 | if(val[PKT_REL] || val[SVC_NBSY]) | 1035 | if (val[PKT_REL] || val[SVC_NBSY]) |
1036 | { | 1036 | { |
1037 | printf("\tOverlap support:"); | 1037 | printf("\tOverlap support:"); |
1038 | if_printf(val[PKT_REL]," %uus to release bus.",val[PKT_REL]); | 1038 | if_printf(val[PKT_REL]," %uus to release bus.",val[PKT_REL]); |
@@ -1043,25 +1043,25 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1043 | 1043 | ||
1044 | /* DMA stuff. Check that only one DMA mode is selected. */ | 1044 | /* DMA stuff. Check that only one DMA mode is selected. */ |
1045 | printf("\tDMA: "); | 1045 | printf("\tDMA: "); |
1046 | if(!(val[CAPAB_0] & DMA_SUP)) | 1046 | if (!(val[CAPAB_0] & DMA_SUP)) |
1047 | printf("not supported\n"); | 1047 | printf("not supported\n"); |
1048 | else | 1048 | else |
1049 | { | 1049 | { |
1050 | if_printf((val[DMA_MODE] && !val[SINGLE_DMA] && !val[MULTI_DMA]), | 1050 | if_printf((val[DMA_MODE] && !val[SINGLE_DMA] && !val[MULTI_DMA]), |
1051 | " sdma%u\n",(val[DMA_MODE] & MODE) >> 8); | 1051 | " sdma%u\n",(val[DMA_MODE] & MODE) >> 8); |
1052 | if(val[SINGLE_DMA]) | 1052 | if (val[SINGLE_DMA]) |
1053 | { | 1053 | { |
1054 | jj = val[SINGLE_DMA]; | 1054 | jj = val[SINGLE_DMA]; |
1055 | kk = val[SINGLE_DMA] >> 8; | 1055 | kk = val[SINGLE_DMA] >> 8; |
1056 | err_dma += mode_loop(jj,kk,'s',&have_mode); | 1056 | err_dma += mode_loop(jj,kk,'s',&have_mode); |
1057 | } | 1057 | } |
1058 | if(val[MULTI_DMA]) | 1058 | if (val[MULTI_DMA]) |
1059 | { | 1059 | { |
1060 | jj = val[MULTI_DMA]; | 1060 | jj = val[MULTI_DMA]; |
1061 | kk = val[MULTI_DMA] >> 8; | 1061 | kk = val[MULTI_DMA] >> 8; |
1062 | err_dma += mode_loop(jj,kk,'m',&have_mode); | 1062 | err_dma += mode_loop(jj,kk,'m',&have_mode); |
1063 | } | 1063 | } |
1064 | if((val[WHATS_VALID] & OK_W88) && val[ULTRA_DMA]) | 1064 | if ((val[WHATS_VALID] & OK_W88) && val[ULTRA_DMA]) |
1065 | { | 1065 | { |
1066 | jj = val[ULTRA_DMA]; | 1066 | jj = val[ULTRA_DMA]; |
1067 | kk = val[ULTRA_DMA] >> 8; | 1067 | kk = val[ULTRA_DMA] >> 8; |
@@ -1073,7 +1073,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1073 | if_printf(((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP)), | 1073 | if_printf(((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP)), |
1074 | "\t Interleaved DMA support\n"); | 1074 | "\t Interleaved DMA support\n"); |
1075 | 1075 | ||
1076 | if((val[WHATS_VALID] & OK_W64_70) && | 1076 | if ((val[WHATS_VALID] & OK_W64_70) && |
1077 | (val[DMA_TIME_MIN] || val[DMA_TIME_NORM])) | 1077 | (val[DMA_TIME_MIN] || val[DMA_TIME_NORM])) |
1078 | { | 1078 | { |
1079 | printf("\t Cycle time:"); | 1079 | printf("\t Cycle time:"); |
@@ -1087,28 +1087,28 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1087 | printf("\tPIO: "); | 1087 | printf("\tPIO: "); |
1088 | /* If a drive supports mode n (e.g. 3), it also supports all modes less | 1088 | /* If a drive supports mode n (e.g. 3), it also supports all modes less |
1089 | * than n (e.g. 3, 2, 1 and 0). Print all the modes. */ | 1089 | * than n (e.g. 3, 2, 1 and 0). Print all the modes. */ |
1090 | if((val[WHATS_VALID] & OK_W64_70) && (val[ADV_PIO_MODES] & PIO_SUP)) | 1090 | if ((val[WHATS_VALID] & OK_W64_70) && (val[ADV_PIO_MODES] & PIO_SUP)) |
1091 | { | 1091 | { |
1092 | jj = ((val[ADV_PIO_MODES] & PIO_SUP) << 3) | 0x0007; | 1092 | jj = ((val[ADV_PIO_MODES] & PIO_SUP) << 3) | 0x0007; |
1093 | for(ii = 0; ii <= PIO_MODE_MAX ; ii++) | 1093 | for (ii = 0; ii <= PIO_MODE_MAX ; ii++) |
1094 | { | 1094 | { |
1095 | if_printf((jj & 0x0001),"pio%d ",ii); | 1095 | if_printf((jj & 0x0001),"pio%d ",ii); |
1096 | jj >>=1; | 1096 | jj >>=1; |
1097 | } | 1097 | } |
1098 | printf("\n"); | 1098 | printf("\n"); |
1099 | } | 1099 | } |
1100 | else if(((min_std < 5) || (eqpt == CDROM)) && (val[PIO_MODE] & MODE) ) | 1100 | else if (((min_std < 5) || (eqpt == CDROM)) && (val[PIO_MODE] & MODE) ) |
1101 | { | 1101 | { |
1102 | for(ii = 0; ii <= val[PIO_MODE]>>8; ii++) | 1102 | for (ii = 0; ii <= val[PIO_MODE]>>8; ii++) |
1103 | printf("pio%d ",ii); | 1103 | printf("pio%d ",ii); |
1104 | printf("\n"); | 1104 | printf("\n"); |
1105 | } | 1105 | } |
1106 | else | 1106 | else |
1107 | printf("unknown\n"); | 1107 | printf("unknown\n"); |
1108 | 1108 | ||
1109 | if(val[WHATS_VALID] & OK_W64_70) | 1109 | if (val[WHATS_VALID] & OK_W64_70) |
1110 | { | 1110 | { |
1111 | if(val[PIO_NO_FLOW] || val[PIO_FLOW]) | 1111 | if (val[PIO_NO_FLOW] || val[PIO_FLOW]) |
1112 | { | 1112 | { |
1113 | printf("\t Cycle time:"); | 1113 | printf("\t Cycle time:"); |
1114 | if_printf(val[PIO_NO_FLOW]," no flow control=%uns", val[PIO_NO_FLOW]); | 1114 | if_printf(val[PIO_NO_FLOW]," no flow control=%uns", val[PIO_NO_FLOW]); |
@@ -1117,27 +1117,27 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1117 | } | 1117 | } |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | if((val[CMDS_SUPP_1] & VALID) == VALID_VAL) | 1120 | if ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) |
1121 | { | 1121 | { |
1122 | printf("Commands/features:\n\tEnabled\tSupported:\n"); | 1122 | printf("Commands/features:\n\tEnabled\tSupported:\n"); |
1123 | jj = val[CMDS_SUPP_0]; | 1123 | jj = val[CMDS_SUPP_0]; |
1124 | kk = val[CMDS_EN_0]; | 1124 | kk = val[CMDS_EN_0]; |
1125 | for(ii = 0; ii < NUM_CMD_FEAT_STR; ii++) | 1125 | for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) |
1126 | { | 1126 | { |
1127 | if((jj & 0x8000) && (*cmd_feat_str[ii] != '\0')) | 1127 | if ((jj & 0x8000) && (*cmd_feat_str[ii] != '\0')) |
1128 | { | 1128 | { |
1129 | if_else_printf((kk & 0x8000),"\t *","\t"); | 1129 | if_else_printf((kk & 0x8000),"\t *","\t"); |
1130 | printf("\t%s\n",cmd_feat_str[ii]); | 1130 | printf("\t%s\n",cmd_feat_str[ii]); |
1131 | } | 1131 | } |
1132 | jj <<=1; kk<<=1; | 1132 | jj <<=1; kk<<=1; |
1133 | if(ii%16 == 15) | 1133 | if (ii%16 == 15) |
1134 | { | 1134 | { |
1135 | jj = val[CMDS_SUPP_0+1+(ii/16)]; | 1135 | jj = val[CMDS_SUPP_0+1+(ii/16)]; |
1136 | kk = val[CMDS_EN_0+1+(ii/16)]; | 1136 | kk = val[CMDS_EN_0+1+(ii/16)]; |
1137 | } | 1137 | } |
1138 | if(ii == 31) | 1138 | if (ii == 31) |
1139 | { | 1139 | { |
1140 | if((val[CMDS_SUPP_2] & VALID) != VALID_VAL) | 1140 | if ((val[CMDS_SUPP_2] & VALID) != VALID_VAL) |
1141 | ii +=16; | 1141 | ii +=16; |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
@@ -1147,21 +1147,21 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1147 | 1147 | ||
1148 | 1148 | ||
1149 | /* security */ | 1149 | /* security */ |
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 | printf("Security: \n"); |
1154 | if_printf((val[PSWD_CODE] && (val[PSWD_CODE] != NOVAL_1)), | 1154 | if_printf((val[PSWD_CODE] && (val[PSWD_CODE] != NOVAL_1)), |
1155 | "\tMaster password revision code = %u\n",val[PSWD_CODE]); | 1155 | "\tMaster password revision code = %u\n",val[PSWD_CODE]); |
1156 | jj = val[SECU_STATUS]; | 1156 | jj = val[SECU_STATUS]; |
1157 | if(jj) | 1157 | if (jj) |
1158 | { | 1158 | { |
1159 | for(ii = 0; ii < NUM_SECU_STR; ii++) | 1159 | for (ii = 0; ii < NUM_SECU_STR; ii++) |
1160 | { | 1160 | { |
1161 | if_else_printf((!(jj & 0x0001)),"\tnot\t%s\n", "\t\t%s\n", secu_str[ii]); | 1161 | if_else_printf((!(jj & 0x0001)),"\tnot\t%s\n", "\t\t%s\n", secu_str[ii]); |
1162 | jj >>=1; | 1162 | jj >>=1; |
1163 | } | 1163 | } |
1164 | if(val[SECU_STATUS] & SECU_ENABLED) | 1164 | if (val[SECU_STATUS] & SECU_ENABLED) |
1165 | { | 1165 | { |
1166 | printf("\tSecurity level "); | 1166 | printf("\tSecurity level "); |
1167 | if_else_printf((val[SECU_STATUS] & SECU_LEVEL),"maximum\n","high\n"); | 1167 | if_else_printf((val[SECU_STATUS] & SECU_LEVEL),"maximum\n","high\n"); |
@@ -1169,7 +1169,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1169 | } | 1169 | } |
1170 | jj = val[ERASE_TIME] & ERASE_BITS; | 1170 | jj = val[ERASE_TIME] & ERASE_BITS; |
1171 | kk = val[ENH_ERASE_TIME] & ERASE_BITS; | 1171 | kk = val[ENH_ERASE_TIME] & ERASE_BITS; |
1172 | if(jj || kk) | 1172 | if (jj || kk) |
1173 | { | 1173 | { |
1174 | printf("\t"); | 1174 | printf("\t"); |
1175 | if_printf(jj,"%umin for SECURITY ERASE UNIT. ", jj==ERASE_BITS ? 508 : jj<<1); | 1175 | if_printf(jj,"%umin for SECURITY ERASE UNIT. ", jj==ERASE_BITS ? 508 : jj<<1); |
@@ -1179,12 +1179,12 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | /* reset result */ | 1181 | /* reset result */ |
1182 | if((val[HWRST_RSLT] & VALID) == VALID_VAL) | 1182 | if ((val[HWRST_RSLT] & VALID) == VALID_VAL) |
1183 | { | 1183 | { |
1184 | printf("HW reset results:\n"); | 1184 | printf("HW reset results:\n"); |
1185 | if_else_printf((val[HWRST_RSLT] & CBLID),"\tCBLID- above Vih\n","\tCBLID- below Vih\n"); | 1185 | if_else_printf((val[HWRST_RSLT] & CBLID),"\tCBLID- above Vih\n","\tCBLID- below Vih\n"); |
1186 | 1186 | ||
1187 | if(val[HWRST_RSLT] & RST0) | 1187 | if (val[HWRST_RSLT] & RST0) |
1188 | { | 1188 | { |
1189 | printf("\tDevice num = 0"); | 1189 | printf("\tDevice num = 0"); |
1190 | jj = val[HWRST_RSLT]; | 1190 | jj = val[HWRST_RSLT]; |
@@ -1195,17 +1195,17 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1195 | jj = val[HWRST_RSLT] >> 8; | 1195 | jj = val[HWRST_RSLT] >> 8; |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | if((jj & DEV_DET) == JUMPER_VAL) | 1198 | if ((jj & DEV_DET) == JUMPER_VAL) |
1199 | printf(" determined by the jumper"); | 1199 | printf(" determined by the jumper"); |
1200 | else if((jj & DEV_DET) == CSEL_VAL) | 1200 | else if ((jj & DEV_DET) == CSEL_VAL) |
1201 | printf(" determined by CSEL"); | 1201 | printf(" determined by CSEL"); |
1202 | printf("\n"); | 1202 | printf("\n"); |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | /* more stuff from std 5 */ | 1205 | /* more stuff from std 5 */ |
1206 | if((like_std > 4) && (eqpt != CDROM)) | 1206 | if ((like_std > 4) && (eqpt != CDROM)) |
1207 | { | 1207 | { |
1208 | if(val[CFA_PWR_MODE] & VALID_W160) | 1208 | if (val[CFA_PWR_MODE] & VALID_W160) |
1209 | { | 1209 | { |
1210 | printf("CFA power mode 1:\n\t"); | 1210 | printf("CFA power mode 1:\n\t"); |
1211 | if_else_printf((val[CFA_PWR_MODE] & PWR_MODE_OFF),"disabled","enabled"); | 1211 | if_else_printf((val[CFA_PWR_MODE] & PWR_MODE_OFF),"disabled","enabled"); |
@@ -1215,7 +1215,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
1215 | 1215 | ||
1216 | if_printf((val[CFA_PWR_MODE] & MAX_AMPS),"\tMaximum current = %uma\n",val[CFA_PWR_MODE] & MAX_AMPS); | 1216 | if_printf((val[CFA_PWR_MODE] & MAX_AMPS),"\tMaximum current = %uma\n",val[CFA_PWR_MODE] & MAX_AMPS); |
1217 | } | 1217 | } |
1218 | if((val[INTEGRITY] & SIG) == SIG_VAL) | 1218 | if ((val[INTEGRITY] & SIG) == SIG_VAL) |
1219 | { | 1219 | { |
1220 | printf("Checksum: "); | 1220 | printf("Checksum: "); |
1221 | if_printf(chksum,"in"); | 1221 | if_printf(chksum,"in"); |
@@ -1304,9 +1304,9 @@ static const char * const cfg_str[] = | |||
1304 | " dStbOff", " TrkOff", " FmtGapReq", " nonMagnetic" | 1304 | " dStbOff", " TrkOff", " FmtGapReq", " nonMagnetic" |
1305 | }; | 1305 | }; |
1306 | 1306 | ||
1307 | static const char * const BuffType[] = {"unknown", "1Sect", "DualPort", "DualPortCache"}; | 1307 | static const char * const BuffType[] = {"unknown", "1Sect", "DualPort", "DualPortCache"}; |
1308 | 1308 | ||
1309 | static void dump_identity (const struct hd_driveid *id) | 1309 | static void dump_identity(const struct hd_driveid *id) |
1310 | { | 1310 | { |
1311 | int i; | 1311 | int i; |
1312 | char pmodes[64], dmodes[128], umodes[128]; | 1312 | char pmodes[64], dmodes[128], umodes[128]; |
@@ -1458,9 +1458,9 @@ static void dump_identity (const struct hd_driveid *id) | |||
1458 | } | 1458 | } |
1459 | #endif | 1459 | #endif |
1460 | 1460 | ||
1461 | static void flush_buffer_cache (int fd) | 1461 | static void flush_buffer_cache(int fd) |
1462 | { | 1462 | { |
1463 | fsync (fd); /* flush buffers */ | 1463 | fsync(fd); /* flush buffers */ |
1464 | bb_ioctl(fd, BLKFLSBUF, NULL,"BLKFLSBUF" ) ;/* do it again, big time */ | 1464 | bb_ioctl(fd, BLKFLSBUF, NULL,"BLKFLSBUF" ) ;/* do it again, big time */ |
1465 | #ifdef HDIO_DRIVE_CMD | 1465 | #ifdef HDIO_DRIVE_CMD |
1466 | sleep(1); | 1466 | sleep(1); |
@@ -1469,16 +1469,15 @@ static void flush_buffer_cache (int fd) | |||
1469 | #endif | 1469 | #endif |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | static int seek_to_zero (int fd) | 1472 | static int seek_to_zero(int fd) |
1473 | { | 1473 | { |
1474 | if (lseek(fd, (off_t) 0, SEEK_SET)) | 1474 | if (lseek(fd, (off_t) 0, SEEK_SET)) |
1475 | return 1; | 1475 | return 1; |
1476 | return 0; | 1476 | return 0; |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | static int read_big_block (int fd, char *buf) | 1479 | static int read_big_block(int fd, char *buf) |
1480 | { | 1480 | { |
1481 | |||
1482 | const char *string; | 1481 | const char *string; |
1483 | int i, rc; | 1482 | int i, rc; |
1484 | if ((rc = read(fd, buf, TIMING_BUF_BYTES)) != TIMING_BUF_BYTES) | 1483 | if ((rc = read(fd, buf, TIMING_BUF_BYTES)) != TIMING_BUF_BYTES) |
@@ -1506,7 +1505,7 @@ static int read_big_block (int fd, char *buf) | |||
1506 | 1505 | ||
1507 | static double correction; | 1506 | static double correction; |
1508 | 1507 | ||
1509 | static void do_time (int flag, int fd) | 1508 | static void do_time(int flag, int fd) |
1510 | /* | 1509 | /* |
1511 | flag = 0 time_cache | 1510 | flag = 0 time_cache |
1512 | flag = 1 time_device | 1511 | flag = 1 time_device |
@@ -1521,28 +1520,28 @@ static void do_time (int flag, int fd) | |||
1521 | 1520 | ||
1522 | if ((shmid = shmget(IPC_PRIVATE, TIMING_BUF_BYTES, 0600)) == -1) | 1521 | if ((shmid = shmget(IPC_PRIVATE, TIMING_BUF_BYTES, 0600)) == -1) |
1523 | { | 1522 | { |
1524 | bb_error_msg (bb_msg_shared_mem,"allocate"); /*"could not allocate sharedmem buf"*/ | 1523 | bb_error_msg(bb_msg_shared_mem,"allocate"); /*"could not allocate sharedmem buf"*/ |
1525 | return; | 1524 | return; |
1526 | } | 1525 | } |
1527 | if (shmctl(shmid, SHM_LOCK, NULL) == -1) | 1526 | if (shmctl(shmid, SHM_LOCK, NULL) == -1) |
1528 | { | 1527 | { |
1529 | bb_error_msg (bb_msg_shared_mem,"lock"); /*"could not lock sharedmem buf"*/ | 1528 | bb_error_msg(bb_msg_shared_mem,"lock"); /*"could not lock sharedmem buf"*/ |
1530 | (void) shmctl(shmid, IPC_RMID, NULL); | 1529 | (void) shmctl(shmid, IPC_RMID, NULL); |
1531 | return; | 1530 | return; |
1532 | } | 1531 | } |
1533 | if ((buf = shmat(shmid, (char *) 0, 0)) == (char *) -1) | 1532 | if ((buf = shmat(shmid, (char *) 0, 0)) == (char *) -1) |
1534 | { | 1533 | { |
1535 | bb_error_msg (bb_msg_shared_mem,"attach"); /*"could not attach sharedmem buf"*/ | 1534 | bb_error_msg(bb_msg_shared_mem,"attach"); /*"could not attach sharedmem buf"*/ |
1536 | (void) shmctl(shmid, IPC_RMID, NULL); | 1535 | (void) shmctl(shmid, IPC_RMID, NULL); |
1537 | return; | 1536 | return; |
1538 | } | 1537 | } |
1539 | if (shmctl(shmid, IPC_RMID, NULL) == -1) | 1538 | if (shmctl(shmid, IPC_RMID, NULL) == -1) |
1540 | bb_error_msg ("shmctl(,IPC_RMID,)"); | 1539 | bb_error_msg("shmctl(,IPC_RMID,)"); |
1541 | 1540 | ||
1542 | /* Clear out the device request queues & give them time to complete */ | 1541 | /* Clear out the device request queues & give them time to complete */ |
1543 | sync_and_sleep(3); | 1542 | sync_and_sleep(3); |
1544 | 1543 | ||
1545 | if(flag == 0) /* Time cache */ | 1544 | if (flag == 0) /* Time cache */ |
1546 | { | 1545 | { |
1547 | /* Calculate a correction factor for the basic | 1546 | /* Calculate a correction factor for the basic |
1548 | * overhead of doing a read() from the buffer cache. | 1547 | * overhead of doing a read() from the buffer cache. |
@@ -1554,9 +1553,9 @@ static void do_time (int flag, int fd) | |||
1554 | * it is much more consistent (on my machine, at least). | 1553 | * it is much more consistent (on my machine, at least). |
1555 | */ | 1554 | */ |
1556 | setitimer(ITIMER_REAL, &(struct itimerval){{1000,0},{1000,0}}, NULL); | 1555 | setitimer(ITIMER_REAL, &(struct itimerval){{1000,0},{1000,0}}, NULL); |
1557 | if (seek_to_zero (fd)) | 1556 | if (seek_to_zero(fd)) |
1558 | return; | 1557 | return; |
1559 | if (read_big_block (fd, buf)) | 1558 | if (read_big_block(fd, buf)) |
1560 | return; | 1559 | return; |
1561 | printf(" Timing buffer-cache reads: "); | 1560 | printf(" Timing buffer-cache reads: "); |
1562 | fflush(stdout); | 1561 | fflush(stdout); |
@@ -1568,9 +1567,9 @@ static void do_time (int flag, int fd) | |||
1568 | getitimer(ITIMER_REAL, &e1); | 1567 | getitimer(ITIMER_REAL, &e1); |
1569 | for (i = (BUFCACHE_FACTOR * TIMING_BUF_COUNT) ; i > 0; --i) | 1568 | for (i = (BUFCACHE_FACTOR * TIMING_BUF_COUNT) ; i > 0; --i) |
1570 | { | 1569 | { |
1571 | if (seek_to_zero (fd)) | 1570 | if (seek_to_zero(fd)) |
1572 | goto quit; | 1571 | goto quit; |
1573 | if (read_big_block (fd, buf)) | 1572 | if (read_big_block(fd, buf)) |
1574 | goto quit; | 1573 | goto quit; |
1575 | } | 1574 | } |
1576 | getitimer(ITIMER_REAL, &e2); | 1575 | getitimer(ITIMER_REAL, &e2); |
@@ -1580,7 +1579,7 @@ static void do_time (int flag, int fd) | |||
1580 | getitimer(ITIMER_REAL, &e1); | 1579 | getitimer(ITIMER_REAL, &e1); |
1581 | for (i = (BUFCACHE_FACTOR * TIMING_BUF_COUNT) ; i > 0; --i) | 1580 | for (i = (BUFCACHE_FACTOR * TIMING_BUF_COUNT) ; i > 0; --i) |
1582 | { | 1581 | { |
1583 | if (seek_to_zero (fd)) | 1582 | if (seek_to_zero(fd)) |
1584 | goto quit; | 1583 | goto quit; |
1585 | } | 1584 | } |
1586 | getitimer(ITIMER_REAL, &e2); | 1585 | getitimer(ITIMER_REAL, &e2); |
@@ -1615,7 +1614,7 @@ static void do_time (int flag, int fd) | |||
1615 | getitimer(ITIMER_REAL, &e1); | 1614 | getitimer(ITIMER_REAL, &e1); |
1616 | for (i = TIMING_BUF_COUNT; i > 0; --i) | 1615 | for (i = TIMING_BUF_COUNT; i > 0; --i) |
1617 | { | 1616 | { |
1618 | if (read_big_block (fd, buf)) | 1617 | if (read_big_block(fd, buf)) |
1619 | goto quit; | 1618 | goto quit; |
1620 | } | 1619 | } |
1621 | getitimer(ITIMER_REAL, &e2); | 1620 | getitimer(ITIMER_REAL, &e2); |
@@ -1646,24 +1645,24 @@ static void do_time (int flag, int fd) | |||
1646 | } | 1645 | } |
1647 | quit: | 1646 | quit: |
1648 | if (-1 == shmdt(buf)) | 1647 | if (-1 == shmdt(buf)) |
1649 | bb_error_msg (bb_msg_shared_mem,"detach"); /*"could not detach sharedmem buf"*/ | 1648 | bb_error_msg(bb_msg_shared_mem,"detach"); /*"could not detach sharedmem buf"*/ |
1650 | } | 1649 | } |
1651 | 1650 | ||
1652 | 1651 | ||
1653 | static void no_scsi (void) | 1652 | static void no_scsi(void) |
1654 | { | 1653 | { |
1655 | /*" operation not supported on SCSI disks"*/ | 1654 | /*" operation not supported on SCSI disks"*/ |
1656 | if (is_scsi_hd) | 1655 | if (is_scsi_hd) |
1657 | bb_error_msg_and_die(bb_msg_op_not_supp,"SCSI"); | 1656 | bb_error_msg_and_die(bb_msg_op_not_supp,"SCSI"); |
1658 | } | 1657 | } |
1659 | 1658 | ||
1660 | static void no_xt (void) | 1659 | static void no_xt(void) |
1661 | { | 1660 | { |
1662 | if (is_xt_hd) | 1661 | if (is_xt_hd) |
1663 | bb_error_msg_and_die(bb_msg_op_not_supp,"XT"); | 1662 | bb_error_msg_and_die(bb_msg_op_not_supp,"XT"); |
1664 | } | 1663 | } |
1665 | 1664 | ||
1666 | static void no_scsi_no_xt (void) | 1665 | static void no_scsi_no_xt(void) |
1667 | { | 1666 | { |
1668 | no_scsi(); | 1667 | no_scsi(); |
1669 | no_xt(); | 1668 | no_xt(); |
@@ -1675,7 +1674,7 @@ static void on_off (unsigned int value) | |||
1675 | } | 1674 | } |
1676 | 1675 | ||
1677 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF | 1676 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF |
1678 | static void bus_state_value (unsigned int value) | 1677 | static void bus_state_value(unsigned int value) |
1679 | { | 1678 | { |
1680 | const char *string; | 1679 | const char *string; |
1681 | 1680 | ||
@@ -1699,7 +1698,7 @@ static void bus_state_value (unsigned int value) | |||
1699 | #endif | 1698 | #endif |
1700 | 1699 | ||
1701 | #ifdef HDIO_DRIVE_CMD | 1700 | #ifdef HDIO_DRIVE_CMD |
1702 | static void interpret_standby (unsigned int standby) | 1701 | static void interpret_standby(unsigned int standby) |
1703 | { | 1702 | { |
1704 | printf(" ("); | 1703 | printf(" ("); |
1705 | switch(standby) | 1704 | switch(standby) |
@@ -1807,7 +1806,7 @@ static int translate_xfermode(char * name) | |||
1807 | return -1; | 1806 | return -1; |
1808 | } | 1807 | } |
1809 | 1808 | ||
1810 | static void interpret_xfermode (unsigned int xfermode) | 1809 | static void interpret_xfermode(unsigned int xfermode) |
1811 | { | 1810 | { |
1812 | printf(" ("); | 1811 | printf(" ("); |
1813 | switch(xfermode) { | 1812 | switch(xfermode) { |
@@ -1873,7 +1872,7 @@ static void interpret_xfermode (unsigned int xfermode) | |||
1873 | #define CCISS_MAJOR 104 | 1872 | #define CCISS_MAJOR 104 |
1874 | #endif | 1873 | #endif |
1875 | 1874 | ||
1876 | static void process_dev (char *devname) | 1875 | static void process_dev(char *devname) |
1877 | { | 1876 | { |
1878 | int fd; | 1877 | int fd; |
1879 | static long parm, multcount; | 1878 | static long parm, multcount; |
@@ -1945,8 +1944,8 @@ static void process_dev (char *devname) | |||
1945 | bb_error_msg_and_die("%s not supported",devname); | 1944 | bb_error_msg_and_die("%s not supported",devname); |
1946 | } | 1945 | } |
1947 | 1946 | ||
1948 | fd = bb_xopen (devname, O_RDONLY|O_NONBLOCK); | 1947 | fd = bb_xopen(devname, O_RDONLY|O_NONBLOCK); |
1949 | if_printf( (!quiet),"\n%s:\n", devname); | 1948 | if_printf(!quiet, "\n%s:\n", devname); |
1950 | 1949 | ||
1951 | if (set_readahead) | 1950 | if (set_readahead) |
1952 | { | 1951 | { |
@@ -2000,7 +1999,7 @@ static void process_dev (char *devname) | |||
2000 | { | 1999 | { |
2001 | no_scsi_no_xt(); | 2000 | no_scsi_no_xt(); |
2002 | if_printf(get_mult, " setting multcount to %ld\n", mult); | 2001 | if_printf(get_mult, " setting multcount to %ld\n", mult); |
2003 | if(ioctl(fd, HDIO_SET_MULTCOUNT, mult)) | 2002 | if (ioctl(fd, HDIO_SET_MULTCOUNT, mult)) |
2004 | bb_perror_msg("HDIO_SET_MULTCOUNT"); | 2003 | bb_perror_msg("HDIO_SET_MULTCOUNT"); |
2005 | #ifndef HDIO_DRIVE_CMD | 2004 | #ifndef HDIO_DRIVE_CMD |
2006 | else | 2005 | else |
@@ -2212,7 +2211,7 @@ static void process_dev (char *devname) | |||
2212 | if ((verbose && !is_scsi_hd && !is_xt_hd) || get_io32bit) | 2211 | if ((verbose && !is_scsi_hd && !is_xt_hd) || get_io32bit) |
2213 | { | 2212 | { |
2214 | no_scsi_no_xt(); | 2213 | no_scsi_no_xt(); |
2215 | if(!bb_ioctl(fd, HDIO_GET_32BIT, &parm, "HDIO_GET_32BIT")) | 2214 | if (!bb_ioctl(fd, HDIO_GET_32BIT, &parm, "HDIO_GET_32BIT")) |
2216 | { | 2215 | { |
2217 | printf(" IO_support =%3ld (", parm); | 2216 | printf(" IO_support =%3ld (", parm); |
2218 | switch (parm) | 2217 | switch (parm) |
@@ -2248,7 +2247,7 @@ static void process_dev (char *devname) | |||
2248 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA | 2247 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA |
2249 | if ((verbose && !is_scsi_hd) || get_dma) { | 2248 | if ((verbose && !is_scsi_hd) || get_dma) { |
2250 | no_scsi(); | 2249 | no_scsi(); |
2251 | if(!bb_ioctl(fd, HDIO_GET_DMA, &parm, "HDIO_GET_DMA")) | 2250 | if (!bb_ioctl(fd, HDIO_GET_DMA, &parm, "HDIO_GET_DMA")) |
2252 | { | 2251 | { |
2253 | printf(" using_dma = %2ld", parm); | 2252 | printf(" using_dma = %2ld", parm); |
2254 | if (parm == 8) | 2253 | if (parm == 8) |
@@ -2385,7 +2384,7 @@ static void process_dev (char *devname) | |||
2385 | if (bb_ioctl_alt(fd, HDIO_DRIVE_CMD, args1, WIN_PIDENTIFY, "HDIO_DRIVE_CMD(identify)")) | 2384 | if (bb_ioctl_alt(fd, HDIO_DRIVE_CMD, args1, WIN_PIDENTIFY, "HDIO_DRIVE_CMD(identify)")) |
2386 | goto identify_abort; | 2385 | goto identify_abort; |
2387 | 2386 | ||
2388 | for(i=0; i<(sizeof args1)/2; i+=2) | 2387 | for (i=0; i<(sizeof args1)/2; i+=2) |
2389 | __le16_to_cpus((uint16_t *)(&args1[i])); | 2388 | __le16_to_cpus((uint16_t *)(&args1[i])); |
2390 | identify((void *)&args1[4], NULL); | 2389 | identify((void *)&args1[4], NULL); |
2391 | identify_abort: | 2390 | identify_abort: |
@@ -2424,8 +2423,8 @@ identify_abort: | |||
2424 | if (do_timings) | 2423 | if (do_timings) |
2425 | do_time(1,fd); /*time device */ | 2424 | do_time(1,fd); /*time device */ |
2426 | if (do_flush) | 2425 | if (do_flush) |
2427 | flush_buffer_cache (fd); | 2426 | flush_buffer_cache(fd); |
2428 | close (fd); | 2427 | close(fd); |
2429 | } | 2428 | } |
2430 | 2429 | ||
2431 | static char * GET_NUMBER(char *p, unsigned long *flag, unsigned long *num) | 2430 | static char * GET_NUMBER(char *p, unsigned long *flag, unsigned long *num) |
@@ -2458,7 +2457,7 @@ static char * GET_STRING(char *p, unsigned long *flag, int *num) | |||
2458 | } | 2457 | } |
2459 | 2458 | ||
2460 | #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY | 2459 | #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY |
2461 | static int fromhex (unsigned char c) | 2460 | static int fromhex(unsigned char c) |
2462 | { | 2461 | { |
2463 | if (c >= 'a' && c <= 'f') | 2462 | if (c >= 'a' && c <= 'f') |
2464 | return 10 + (c - 'a'); | 2463 | return 10 + (c - 'a'); |
@@ -2467,7 +2466,7 @@ static int fromhex (unsigned char c) | |||
2467 | bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c); | 2466 | bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c); |
2468 | } | 2467 | } |
2469 | 2468 | ||
2470 | static int identify_from_stdin (void) | 2469 | static int identify_from_stdin(void) |
2471 | { | 2470 | { |
2472 | unsigned short sbuf[800]; | 2471 | unsigned short sbuf[800]; |
2473 | unsigned char buf[1600], *b = (unsigned char *)buf; | 2472 | unsigned char buf[1600], *b = (unsigned char *)buf; |
@@ -2551,7 +2550,7 @@ int hdparm_main(int argc, char **argv) | |||
2551 | noisy = 1; | 2550 | noisy = 1; |
2552 | if (!*p && argc && isdigit(**argv)) | 2551 | if (!*p && argc && isdigit(**argv)) |
2553 | p = *argv++, --argc; | 2552 | p = *argv++, --argc; |
2554 | if((set_unmask = set_flag(p,'1'))==1) | 2553 | if ((set_unmask = set_flag(p,'1'))==1) |
2555 | unmask = *p++ - '0'; | 2554 | unmask = *p++ - '0'; |
2556 | break; | 2555 | break; |
2557 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA | 2556 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA |
@@ -2560,7 +2559,7 @@ int hdparm_main(int argc, char **argv) | |||
2560 | noisy = 1; | 2559 | noisy = 1; |
2561 | if (!*p && argc && isdigit(**argv)) | 2560 | if (!*p && argc && isdigit(**argv)) |
2562 | p = *argv++, --argc; | 2561 | p = *argv++, --argc; |
2563 | if((set_dma = set_flag(p,'9'))==1) | 2562 | if ((set_dma = set_flag(p,'9'))==1) |
2564 | dma = *p++ - '0'; | 2563 | dma = *p++ - '0'; |
2565 | break; | 2564 | break; |
2566 | #endif /* CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA */ | 2565 | #endif /* CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA */ |
@@ -2569,7 +2568,7 @@ int hdparm_main(int argc, char **argv) | |||
2569 | noisy = 1; | 2568 | noisy = 1; |
2570 | if (!*p && argc && isdigit(**argv)) | 2569 | if (!*p && argc && isdigit(**argv)) |
2571 | p = *argv++, --argc; | 2570 | p = *argv++, --argc; |
2572 | if((set_nowerr = set_flag(p,'1'))==1) | 2571 | if ((set_nowerr = set_flag(p,'1'))==1) |
2573 | nowerr = *p++ - '0'; | 2572 | nowerr = *p++ - '0'; |
2574 | break; | 2573 | break; |
2575 | case 'p': | 2574 | case 'p': |
@@ -2584,7 +2583,7 @@ int hdparm_main(int argc, char **argv) | |||
2584 | noisy = 1; | 2583 | noisy = 1; |
2585 | if (!*p && argc && isdigit(**argv)) | 2584 | if (!*p && argc && isdigit(**argv)) |
2586 | p = *argv++, --argc; | 2585 | p = *argv++, --argc; |
2587 | if((set_readonly = set_flag(p,'1'))==1) | 2586 | if ((set_readonly = set_flag(p,'1'))==1) |
2588 | readonly = *p++ - '0'; | 2587 | readonly = *p++ - '0'; |
2589 | break; | 2588 | break; |
2590 | case 'm': | 2589 | case 'm': |
@@ -2642,7 +2641,7 @@ int hdparm_main(int argc, char **argv) | |||
2642 | noisy = 1; | 2641 | noisy = 1; |
2643 | if (!*p && argc && isdigit(**argv)) | 2642 | if (!*p && argc && isdigit(**argv)) |
2644 | p = *argv++, --argc; | 2643 | p = *argv++, --argc; |
2645 | if((set_dkeep = set_flag(p,'1'))==1) | 2644 | if ((set_dkeep = set_flag(p,'1'))==1) |
2646 | dkeep = *p++ - '0'; | 2645 | dkeep = *p++ - '0'; |
2647 | else | 2646 | else |
2648 | goto missing_arg_error; | 2647 | goto missing_arg_error; |
@@ -2653,7 +2652,7 @@ int hdparm_main(int argc, char **argv) | |||
2653 | noisy = 1; | 2652 | noisy = 1; |
2654 | if (!*p && argc && isdigit(**argv)) | 2653 | if (!*p && argc && isdigit(**argv)) |
2655 | p = *argv++, --argc; | 2654 | p = *argv++, --argc; |
2656 | if((set_lookahead = set_flag(p,'1'))==1) | 2655 | if ((set_lookahead = set_flag(p,'1'))==1) |
2657 | lookahead = *p++ - '0'; | 2656 | lookahead = *p++ - '0'; |
2658 | else | 2657 | else |
2659 | goto missing_arg_error; | 2658 | goto missing_arg_error; |
@@ -2664,7 +2663,7 @@ int hdparm_main(int argc, char **argv) | |||
2664 | noisy = 1; | 2663 | noisy = 1; |
2665 | if (!*p && argc && isdigit(**argv)) | 2664 | if (!*p && argc && isdigit(**argv)) |
2666 | p = *argv++, --argc; | 2665 | p = *argv++, --argc; |
2667 | if((set_doorlock = set_flag(p,'1'))==1) | 2666 | if ((set_doorlock = set_flag(p,'1'))==1) |
2668 | doorlock = *p++ - '0'; | 2667 | doorlock = *p++ - '0'; |
2669 | else | 2668 | else |
2670 | goto missing_arg_error; | 2669 | goto missing_arg_error; |
@@ -2675,7 +2674,7 @@ int hdparm_main(int argc, char **argv) | |||
2675 | noisy = 1; | 2674 | noisy = 1; |
2676 | if (!*p && argc && isdigit(**argv)) | 2675 | if (!*p && argc && isdigit(**argv)) |
2677 | p = *argv++, --argc; | 2676 | p = *argv++, --argc; |
2678 | if((set_wcache = set_flag(p,'1'))==1) | 2677 | if ((set_wcache = set_flag(p,'1'))==1) |
2679 | wcache = *p++ - '0'; | 2678 | wcache = *p++ - '0'; |
2680 | else | 2679 | else |
2681 | missing_arg_error: | 2680 | missing_arg_error: |
@@ -2714,14 +2713,14 @@ missing_arg_error: | |||
2714 | noisy = 1; | 2713 | noisy = 1; |
2715 | if (!*p && argc && isdigit(**argv)) | 2714 | if (!*p && argc && isdigit(**argv)) |
2716 | p = *argv++, --argc; | 2715 | p = *argv++, --argc; |
2717 | if((set_keep = set_flag(p,'1'))==1) | 2716 | if ((set_keep = set_flag(p,'1'))==1) |
2718 | keep = *p++ - '0'; | 2717 | keep = *p++ - '0'; |
2719 | break; | 2718 | break; |
2720 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF | 2719 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF |
2721 | case 'U': | 2720 | case 'U': |
2722 | if (!*p && argc && isdigit(**argv)) | 2721 | if (!*p && argc && isdigit(**argv)) |
2723 | p = *argv++, --argc; | 2722 | p = *argv++, --argc; |
2724 | if(! p) | 2723 | if (! p) |
2725 | goto expected_hwif_error; /* "expected hwif_nr" */ | 2724 | goto expected_hwif_error; /* "expected hwif_nr" */ |
2726 | 2725 | ||
2727 | sscanf(p++, "%i", &hwif); | 2726 | sscanf(p++, "%i", &hwif); |
@@ -2733,7 +2732,7 @@ missing_arg_error: | |||
2733 | case 'R': | 2732 | case 'R': |
2734 | if (!*p && argc && isdigit(**argv)) | 2733 | if (!*p && argc && isdigit(**argv)) |
2735 | p = *argv++, --argc; | 2734 | p = *argv++, --argc; |
2736 | if(! p) | 2735 | if (! p) |
2737 | goto expected_hwif_error; /* "expected hwif_data" */ | 2736 | goto expected_hwif_error; /* "expected hwif_data" */ |
2738 | 2737 | ||
2739 | sscanf(p++, "%i", &hwif_data); | 2738 | sscanf(p++, "%i", &hwif_data); |
@@ -2786,7 +2785,7 @@ expected_hwif_error: | |||
2786 | case 'x': | 2785 | case 'x': |
2787 | if (!*p && argc && isdigit(**argv)) | 2786 | if (!*p && argc && isdigit(**argv)) |
2788 | p = *argv++, --argc; | 2787 | p = *argv++, --argc; |
2789 | if((perform_tristate = set_flag(p,'1'))==1) | 2788 | if ((perform_tristate = set_flag(p,'1'))==1) |
2790 | tristate = *p++ - '0'; | 2789 | tristate = *p++ - '0'; |
2791 | else | 2790 | else |
2792 | missing_arg(1, c, "(0/1)"); | 2791 | missing_arg(1, c, "(0/1)"); |
@@ -2822,7 +2821,7 @@ expected_hwif_error: | |||
2822 | noisy = 1; | 2821 | noisy = 1; |
2823 | if (!*p && argc && isdigit(**argv)) | 2822 | if (!*p && argc && isdigit(**argv)) |
2824 | p = *argv++, --argc; | 2823 | p = *argv++, --argc; |
2825 | if((set_busstate = set_flag(p,'2'))==1) | 2824 | if ((set_busstate = set_flag(p,'2'))==1) |
2826 | busstate = *p++ - '0'; | 2825 | busstate = *p++ - '0'; |
2827 | break; | 2826 | break; |
2828 | #endif | 2827 | #endif |
@@ -2834,7 +2833,7 @@ expected_hwif_error: | |||
2834 | if (!argc) | 2833 | if (!argc) |
2835 | bb_show_usage(); | 2834 | bb_show_usage(); |
2836 | } else { | 2835 | } else { |
2837 | process_dev (p); | 2836 | process_dev(p); |
2838 | } | 2837 | } |
2839 | } | 2838 | } |
2840 | return 0 ; | 2839 | return 0 ; |