aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-11-27 05:28:53 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:10 -0500
commit405e66b38797875e80669eaf72d313dbb76533c3 (patch)
treea069f0bb4ae1e81a58bc8f8965a2443d25186f0d /include
parentf20ded38aa54b92dd0af32578b8916d0aa2d9e05 (diff)
libata: implement protocol tests
Implement protocol tests - ata_is_atapi(), ata_is_nodata(), ata_is_pio(), ata_is_dma(), ata_is_ncq() and ata_is_data() and use them to replace is_atapi_taskfile() and hard coded protocol tests. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ata.h71
1 files changed, 64 insertions, 7 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 3fbe6d7784ab..43fecf62773a 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -324,6 +324,13 @@ enum {
324 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ 324 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */
325 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ 325 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */
326 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ 326 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */
327
328 /* protocol flags */
329 ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */
330 ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */
331 ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA,
332 ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */
333 ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */
327}; 334};
328 335
329enum ata_tf_protocols { 336enum ata_tf_protocols {
@@ -373,6 +380,63 @@ struct ata_taskfile {
373 u8 command; /* IO operation */ 380 u8 command; /* IO operation */
374}; 381};
375 382
383/*
384 * protocol tests
385 */
386static inline unsigned int ata_prot_flags(u8 prot)
387{
388 switch (prot) {
389 case ATA_PROT_NODATA:
390 return 0;
391 case ATA_PROT_PIO:
392 return ATA_PROT_FLAG_PIO;
393 case ATA_PROT_DMA:
394 return ATA_PROT_FLAG_DMA;
395 case ATA_PROT_NCQ:
396 return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ;
397 case ATA_PROT_ATAPI_NODATA:
398 return ATA_PROT_FLAG_ATAPI;
399 case ATA_PROT_ATAPI:
400 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO;
401 case ATA_PROT_ATAPI_DMA:
402 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA;
403 }
404 return 0;
405}
406
407static inline int ata_is_atapi(u8 prot)
408{
409 return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI;
410}
411
412static inline int ata_is_nodata(u8 prot)
413{
414 return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA);
415}
416
417static inline int ata_is_pio(u8 prot)
418{
419 return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO;
420}
421
422static inline int ata_is_dma(u8 prot)
423{
424 return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA;
425}
426
427static inline int ata_is_ncq(u8 prot)
428{
429 return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ;
430}
431
432static inline int ata_is_data(u8 prot)
433{
434 return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA;
435}
436
437/*
438 * id tests
439 */
376#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) 440#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
377#define ata_id_has_lba(id) ((id)[49] & (1 << 9)) 441#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
378#define ata_id_has_dma(id) ((id)[49] & (1 << 8)) 442#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
@@ -594,13 +658,6 @@ static inline int atapi_command_packet_set(const u16 *dev_id)
594 return (dev_id[0] >> 8) & 0x1f; 658 return (dev_id[0] >> 8) & 0x1f;
595} 659}
596 660
597static inline int is_atapi_taskfile(const struct ata_taskfile *tf)
598{
599 return (tf->protocol == ATA_PROT_ATAPI) ||
600 (tf->protocol == ATA_PROT_ATAPI_NODATA) ||
601 (tf->protocol == ATA_PROT_ATAPI_DMA);
602}
603
604static inline int is_multi_taskfile(struct ata_taskfile *tf) 661static inline int is_multi_taskfile(struct ata_taskfile *tf)
605{ 662{
606 return (tf->command == ATA_CMD_READ_MULTI) || 663 return (tf->command == ATA_CMD_READ_MULTI) ||