From b1c04e80c6da5f5d3d4778ede23c59666135fdeb Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 14 Jul 2016 09:05:42 +0900 Subject: libata: return boolean values from ata_is_* This way we don't have to worry about the exact bit postition of the test to leak out and any crazy propagation effects in the callers. Suggested-by: Tejun Heo Signed-off-by: Christoph Hellwig Signed-off-by: Tejun Heo --- include/linux/libata.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include/linux/libata.h') diff --git a/include/linux/libata.h b/include/linux/libata.h index d15c19e331d1..4e5a09c6dc10 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1063,32 +1063,32 @@ static inline unsigned int ata_prot_flags(u8 prot) return 0; } -static inline int ata_is_atapi(u8 prot) +static inline bool ata_is_atapi(u8 prot) { return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI; } -static inline int ata_is_nodata(u8 prot) +static inline bool ata_is_nodata(u8 prot) { return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA); } -static inline int ata_is_pio(u8 prot) +static inline bool ata_is_pio(u8 prot) { return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO; } -static inline int ata_is_dma(u8 prot) +static inline bool ata_is_dma(u8 prot) { return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA; } -static inline int ata_is_ncq(u8 prot) +static inline bool ata_is_ncq(u8 prot) { return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ; } -static inline int ata_is_data(u8 prot) +static inline bool ata_is_data(u8 prot) { return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA; } @@ -1407,7 +1407,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap) return ap->nr_pmp_links != 0; } -static inline int ata_is_host_link(const struct ata_link *link) +static inline bool ata_is_host_link(const struct ata_link *link) { return link == &link->ap->link || link == link->ap->slave_link; } @@ -1422,7 +1422,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap) return false; } -static inline int ata_is_host_link(const struct ata_link *link) +static inline bool ata_is_host_link(const struct ata_link *link) { return 1; } -- cgit v1.2.3 From 5b844b63ddfb65aef923eaabe0420196fd71dd13 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Thu, 14 Jul 2016 09:05:48 +0900 Subject: ata: Handle ATA NCQ NO-DATA commands correctly Add a new taskfile protocol ATA_PROT_NCQ_NODATA to handle ATA NCQ NO-DATA commands correctly. And fixup ata_scsi_zbc_out_xlat() to use it. Signed-off-by: Hannes Reinecke Signed-off-by: Christoph Hellwig Signed-off-by: Tejun Heo --- include/linux/libata.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/linux/libata.h') diff --git a/include/linux/libata.h b/include/linux/libata.h index 4e5a09c6dc10..1abd6690c776 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1053,6 +1053,8 @@ static inline unsigned int ata_prot_flags(u8 prot) return ATA_PROT_FLAG_DMA; case ATA_PROT_NCQ: return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ; + case ATA_PROT_NCQ_NODATA: + return ATA_PROT_FLAG_NCQ; case ATAPI_PROT_NODATA: return ATA_PROT_FLAG_ATAPI; case ATAPI_PROT_PIO: -- cgit v1.2.3 From eb0effdf53b061bd57d8efc86032454e79487263 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 16 Jul 2016 22:16:41 +0900 Subject: libata: remove ata_is_nodata The only caller can just check for !ata_is_data instead. Signed-off-by: Christoph Hellwig Signed-off-by: Tejun Heo --- include/linux/libata.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/linux/libata.h') diff --git a/include/linux/libata.h b/include/linux/libata.h index 1abd6690c776..283b6be6c319 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1070,11 +1070,6 @@ static inline bool ata_is_atapi(u8 prot) return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI; } -static inline bool ata_is_nodata(u8 prot) -{ - return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA); -} - static inline bool ata_is_pio(u8 prot) { return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO; -- cgit v1.2.3 From d6e50e379eb1e7f2426eac61a1bbbf6e4cf68905 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 16 Jul 2016 22:16:42 +0900 Subject: libata: remove ATA_PROT_FLAG_DATA Instead we can simply check for PIO or DMA in ata_is_data. Signed-off-by: Christoph Hellwig Signed-off-by: Tejun Heo --- include/linux/libata.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/linux/libata.h') diff --git a/include/linux/libata.h b/include/linux/libata.h index 283b6be6c319..5838fbf6acf7 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -149,7 +149,6 @@ enum { /* protocol flags */ ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */ ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */ - ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA, ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */ ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */ @@ -1087,7 +1086,7 @@ static inline bool ata_is_ncq(u8 prot) static inline bool ata_is_data(u8 prot) { - return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA; + return ata_prot_flags(prot) & (ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA); } static inline int is_multi_taskfile(struct ata_taskfile *tf) -- cgit v1.2.3 From 37f92d77dc45d1fb74eff8501f26e72a3dcaa3cf Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 16 Jul 2016 22:16:43 +0900 Subject: ata: define ATA_PROT_* in terms of ATA_PROT_FLAG_* This avoid the need to always translate between the two in ata_prot_flags and generally cleans up the taskfile protocol usage. Signed-off-by: Christoph Hellwig Signed-off-by: Tejun Heo --- include/linux/libata.h | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) (limited to 'include/linux/libata.h') diff --git a/include/linux/libata.h b/include/linux/libata.h index 5838fbf6acf7..e37d4f99f510 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -146,12 +146,6 @@ enum { ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ - /* protocol flags */ - ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */ - ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */ - ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */ - ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */ - /* struct ata_device stuff */ ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ @@ -1038,55 +1032,29 @@ extern const unsigned long sata_deb_timing_long[]; extern struct ata_port_operations ata_dummy_port_ops; extern const struct ata_port_info ata_dummy_port_info; -/* - * protocol tests - */ -static inline unsigned int ata_prot_flags(u8 prot) -{ - switch (prot) { - case ATA_PROT_NODATA: - return 0; - case ATA_PROT_PIO: - return ATA_PROT_FLAG_PIO; - case ATA_PROT_DMA: - return ATA_PROT_FLAG_DMA; - case ATA_PROT_NCQ: - return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ; - case ATA_PROT_NCQ_NODATA: - return ATA_PROT_FLAG_NCQ; - case ATAPI_PROT_NODATA: - return ATA_PROT_FLAG_ATAPI; - case ATAPI_PROT_PIO: - return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO; - case ATAPI_PROT_DMA: - return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA; - } - return 0; -} - static inline bool ata_is_atapi(u8 prot) { - return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI; + return prot & ATA_PROT_FLAG_ATAPI; } static inline bool ata_is_pio(u8 prot) { - return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO; + return prot & ATA_PROT_FLAG_PIO; } static inline bool ata_is_dma(u8 prot) { - return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA; + return prot & ATA_PROT_FLAG_DMA; } static inline bool ata_is_ncq(u8 prot) { - return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ; + return prot & ATA_PROT_FLAG_NCQ; } static inline bool ata_is_data(u8 prot) { - return ata_prot_flags(prot) & (ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA); + return prot & (ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA); } static inline int is_multi_taskfile(struct ata_taskfile *tf) -- cgit v1.2.3