.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | |
---|
2 | 3 | /* |
---|
3 | 4 | * Copyright 2003-2004 Red Hat, Inc. All rights reserved. |
---|
4 | 5 | * Copyright 2003-2004 Jeff Garzik |
---|
5 | 6 | * |
---|
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 | | - * |
---|
22 | 7 | * libata documentation is available via 'make {ps|pdf}docs', |
---|
23 | 8 | * as Documentation/driver-api/libata.rst |
---|
24 | 9 | * |
---|
25 | 10 | * Hardware documentation available from http://www.t13.org/ |
---|
26 | | - * |
---|
27 | 11 | */ |
---|
28 | 12 | |
---|
29 | 13 | #ifndef __LINUX_ATA_H__ |
---|
.. | .. |
---|
581 | 565 | ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \ |
---|
582 | 566 | ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \ |
---|
583 | 567 | ((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))) |
---|
584 | 580 | #define ata_id_iordy_disable(id) ((id)[ATA_ID_CAPABILITY] & (1 << 10)) |
---|
585 | 581 | #define ata_id_has_iordy(id) ((id)[ATA_ID_CAPABILITY] & (1 << 11)) |
---|
586 | 582 | #define ata_id_u32(id,n) \ |
---|
.. | .. |
---|
593 | 589 | |
---|
594 | 590 | #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20) |
---|
595 | 591 | #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)) |
---|
599 | 592 | |
---|
600 | 593 | static inline bool ata_id_has_hipm(const u16 *id) |
---|
601 | 594 | { |
---|
.. | .. |
---|
606 | 599 | |
---|
607 | 600 | return val & (1 << 9); |
---|
608 | 601 | } |
---|
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 | | - |
---|
620 | 602 | |
---|
621 | 603 | static inline bool ata_id_has_fua(const u16 *id) |
---|
622 | 604 | { |
---|
.. | .. |
---|
786 | 768 | |
---|
787 | 769 | static inline bool ata_id_has_sense_reporting(const u16 *id) |
---|
788 | 770 | { |
---|
789 | | - if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15))) |
---|
| 771 | + if (!(id[ATA_ID_CFS_ENABLE_2] & BIT(15))) |
---|
790 | 772 | 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); |
---|
792 | 776 | } |
---|
793 | 777 | |
---|
794 | 778 | static inline bool ata_id_sense_reporting_enabled(const u16 *id) |
---|
795 | 779 | { |
---|
796 | | - if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15))) |
---|
| 780 | + if (!ata_id_has_sense_reporting(id)) |
---|
797 | 781 | 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); |
---|
799 | 786 | } |
---|
800 | 787 | |
---|
801 | 788 | /** |
---|