aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ata.h
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/linux/ata.h
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'include/linux/ata.h')
-rw-r--r--include/linux/ata.h209
1 files changed, 122 insertions, 87 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index fe6e681a9d74..32df2b6ef0e0 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -89,6 +89,8 @@ enum {
89 ATA_ID_SPG = 98, 89 ATA_ID_SPG = 98,
90 ATA_ID_LBA_CAPACITY_2 = 100, 90 ATA_ID_LBA_CAPACITY_2 = 100,
91 ATA_ID_SECTOR_SIZE = 106, 91 ATA_ID_SECTOR_SIZE = 106,
92 ATA_ID_WWN = 108,
93 ATA_ID_LOGICAL_SECTOR_SIZE = 117, /* and 118 */
92 ATA_ID_LAST_LUN = 126, 94 ATA_ID_LAST_LUN = 126,
93 ATA_ID_DLF = 128, 95 ATA_ID_DLF = 128,
94 ATA_ID_CSFO = 129, 96 ATA_ID_CSFO = 129,
@@ -102,6 +104,7 @@ enum {
102 ATA_ID_SERNO_LEN = 20, 104 ATA_ID_SERNO_LEN = 20,
103 ATA_ID_FW_REV_LEN = 8, 105 ATA_ID_FW_REV_LEN = 8,
104 ATA_ID_PROD_LEN = 40, 106 ATA_ID_PROD_LEN = 40,
107 ATA_ID_WWN_LEN = 8,
105 108
106 ATA_PCI_CTL_OFS = 2, 109 ATA_PCI_CTL_OFS = 2,
107 110
@@ -597,42 +600,42 @@ static inline bool ata_id_has_dipm(const u16 *id)
597} 600}
598 601
599 602
600static inline int ata_id_has_fua(const u16 *id) 603static inline bool ata_id_has_fua(const u16 *id)
601{ 604{
602 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000) 605 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000)
603 return 0; 606 return false;
604 return id[ATA_ID_CFSSE] & (1 << 6); 607 return id[ATA_ID_CFSSE] & (1 << 6);
605} 608}
606 609
607static inline int ata_id_has_flush(const u16 *id) 610static inline bool ata_id_has_flush(const u16 *id)
608{ 611{
609 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 612 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
610 return 0; 613 return false;
611 return id[ATA_ID_COMMAND_SET_2] & (1 << 12); 614 return id[ATA_ID_COMMAND_SET_2] & (1 << 12);
612} 615}
613 616
614static inline int ata_id_flush_enabled(const u16 *id) 617static inline bool ata_id_flush_enabled(const u16 *id)
615{ 618{
616 if (ata_id_has_flush(id) == 0) 619 if (ata_id_has_flush(id) == 0)
617 return 0; 620 return false;
618 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 621 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
619 return 0; 622 return false;
620 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12); 623 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12);
621} 624}
622 625
623static inline int ata_id_has_flush_ext(const u16 *id) 626static inline bool ata_id_has_flush_ext(const u16 *id)
624{ 627{
625 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 628 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
626 return 0; 629 return false;
627 return id[ATA_ID_COMMAND_SET_2] & (1 << 13); 630 return id[ATA_ID_COMMAND_SET_2] & (1 << 13);
628} 631}
629 632
630static inline int ata_id_flush_ext_enabled(const u16 *id) 633static inline bool ata_id_flush_ext_enabled(const u16 *id)
631{ 634{
632 if (ata_id_has_flush_ext(id) == 0) 635 if (ata_id_has_flush_ext(id) == 0)
633 return 0; 636 return false;
634 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 637 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
635 return 0; 638 return false;
636 /* 639 /*
637 * some Maxtor disks have bit 13 defined incorrectly 640 * some Maxtor disks have bit 13 defined incorrectly
638 * so check bit 10 too 641 * so check bit 10 too
@@ -640,76 +643,109 @@ static inline int ata_id_flush_ext_enabled(const u16 *id)
640 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400; 643 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400;
641} 644}
642 645
643static inline int ata_id_has_large_logical_sectors(const u16 *id) 646static inline u32 ata_id_logical_sector_size(const u16 *id)
644{ 647{
645 if ((id[ATA_ID_SECTOR_SIZE] & 0xc000) != 0x4000) 648 /* T13/1699-D Revision 6a, Sep 6, 2008. Page 128.
646 return 0; 649 * IDENTIFY DEVICE data, word 117-118.
647 return id[ATA_ID_SECTOR_SIZE] & (1 << 13); 650 * 0xd000 ignores bit 13 (logical:physical > 1)
651 */
652 if ((id[ATA_ID_SECTOR_SIZE] & 0xd000) == 0x5000)
653 return (((id[ATA_ID_LOGICAL_SECTOR_SIZE+1] << 16)
654 + id[ATA_ID_LOGICAL_SECTOR_SIZE]) * sizeof(u16)) ;
655 return ATA_SECT_SIZE;
648} 656}
649 657
650static inline u16 ata_id_logical_per_physical_sectors(const u16 *id) 658static inline u8 ata_id_log2_per_physical_sector(const u16 *id)
651{ 659{
652 return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf); 660 /* T13/1699-D Revision 6a, Sep 6, 2008. Page 128.
661 * IDENTIFY DEVICE data, word 106.
662 * 0xe000 ignores bit 12 (logical sector > 512 bytes)
663 */
664 if ((id[ATA_ID_SECTOR_SIZE] & 0xe000) == 0x6000)
665 return (id[ATA_ID_SECTOR_SIZE] & 0xf);
666 return 0;
667}
668
669/* Offset of logical sectors relative to physical sectors.
670 *
671 * If device has more than one logical sector per physical sector
672 * (aka 512 byte emulation), vendors might offset the "sector 0" address
673 * so sector 63 is "naturally aligned" - e.g. FAT partition table.
674 * This avoids Read/Mod/Write penalties when using FAT partition table
675 * and updating "well aligned" (FS perspective) physical sectors on every
676 * transaction.
677 */
678static inline u16 ata_id_logical_sector_offset(const u16 *id,
679 u8 log2_per_phys)
680{
681 u16 word_209 = id[209];
682
683 if ((log2_per_phys > 1) && (word_209 & 0xc000) == 0x4000) {
684 u16 first = word_209 & 0x3fff;
685 if (first > 0)
686 return (1 << log2_per_phys) - first;
687 }
688 return 0;
653} 689}
654 690
655static inline int ata_id_has_lba48(const u16 *id) 691static inline bool ata_id_has_lba48(const u16 *id)
656{ 692{
657 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 693 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
658 return 0; 694 return false;
659 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2)) 695 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2))
660 return 0; 696 return false;
661 return id[ATA_ID_COMMAND_SET_2] & (1 << 10); 697 return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
662} 698}
663 699
664static inline int ata_id_lba48_enabled(const u16 *id) 700static inline bool ata_id_lba48_enabled(const u16 *id)
665{ 701{
666 if (ata_id_has_lba48(id) == 0) 702 if (ata_id_has_lba48(id) == 0)
667 return 0; 703 return false;
668 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 704 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
669 return 0; 705 return false;
670 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10); 706 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10);
671} 707}
672 708
673static inline int ata_id_hpa_enabled(const u16 *id) 709static inline bool ata_id_hpa_enabled(const u16 *id)
674{ 710{
675 /* Yes children, word 83 valid bits cover word 82 data */ 711 /* Yes children, word 83 valid bits cover word 82 data */
676 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 712 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
677 return 0; 713 return false;
678 /* And 87 covers 85-87 */ 714 /* And 87 covers 85-87 */
679 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 715 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
680 return 0; 716 return false;
681 /* Check command sets enabled as well as supported */ 717 /* Check command sets enabled as well as supported */
682 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0) 718 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0)
683 return 0; 719 return false;
684 return id[ATA_ID_COMMAND_SET_1] & (1 << 10); 720 return id[ATA_ID_COMMAND_SET_1] & (1 << 10);
685} 721}
686 722
687static inline int ata_id_has_wcache(const u16 *id) 723static inline bool ata_id_has_wcache(const u16 *id)
688{ 724{
689 /* Yes children, word 83 valid bits cover word 82 data */ 725 /* Yes children, word 83 valid bits cover word 82 data */
690 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 726 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
691 return 0; 727 return false;
692 return id[ATA_ID_COMMAND_SET_1] & (1 << 5); 728 return id[ATA_ID_COMMAND_SET_1] & (1 << 5);
693} 729}
694 730
695static inline int ata_id_has_pm(const u16 *id) 731static inline bool ata_id_has_pm(const u16 *id)
696{ 732{
697 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 733 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
698 return 0; 734 return false;
699 return id[ATA_ID_COMMAND_SET_1] & (1 << 3); 735 return id[ATA_ID_COMMAND_SET_1] & (1 << 3);
700} 736}
701 737
702static inline int ata_id_rahead_enabled(const u16 *id) 738static inline bool ata_id_rahead_enabled(const u16 *id)
703{ 739{
704 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 740 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
705 return 0; 741 return false;
706 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6); 742 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6);
707} 743}
708 744
709static inline int ata_id_wcache_enabled(const u16 *id) 745static inline bool ata_id_wcache_enabled(const u16 *id)
710{ 746{
711 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 747 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
712 return 0; 748 return false;
713 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5); 749 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5);
714} 750}
715 751
@@ -739,7 +775,7 @@ static inline unsigned int ata_id_major_version(const u16 *id)
739 return mver; 775 return mver;
740} 776}
741 777
742static inline int ata_id_is_sata(const u16 *id) 778static inline bool ata_id_is_sata(const u16 *id)
743{ 779{
744 /* 780 /*
745 * See if word 93 is 0 AND drive is at least ATA-5 compatible 781 * See if word 93 is 0 AND drive is at least ATA-5 compatible
@@ -748,37 +784,40 @@ static inline int ata_id_is_sata(const u16 *id)
748 * 0x0000 and 0xffff along with the earlier ATA revisions... 784 * 0x0000 and 0xffff along with the earlier ATA revisions...
749 */ 785 */
750 if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020) 786 if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020)
751 return 1; 787 return true;
752 return 0; 788 return false;
753} 789}
754 790
755static inline int ata_id_has_tpm(const u16 *id) 791static inline bool ata_id_has_tpm(const u16 *id)
756{ 792{
757 /* The TPM bits are only valid on ATA8 */ 793 /* The TPM bits are only valid on ATA8 */
758 if (ata_id_major_version(id) < 8) 794 if (ata_id_major_version(id) < 8)
759 return 0; 795 return false;
760 if ((id[48] & 0xC000) != 0x4000) 796 if ((id[48] & 0xC000) != 0x4000)
761 return 0; 797 return false;
762 return id[48] & (1 << 0); 798 return id[48] & (1 << 0);
763} 799}
764 800
765static inline int ata_id_has_dword_io(const u16 *id) 801static inline bool ata_id_has_dword_io(const u16 *id)
766{ 802{
767 /* ATA 8 reuses this flag for "trusted" computing */ 803 /* ATA 8 reuses this flag for "trusted" computing */
768 if (ata_id_major_version(id) > 7) 804 if (ata_id_major_version(id) > 7)
769 return 0; 805 return false;
770 if (id[ATA_ID_DWORD_IO] & (1 << 0)) 806 return id[ATA_ID_DWORD_IO] & (1 << 0);
771 return 1;
772 return 0;
773} 807}
774 808
775static inline int ata_id_has_unload(const u16 *id) 809static inline bool ata_id_has_unload(const u16 *id)
776{ 810{
777 if (ata_id_major_version(id) >= 7 && 811 if (ata_id_major_version(id) >= 7 &&
778 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 && 812 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 &&
779 id[ATA_ID_CFSSE] & (1 << 13)) 813 id[ATA_ID_CFSSE] & (1 << 13))
780 return 1; 814 return true;
781 return 0; 815 return false;
816}
817
818static inline bool ata_id_has_wwn(const u16 *id)
819{
820 return (id[ATA_ID_CSF_DEFAULT] & 0xC100) == 0x4100;
782} 821}
783 822
784static inline int ata_id_form_factor(const u16 *id) 823static inline int ata_id_form_factor(const u16 *id)
@@ -809,25 +848,25 @@ static inline int ata_id_rotation_rate(const u16 *id)
809 return val; 848 return val;
810} 849}
811 850
812static inline int ata_id_has_trim(const u16 *id) 851static inline bool ata_id_has_trim(const u16 *id)
813{ 852{
814 if (ata_id_major_version(id) >= 7 && 853 if (ata_id_major_version(id) >= 7 &&
815 (id[ATA_ID_DATA_SET_MGMT] & 1)) 854 (id[ATA_ID_DATA_SET_MGMT] & 1))
816 return 1; 855 return true;
817 return 0; 856 return false;
818} 857}
819 858
820static inline int ata_id_has_zero_after_trim(const u16 *id) 859static inline bool ata_id_has_zero_after_trim(const u16 *id)
821{ 860{
822 /* DSM supported, deterministic read, and read zero after trim set */ 861 /* DSM supported, deterministic read, and read zero after trim set */
823 if (ata_id_has_trim(id) && 862 if (ata_id_has_trim(id) &&
824 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020) 863 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020)
825 return 1; 864 return true;
826 865
827 return 0; 866 return false;
828} 867}
829 868
830static inline int ata_id_current_chs_valid(const u16 *id) 869static inline bool ata_id_current_chs_valid(const u16 *id)
831{ 870{
832 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 871 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
833 has not been issued to the device then the values of 872 has not been issued to the device then the values of
@@ -839,11 +878,11 @@ static inline int ata_id_current_chs_valid(const u16 *id)
839 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */ 878 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */
840} 879}
841 880
842static inline int ata_id_is_cfa(const u16 *id) 881static inline bool ata_id_is_cfa(const u16 *id)
843{ 882{
844 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */ 883 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */
845 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */ 884 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */
846 return 1; 885 return true;
847 /* 886 /*
848 * CF specs don't require specific value in the word 0 anymore and yet 887 * CF specs don't require specific value in the word 0 anymore and yet
849 * they forbid to report the ATA version in the word 80 and require the 888 * they forbid to report the ATA version in the word 80 and require the
@@ -852,44 +891,40 @@ static inline int ata_id_is_cfa(const u16 *id)
852 * and while those that don't indicate CFA feature support need some 891 * and while those that don't indicate CFA feature support need some
853 * sort of quirk list, it seems impractical for the ones that do... 892 * sort of quirk list, it seems impractical for the ones that do...
854 */ 893 */
855 if ((id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004) 894 return (id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004;
856 return 1;
857 return 0;
858} 895}
859 896
860static inline int ata_id_is_ssd(const u16 *id) 897static inline bool ata_id_is_ssd(const u16 *id)
861{ 898{
862 return id[ATA_ID_ROT_SPEED] == 0x01; 899 return id[ATA_ID_ROT_SPEED] == 0x01;
863} 900}
864 901
865static inline int ata_id_pio_need_iordy(const u16 *id, const u8 pio) 902static inline bool ata_id_pio_need_iordy(const u16 *id, const u8 pio)
866{ 903{
867 /* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */ 904 /* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */
868 if (pio > 4 && ata_id_is_cfa(id)) 905 if (pio > 4 && ata_id_is_cfa(id))
869 return 0; 906 return false;
870 /* For PIO3 and higher it is mandatory. */ 907 /* For PIO3 and higher it is mandatory. */
871 if (pio > 2) 908 if (pio > 2)
872 return 1; 909 return true;
873 /* Turn it on when possible. */ 910 /* Turn it on when possible. */
874 if (ata_id_has_iordy(id)) 911 return ata_id_has_iordy(id);
875 return 1;
876 return 0;
877} 912}
878 913
879static inline int ata_drive_40wire(const u16 *dev_id) 914static inline bool ata_drive_40wire(const u16 *dev_id)
880{ 915{
881 if (ata_id_is_sata(dev_id)) 916 if (ata_id_is_sata(dev_id))
882 return 0; /* SATA */ 917 return false; /* SATA */
883 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000) 918 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000)
884 return 0; /* 80 wire */ 919 return false; /* 80 wire */
885 return 1; 920 return true;
886} 921}
887 922
888static inline int ata_drive_40wire_relaxed(const u16 *dev_id) 923static inline bool ata_drive_40wire_relaxed(const u16 *dev_id)
889{ 924{
890 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000) 925 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000)
891 return 0; /* 80 wire */ 926 return false; /* 80 wire */
892 return 1; 927 return true;
893} 928}
894 929
895static inline int atapi_cdb_len(const u16 *dev_id) 930static inline int atapi_cdb_len(const u16 *dev_id)
@@ -902,12 +937,12 @@ static inline int atapi_cdb_len(const u16 *dev_id)
902 } 937 }
903} 938}
904 939
905static inline int atapi_command_packet_set(const u16 *dev_id) 940static inline bool atapi_command_packet_set(const u16 *dev_id)
906{ 941{
907 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f; 942 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f;
908} 943}
909 944
910static inline int atapi_id_dmadir(const u16 *dev_id) 945static inline bool atapi_id_dmadir(const u16 *dev_id)
911{ 946{
912 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); 947 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000);
913} 948}
@@ -920,13 +955,13 @@ static inline int atapi_id_dmadir(const u16 *dev_id)
920 * 955 *
921 * It is called only once for each device. 956 * It is called only once for each device.
922 */ 957 */
923static inline int ata_id_is_lba_capacity_ok(u16 *id) 958static inline bool ata_id_is_lba_capacity_ok(u16 *id)
924{ 959{
925 unsigned long lba_sects, chs_sects, head, tail; 960 unsigned long lba_sects, chs_sects, head, tail;
926 961
927 /* No non-LBA info .. so valid! */ 962 /* No non-LBA info .. so valid! */
928 if (id[ATA_ID_CYLS] == 0) 963 if (id[ATA_ID_CYLS] == 0)
929 return 1; 964 return true;
930 965
931 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); 966 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
932 967
@@ -941,13 +976,13 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
941 id[ATA_ID_SECTORS] == 63 && 976 id[ATA_ID_SECTORS] == 63 &&
942 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && 977 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) &&
943 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) 978 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS]))
944 return 1; 979 return true;
945 980
946 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; 981 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS];
947 982
948 /* perform a rough sanity check on lba_sects: within 10% is OK */ 983 /* perform a rough sanity check on lba_sects: within 10% is OK */
949 if (lba_sects - chs_sects < chs_sects/10) 984 if (lba_sects - chs_sects < chs_sects/10)
950 return 1; 985 return true;
951 986
952 /* some drives have the word order reversed */ 987 /* some drives have the word order reversed */
953 head = (lba_sects >> 16) & 0xffff; 988 head = (lba_sects >> 16) & 0xffff;
@@ -956,10 +991,10 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
956 991
957 if (lba_sects - chs_sects < chs_sects/10) { 992 if (lba_sects - chs_sects < chs_sects/10) {
958 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); 993 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects);
959 return 1; /* LBA capacity is (now) good */ 994 return true; /* LBA capacity is (now) good */
960 } 995 }
961 996
962 return 0; /* LBA capacity value may be bad */ 997 return false; /* LBA capacity value may be bad */
963} 998}
964 999
965static inline void ata_id_to_hd_driveid(u16 *id) 1000static inline void ata_id_to_hd_driveid(u16 *id)
@@ -1017,19 +1052,19 @@ static inline int is_multi_taskfile(struct ata_taskfile *tf)
1017 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT); 1052 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
1018} 1053}
1019 1054
1020static inline int ata_ok(u8 status) 1055static inline bool ata_ok(u8 status)
1021{ 1056{
1022 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) 1057 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
1023 == ATA_DRDY); 1058 == ATA_DRDY);
1024} 1059}
1025 1060
1026static inline int lba_28_ok(u64 block, u32 n_block) 1061static inline bool lba_28_ok(u64 block, u32 n_block)
1027{ 1062{
1028 /* check the ending block number: must be LESS THAN 0x0fffffff */ 1063 /* check the ending block number: must be LESS THAN 0x0fffffff */
1029 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256); 1064 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256);
1030} 1065}
1031 1066
1032static inline int lba_48_ok(u64 block, u32 n_block) 1067static inline bool lba_48_ok(u64 block, u32 n_block)
1033{ 1068{
1034 /* check the ending block number */ 1069 /* check the ending block number */
1035 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); 1070 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);