hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/include/linux/ata.h
....@@ -1,29 +1,13 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12
23 /*
34 * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
45 * Copyright 2003-2004 Jeff Garzik
56 *
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2, or (at your option)
10
- * any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; see the file COPYING. If not, write to
19
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
- *
21
- *
227 * libata documentation is available via 'make {ps|pdf}docs',
238 * as Documentation/driver-api/libata.rst
249 *
2510 * Hardware documentation available from http://www.t13.org/
26
- *
2711 */
2812
2913 #ifndef __LINUX_ATA_H__
....@@ -581,6 +565,18 @@
581565 ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \
582566 ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \
583567 ((id)[ATA_ID_FEATURE_SUPP] & (1 << 2)))
568
+#define ata_id_has_devslp(id) \
569
+ ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \
570
+ ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \
571
+ ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8)))
572
+#define ata_id_has_ncq_autosense(id) \
573
+ ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \
574
+ ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \
575
+ ((id)[ATA_ID_FEATURE_SUPP] & (1 << 7)))
576
+#define ata_id_has_dipm(id) \
577
+ ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \
578
+ ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \
579
+ ((id)[ATA_ID_FEATURE_SUPP] & (1 << 3)))
584580 #define ata_id_iordy_disable(id) ((id)[ATA_ID_CAPABILITY] & (1 << 10))
585581 #define ata_id_has_iordy(id) ((id)[ATA_ID_CAPABILITY] & (1 << 11))
586582 #define ata_id_u32(id,n) \
....@@ -593,9 +589,6 @@
593589
594590 #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20)
595591 #define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4))
596
-#define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8))
597
-#define ata_id_has_ncq_autosense(id) \
598
- ((id)[ATA_ID_FEATURE_SUPP] & (1 << 7))
599592
600593 static inline bool ata_id_has_hipm(const u16 *id)
601594 {
....@@ -606,17 +599,6 @@
606599
607600 return val & (1 << 9);
608601 }
609
-
610
-static inline bool ata_id_has_dipm(const u16 *id)
611
-{
612
- u16 val = id[ATA_ID_FEATURE_SUPP];
613
-
614
- if (val == 0 || val == 0xffff)
615
- return false;
616
-
617
- return val & (1 << 3);
618
-}
619
-
620602
621603 static inline bool ata_id_has_fua(const u16 *id)
622604 {
....@@ -786,16 +768,21 @@
786768
787769 static inline bool ata_id_has_sense_reporting(const u16 *id)
788770 {
789
- if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
771
+ if (!(id[ATA_ID_CFS_ENABLE_2] & BIT(15)))
790772 return false;
791
- return id[ATA_ID_COMMAND_SET_3] & (1 << 6);
773
+ if ((id[ATA_ID_COMMAND_SET_3] & (BIT(15) | BIT(14))) != BIT(14))
774
+ return false;
775
+ return id[ATA_ID_COMMAND_SET_3] & BIT(6);
792776 }
793777
794778 static inline bool ata_id_sense_reporting_enabled(const u16 *id)
795779 {
796
- if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
780
+ if (!ata_id_has_sense_reporting(id))
797781 return false;
798
- return id[ATA_ID_COMMAND_SET_4] & (1 << 6);
782
+ /* ata_id_has_sense_reporting() == true, word 86 must have bit 15 set */
783
+ if ((id[ATA_ID_COMMAND_SET_4] & (BIT(15) | BIT(14))) != BIT(14))
784
+ return false;
785
+ return id[ATA_ID_COMMAND_SET_4] & BIT(6);
799786 }
800787
801788 /**