aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2011-03-14 03:54:20 -0400
committerJeff Garzik <jgarzik@pobox.com>2011-03-15 02:42:32 -0400
commit4dce8ba94c751dd25f1d9b2d35c04312b046e5d6 (patch)
tree58f79870815f08108ce0199a938bffba81a6234b /include
parent578ca87c9d18d344b449a8eefee40c10e4fc319f (diff)
libata: Use 'bool' return value for ata_id_XXX
Most ata_id_XXX inlines are simple tests, so we should set the return value to 'bool' here. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ata.h156
1 files changed, 75 insertions, 81 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 198e1ea2b2eb..32df2b6ef0e0 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -600,42 +600,42 @@ static inline bool ata_id_has_dipm(const u16 *id)
600} 600}
601 601
602 602
603static inline int ata_id_has_fua(const u16 *id) 603static inline bool ata_id_has_fua(const u16 *id)
604{ 604{
605 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000) 605 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000)
606 return 0; 606 return false;
607 return id[ATA_ID_CFSSE] & (1 << 6); 607 return id[ATA_ID_CFSSE] & (1 << 6);
608} 608}
609 609
610static inline int ata_id_has_flush(const u16 *id) 610static inline bool ata_id_has_flush(const u16 *id)
611{ 611{
612 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 612 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
613 return 0; 613 return false;
614 return id[ATA_ID_COMMAND_SET_2] & (1 << 12); 614 return id[ATA_ID_COMMAND_SET_2] & (1 << 12);
615} 615}
616 616
617static inline int ata_id_flush_enabled(const u16 *id) 617static inline bool ata_id_flush_enabled(const u16 *id)
618{ 618{
619 if (ata_id_has_flush(id) == 0) 619 if (ata_id_has_flush(id) == 0)
620 return 0; 620 return false;
621 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 621 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
622 return 0; 622 return false;
623 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12); 623 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12);
624} 624}
625 625
626static inline int ata_id_has_flush_ext(const u16 *id) 626static inline bool ata_id_has_flush_ext(const u16 *id)
627{ 627{
628 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 628 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
629 return 0; 629 return false;
630 return id[ATA_ID_COMMAND_SET_2] & (1 << 13); 630 return id[ATA_ID_COMMAND_SET_2] & (1 << 13);
631} 631}
632 632
633static inline int ata_id_flush_ext_enabled(const u16 *id) 633static inline bool ata_id_flush_ext_enabled(const u16 *id)
634{ 634{
635 if (ata_id_has_flush_ext(id) == 0) 635 if (ata_id_has_flush_ext(id) == 0)
636 return 0; 636 return false;
637 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 637 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
638 return 0; 638 return false;
639 /* 639 /*
640 * some Maxtor disks have bit 13 defined incorrectly 640 * some Maxtor disks have bit 13 defined incorrectly
641 * so check bit 10 too 641 * so check bit 10 too
@@ -688,64 +688,64 @@ static inline u16 ata_id_logical_sector_offset(const u16 *id,
688 return 0; 688 return 0;
689} 689}
690 690
691static inline int ata_id_has_lba48(const u16 *id) 691static inline bool ata_id_has_lba48(const u16 *id)
692{ 692{
693 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 693 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
694 return 0; 694 return false;
695 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2)) 695 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2))
696 return 0; 696 return false;
697 return id[ATA_ID_COMMAND_SET_2] & (1 << 10); 697 return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
698} 698}
699 699
700static inline int ata_id_lba48_enabled(const u16 *id) 700static inline bool ata_id_lba48_enabled(const u16 *id)
701{ 701{
702 if (ata_id_has_lba48(id) == 0) 702 if (ata_id_has_lba48(id) == 0)
703 return 0; 703 return false;
704 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 704 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
705 return 0; 705 return false;
706 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10); 706 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10);
707} 707}
708 708
709static inline int ata_id_hpa_enabled(const u16 *id) 709static inline bool ata_id_hpa_enabled(const u16 *id)
710{ 710{
711 /* Yes children, word 83 valid bits cover word 82 data */ 711 /* Yes children, word 83 valid bits cover word 82 data */
712 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 712 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
713 return 0; 713 return false;
714 /* And 87 covers 85-87 */ 714 /* And 87 covers 85-87 */
715 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 715 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
716 return 0; 716 return false;
717 /* Check command sets enabled as well as supported */ 717 /* Check command sets enabled as well as supported */
718 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0) 718 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0)
719 return 0; 719 return false;
720 return id[ATA_ID_COMMAND_SET_1] & (1 << 10); 720 return id[ATA_ID_COMMAND_SET_1] & (1 << 10);
721} 721}
722 722
723static inline int ata_id_has_wcache(const u16 *id) 723static inline bool ata_id_has_wcache(const u16 *id)
724{ 724{
725 /* Yes children, word 83 valid bits cover word 82 data */ 725 /* Yes children, word 83 valid bits cover word 82 data */
726 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 726 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
727 return 0; 727 return false;
728 return id[ATA_ID_COMMAND_SET_1] & (1 << 5); 728 return id[ATA_ID_COMMAND_SET_1] & (1 << 5);
729} 729}
730 730
731static inline int ata_id_has_pm(const u16 *id) 731static inline bool ata_id_has_pm(const u16 *id)
732{ 732{
733 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 733 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
734 return 0; 734 return false;
735 return id[ATA_ID_COMMAND_SET_1] & (1 << 3); 735 return id[ATA_ID_COMMAND_SET_1] & (1 << 3);
736} 736}
737 737
738static inline int ata_id_rahead_enabled(const u16 *id) 738static inline bool ata_id_rahead_enabled(const u16 *id)
739{ 739{
740 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 740 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
741 return 0; 741 return false;
742 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6); 742 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6);
743} 743}
744 744
745static inline int ata_id_wcache_enabled(const u16 *id) 745static inline bool ata_id_wcache_enabled(const u16 *id)
746{ 746{
747 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 747 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
748 return 0; 748 return false;
749 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5); 749 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5);
750} 750}
751 751
@@ -775,7 +775,7 @@ static inline unsigned int ata_id_major_version(const u16 *id)
775 return mver; 775 return mver;
776} 776}
777 777
778static inline int ata_id_is_sata(const u16 *id) 778static inline bool ata_id_is_sata(const u16 *id)
779{ 779{
780 /* 780 /*
781 * 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
@@ -784,37 +784,35 @@ static inline int ata_id_is_sata(const u16 *id)
784 * 0x0000 and 0xffff along with the earlier ATA revisions... 784 * 0x0000 and 0xffff along with the earlier ATA revisions...
785 */ 785 */
786 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)
787 return 1; 787 return true;
788 return 0; 788 return false;
789} 789}
790 790
791static inline int ata_id_has_tpm(const u16 *id) 791static inline bool ata_id_has_tpm(const u16 *id)
792{ 792{
793 /* The TPM bits are only valid on ATA8 */ 793 /* The TPM bits are only valid on ATA8 */
794 if (ata_id_major_version(id) < 8) 794 if (ata_id_major_version(id) < 8)
795 return 0; 795 return false;
796 if ((id[48] & 0xC000) != 0x4000) 796 if ((id[48] & 0xC000) != 0x4000)
797 return 0; 797 return false;
798 return id[48] & (1 << 0); 798 return id[48] & (1 << 0);
799} 799}
800 800
801static inline int ata_id_has_dword_io(const u16 *id) 801static inline bool ata_id_has_dword_io(const u16 *id)
802{ 802{
803 /* ATA 8 reuses this flag for "trusted" computing */ 803 /* ATA 8 reuses this flag for "trusted" computing */
804 if (ata_id_major_version(id) > 7) 804 if (ata_id_major_version(id) > 7)
805 return 0; 805 return false;
806 if (id[ATA_ID_DWORD_IO] & (1 << 0)) 806 return id[ATA_ID_DWORD_IO] & (1 << 0);
807 return 1;
808 return 0;
809} 807}
810 808
811static inline int ata_id_has_unload(const u16 *id) 809static inline bool ata_id_has_unload(const u16 *id)
812{ 810{
813 if (ata_id_major_version(id) >= 7 && 811 if (ata_id_major_version(id) >= 7 &&
814 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 && 812 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 &&
815 id[ATA_ID_CFSSE] & (1 << 13)) 813 id[ATA_ID_CFSSE] & (1 << 13))
816 return 1; 814 return true;
817 return 0; 815 return false;
818} 816}
819 817
820static inline bool ata_id_has_wwn(const u16 *id) 818static inline bool ata_id_has_wwn(const u16 *id)
@@ -850,25 +848,25 @@ static inline int ata_id_rotation_rate(const u16 *id)
850 return val; 848 return val;
851} 849}
852 850
853static inline int ata_id_has_trim(const u16 *id) 851static inline bool ata_id_has_trim(const u16 *id)
854{ 852{
855 if (ata_id_major_version(id) >= 7 && 853 if (ata_id_major_version(id) >= 7 &&
856 (id[ATA_ID_DATA_SET_MGMT] & 1)) 854 (id[ATA_ID_DATA_SET_MGMT] & 1))
857 return 1; 855 return true;
858 return 0; 856 return false;
859} 857}
860 858
861static inline int ata_id_has_zero_after_trim(const u16 *id) 859static inline bool ata_id_has_zero_after_trim(const u16 *id)
862{ 860{
863 /* DSM supported, deterministic read, and read zero after trim set */ 861 /* DSM supported, deterministic read, and read zero after trim set */
864 if (ata_id_has_trim(id) && 862 if (ata_id_has_trim(id) &&
865 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020) 863 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020)
866 return 1; 864 return true;
867 865
868 return 0; 866 return false;
869} 867}
870 868
871static inline int ata_id_current_chs_valid(const u16 *id) 869static inline bool ata_id_current_chs_valid(const u16 *id)
872{ 870{
873 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 871 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
874 has not been issued to the device then the values of 872 has not been issued to the device then the values of
@@ -880,11 +878,11 @@ static inline int ata_id_current_chs_valid(const u16 *id)
880 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */ 878 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */
881} 879}
882 880
883static inline int ata_id_is_cfa(const u16 *id) 881static inline bool ata_id_is_cfa(const u16 *id)
884{ 882{
885 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */ 883 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */
886 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */ 884 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */
887 return 1; 885 return true;
888 /* 886 /*
889 * 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
890 * 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
@@ -893,44 +891,40 @@ static inline int ata_id_is_cfa(const u16 *id)
893 * 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
894 * 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...
895 */ 893 */
896 if ((id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004) 894 return (id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004;
897 return 1;
898 return 0;
899} 895}
900 896
901static inline int ata_id_is_ssd(const u16 *id) 897static inline bool ata_id_is_ssd(const u16 *id)
902{ 898{
903 return id[ATA_ID_ROT_SPEED] == 0x01; 899 return id[ATA_ID_ROT_SPEED] == 0x01;
904} 900}
905 901
906static 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)
907{ 903{
908 /* 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. */
909 if (pio > 4 && ata_id_is_cfa(id)) 905 if (pio > 4 && ata_id_is_cfa(id))
910 return 0; 906 return false;
911 /* For PIO3 and higher it is mandatory. */ 907 /* For PIO3 and higher it is mandatory. */
912 if (pio > 2) 908 if (pio > 2)
913 return 1; 909 return true;
914 /* Turn it on when possible. */ 910 /* Turn it on when possible. */
915 if (ata_id_has_iordy(id)) 911 return ata_id_has_iordy(id);
916 return 1;
917 return 0;
918} 912}
919 913
920static inline int ata_drive_40wire(const u16 *dev_id) 914static inline bool ata_drive_40wire(const u16 *dev_id)
921{ 915{
922 if (ata_id_is_sata(dev_id)) 916 if (ata_id_is_sata(dev_id))
923 return 0; /* SATA */ 917 return false; /* SATA */
924 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000) 918 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000)
925 return 0; /* 80 wire */ 919 return false; /* 80 wire */
926 return 1; 920 return true;
927} 921}
928 922
929static inline int ata_drive_40wire_relaxed(const u16 *dev_id) 923static inline bool ata_drive_40wire_relaxed(const u16 *dev_id)
930{ 924{
931 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000) 925 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000)
932 return 0; /* 80 wire */ 926 return false; /* 80 wire */
933 return 1; 927 return true;
934} 928}
935 929
936static inline int atapi_cdb_len(const u16 *dev_id) 930static inline int atapi_cdb_len(const u16 *dev_id)
@@ -943,12 +937,12 @@ static inline int atapi_cdb_len(const u16 *dev_id)
943 } 937 }
944} 938}
945 939
946static inline int atapi_command_packet_set(const u16 *dev_id) 940static inline bool atapi_command_packet_set(const u16 *dev_id)
947{ 941{
948 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f; 942 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f;
949} 943}
950 944
951static inline int atapi_id_dmadir(const u16 *dev_id) 945static inline bool atapi_id_dmadir(const u16 *dev_id)
952{ 946{
953 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);
954} 948}
@@ -961,13 +955,13 @@ static inline int atapi_id_dmadir(const u16 *dev_id)
961 * 955 *
962 * It is called only once for each device. 956 * It is called only once for each device.
963 */ 957 */
964static inline int ata_id_is_lba_capacity_ok(u16 *id) 958static inline bool ata_id_is_lba_capacity_ok(u16 *id)
965{ 959{
966 unsigned long lba_sects, chs_sects, head, tail; 960 unsigned long lba_sects, chs_sects, head, tail;
967 961
968 /* No non-LBA info .. so valid! */ 962 /* No non-LBA info .. so valid! */
969 if (id[ATA_ID_CYLS] == 0) 963 if (id[ATA_ID_CYLS] == 0)
970 return 1; 964 return true;
971 965
972 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); 966 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
973 967
@@ -982,13 +976,13 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
982 id[ATA_ID_SECTORS] == 63 && 976 id[ATA_ID_SECTORS] == 63 &&
983 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && 977 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) &&
984 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) 978 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS]))
985 return 1; 979 return true;
986 980
987 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];
988 982
989 /* 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 */
990 if (lba_sects - chs_sects < chs_sects/10) 984 if (lba_sects - chs_sects < chs_sects/10)
991 return 1; 985 return true;
992 986
993 /* some drives have the word order reversed */ 987 /* some drives have the word order reversed */
994 head = (lba_sects >> 16) & 0xffff; 988 head = (lba_sects >> 16) & 0xffff;
@@ -997,10 +991,10 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
997 991
998 if (lba_sects - chs_sects < chs_sects/10) { 992 if (lba_sects - chs_sects < chs_sects/10) {
999 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); 993 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects);
1000 return 1; /* LBA capacity is (now) good */ 994 return true; /* LBA capacity is (now) good */
1001 } 995 }
1002 996
1003 return 0; /* LBA capacity value may be bad */ 997 return false; /* LBA capacity value may be bad */
1004} 998}
1005 999
1006static inline void ata_id_to_hd_driveid(u16 *id) 1000static inline void ata_id_to_hd_driveid(u16 *id)
@@ -1058,19 +1052,19 @@ static inline int is_multi_taskfile(struct ata_taskfile *tf)
1058 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT); 1052 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
1059} 1053}
1060 1054
1061static inline int ata_ok(u8 status) 1055static inline bool ata_ok(u8 status)
1062{ 1056{
1063 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))
1064 == ATA_DRDY); 1058 == ATA_DRDY);
1065} 1059}
1066 1060
1067static inline int lba_28_ok(u64 block, u32 n_block) 1061static inline bool lba_28_ok(u64 block, u32 n_block)
1068{ 1062{
1069 /* check the ending block number: must be LESS THAN 0x0fffffff */ 1063 /* check the ending block number: must be LESS THAN 0x0fffffff */
1070 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256); 1064 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256);
1071} 1065}
1072 1066
1073static inline int lba_48_ok(u64 block, u32 n_block) 1067static inline bool lba_48_ok(u64 block, u32 n_block)
1074{ 1068{
1075 /* check the ending block number */ 1069 /* check the ending block number */
1076 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); 1070 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);