aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h186
1 files changed, 115 insertions, 71 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 124033cb5e9b..bc5a8d0c7090 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -35,6 +35,7 @@
35#include <linux/workqueue.h> 35#include <linux/workqueue.h>
36#include <scsi/scsi_host.h> 36#include <scsi/scsi_host.h>
37#include <linux/acpi.h> 37#include <linux/acpi.h>
38#include <linux/cdrom.h>
38 39
39/* 40/*
40 * Define if arch has non-standard setup. This is a _PCI_ standard 41 * Define if arch has non-standard setup. This is a _PCI_ standard
@@ -143,10 +144,11 @@ enum {
143 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ 144 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */
144 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 145 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
145 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ 146 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
146 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 147 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
148 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
147 149
148 ATA_DFLAG_DETACH = (1 << 16), 150 ATA_DFLAG_DETACH = (1 << 24),
149 ATA_DFLAG_DETACHED = (1 << 17), 151 ATA_DFLAG_DETACHED = (1 << 25),
150 152
151 ATA_DEV_UNKNOWN = 0, /* unknown device */ 153 ATA_DEV_UNKNOWN = 0, /* unknown device */
152 ATA_DEV_ATA = 1, /* ATA device */ 154 ATA_DEV_ATA = 1, /* ATA device */
@@ -217,9 +219,7 @@ enum {
217 219
218 /* struct ata_queued_cmd flags */ 220 /* struct ata_queued_cmd flags */
219 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ 221 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */
220 ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */ 222 ATA_QCFLAG_DMAMAP = (1 << 1), /* SG table is DMA mapped */
221 ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */
222 ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
223 ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ 223 ATA_QCFLAG_IO = (1 << 3), /* standard IO command */
224 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ 224 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */
225 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ 225 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */
@@ -266,19 +266,15 @@ enum {
266 PORT_DISABLED = 2, 266 PORT_DISABLED = 2,
267 267
268 /* encoding various smaller bitmaps into a single 268 /* encoding various smaller bitmaps into a single
269 * unsigned int bitmap 269 * unsigned long bitmap
270 */ 270 */
271 ATA_BITS_PIO = 7, 271 ATA_NR_PIO_MODES = 7,
272 ATA_BITS_MWDMA = 5, 272 ATA_NR_MWDMA_MODES = 5,
273 ATA_BITS_UDMA = 8, 273 ATA_NR_UDMA_MODES = 8,
274 274
275 ATA_SHIFT_PIO = 0, 275 ATA_SHIFT_PIO = 0,
276 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_BITS_PIO, 276 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES,
277 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_BITS_MWDMA, 277 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES,
278
279 ATA_MASK_PIO = ((1 << ATA_BITS_PIO) - 1) << ATA_SHIFT_PIO,
280 ATA_MASK_MWDMA = ((1 << ATA_BITS_MWDMA) - 1) << ATA_SHIFT_MWDMA,
281 ATA_MASK_UDMA = ((1 << ATA_BITS_UDMA) - 1) << ATA_SHIFT_UDMA,
282 278
283 /* size of buffer to pad xfers ending on unaligned boundaries */ 279 /* size of buffer to pad xfers ending on unaligned boundaries */
284 ATA_DMA_PAD_SZ = 4, 280 ATA_DMA_PAD_SZ = 4,
@@ -349,6 +345,21 @@ enum {
349 ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ 345 ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */
350 ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ 346 ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */
351 ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */ 347 ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */
348
349 /* ATAPI command types */
350 ATAPI_READ = 0, /* READs */
351 ATAPI_WRITE = 1, /* WRITEs */
352 ATAPI_READ_CD = 2, /* READ CD [MSF] */
353 ATAPI_MISC = 3, /* the rest */
354};
355
356enum ata_xfer_mask {
357 ATA_MASK_PIO = ((1LU << ATA_NR_PIO_MODES) - 1)
358 << ATA_SHIFT_PIO,
359 ATA_MASK_MWDMA = ((1LU << ATA_NR_MWDMA_MODES) - 1)
360 << ATA_SHIFT_MWDMA,
361 ATA_MASK_UDMA = ((1LU << ATA_NR_UDMA_MODES) - 1)
362 << ATA_SHIFT_UDMA,
352}; 363};
353 364
354enum hsm_task_states { 365enum hsm_task_states {
@@ -446,8 +457,7 @@ struct ata_queued_cmd {
446 unsigned long flags; /* ATA_QCFLAG_xxx */ 457 unsigned long flags; /* ATA_QCFLAG_xxx */
447 unsigned int tag; 458 unsigned int tag;
448 unsigned int n_elem; 459 unsigned int n_elem;
449 unsigned int n_iter; 460 unsigned int mapped_n_elem;
450 unsigned int orig_n_elem;
451 461
452 int dma_dir; 462 int dma_dir;
453 463
@@ -455,17 +465,18 @@ struct ata_queued_cmd {
455 unsigned int sect_size; 465 unsigned int sect_size;
456 466
457 unsigned int nbytes; 467 unsigned int nbytes;
468 unsigned int raw_nbytes;
458 unsigned int curbytes; 469 unsigned int curbytes;
459 470
460 struct scatterlist *cursg; 471 struct scatterlist *cursg;
461 unsigned int cursg_ofs; 472 unsigned int cursg_ofs;
462 473
474 struct scatterlist *last_sg;
475 struct scatterlist saved_last_sg;
463 struct scatterlist sgent; 476 struct scatterlist sgent;
464 struct scatterlist pad_sgent; 477 struct scatterlist extra_sg[2];
465 void *buf_virt;
466 478
467 /* DO NOT iterate over __sg manually, use ata_for_each_sg() */ 479 struct scatterlist *sg;
468 struct scatterlist *__sg;
469 480
470 unsigned int err_mask; 481 unsigned int err_mask;
471 struct ata_taskfile result_tf; 482 struct ata_taskfile result_tf;
@@ -482,7 +493,7 @@ struct ata_port_stats {
482}; 493};
483 494
484struct ata_ering_entry { 495struct ata_ering_entry {
485 int is_io; 496 unsigned int eflags;
486 unsigned int err_mask; 497 unsigned int err_mask;
487 u64 timestamp; 498 u64 timestamp;
488}; 499};
@@ -522,9 +533,9 @@ struct ata_device {
522 unsigned int cdb_len; 533 unsigned int cdb_len;
523 534
524 /* per-dev xfer mask */ 535 /* per-dev xfer mask */
525 unsigned int pio_mask; 536 unsigned long pio_mask;
526 unsigned int mwdma_mask; 537 unsigned long mwdma_mask;
527 unsigned int udma_mask; 538 unsigned long udma_mask;
528 539
529 /* for CHS addressing */ 540 /* for CHS addressing */
530 u16 cylinders; /* Number of cylinders */ 541 u16 cylinders; /* Number of cylinders */
@@ -560,6 +571,8 @@ struct ata_eh_context {
560 int tries[ATA_MAX_DEVICES]; 571 int tries[ATA_MAX_DEVICES];
561 unsigned int classes[ATA_MAX_DEVICES]; 572 unsigned int classes[ATA_MAX_DEVICES];
562 unsigned int did_probe_mask; 573 unsigned int did_probe_mask;
574 unsigned int saved_ncq_enabled;
575 u8 saved_xfer_mode[ATA_MAX_DEVICES];
563}; 576};
564 577
565struct ata_acpi_drive 578struct ata_acpi_drive
@@ -686,7 +699,8 @@ struct ata_port_operations {
686 void (*bmdma_setup) (struct ata_queued_cmd *qc); 699 void (*bmdma_setup) (struct ata_queued_cmd *qc);
687 void (*bmdma_start) (struct ata_queued_cmd *qc); 700 void (*bmdma_start) (struct ata_queued_cmd *qc);
688 701
689 void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); 702 unsigned int (*data_xfer) (struct ata_device *dev, unsigned char *buf,
703 unsigned int buflen, int rw);
690 704
691 int (*qc_defer) (struct ata_queued_cmd *qc); 705 int (*qc_defer) (struct ata_queued_cmd *qc);
692 void (*qc_prep) (struct ata_queued_cmd *qc); 706 void (*qc_prep) (struct ata_queued_cmd *qc);
@@ -832,8 +846,6 @@ extern int ata_busy_sleep(struct ata_port *ap,
832 unsigned long timeout_pat, unsigned long timeout); 846 unsigned long timeout_pat, unsigned long timeout);
833extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline); 847extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline);
834extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline); 848extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline);
835extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn,
836 void *data, unsigned long delay);
837extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 849extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
838 unsigned long interval_msec, 850 unsigned long interval_msec,
839 unsigned long timeout_msec); 851 unsigned long timeout_msec);
@@ -848,6 +860,16 @@ extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
848extern void ata_tf_to_fis(const struct ata_taskfile *tf, 860extern void ata_tf_to_fis(const struct ata_taskfile *tf,
849 u8 pmp, int is_cmd, u8 *fis); 861 u8 pmp, int is_cmd, u8 *fis);
850extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); 862extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
863extern unsigned long ata_pack_xfermask(unsigned long pio_mask,
864 unsigned long mwdma_mask, unsigned long udma_mask);
865extern void ata_unpack_xfermask(unsigned long xfer_mask,
866 unsigned long *pio_mask, unsigned long *mwdma_mask,
867 unsigned long *udma_mask);
868extern u8 ata_xfer_mask2mode(unsigned long xfer_mask);
869extern unsigned long ata_xfer_mode2mask(u8 xfer_mode);
870extern int ata_xfer_mode2shift(unsigned long xfer_mode);
871extern const char *ata_mode_string(unsigned long xfer_mask);
872extern unsigned long ata_id_xfermask(const u16 *id);
851extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); 873extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
852extern void ata_std_dev_select(struct ata_port *ap, unsigned int device); 874extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
853extern u8 ata_check_status(struct ata_port *ap); 875extern u8 ata_check_status(struct ata_port *ap);
@@ -856,17 +878,15 @@ extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
856extern int ata_port_start(struct ata_port *ap); 878extern int ata_port_start(struct ata_port *ap);
857extern int ata_sff_port_start(struct ata_port *ap); 879extern int ata_sff_port_start(struct ata_port *ap);
858extern irqreturn_t ata_interrupt(int irq, void *dev_instance); 880extern irqreturn_t ata_interrupt(int irq, void *dev_instance);
859extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, 881extern unsigned int ata_data_xfer(struct ata_device *dev,
860 unsigned int buflen, int write_data); 882 unsigned char *buf, unsigned int buflen, int rw);
861extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, 883extern unsigned int ata_data_xfer_noirq(struct ata_device *dev,
862 unsigned int buflen, int write_data); 884 unsigned char *buf, unsigned int buflen, int rw);
863extern int ata_std_qc_defer(struct ata_queued_cmd *qc); 885extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
864extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc); 886extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc);
865extern void ata_qc_prep(struct ata_queued_cmd *qc); 887extern void ata_qc_prep(struct ata_queued_cmd *qc);
866extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); 888extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
867extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); 889extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
868extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
869 unsigned int buflen);
870extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 890extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
871 unsigned int n_elem); 891 unsigned int n_elem);
872extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); 892extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
@@ -875,7 +895,6 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
875 unsigned int ofs, unsigned int len); 895 unsigned int ofs, unsigned int len);
876extern void ata_id_c_string(const u16 *id, unsigned char *s, 896extern void ata_id_c_string(const u16 *id, unsigned char *s,
877 unsigned int ofs, unsigned int len); 897 unsigned int ofs, unsigned int len);
878extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown);
879extern void ata_bmdma_setup(struct ata_queued_cmd *qc); 898extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
880extern void ata_bmdma_start(struct ata_queued_cmd *qc); 899extern void ata_bmdma_start(struct ata_queued_cmd *qc);
881extern void ata_bmdma_stop(struct ata_queued_cmd *qc); 900extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
@@ -910,6 +929,7 @@ extern u8 ata_irq_on(struct ata_port *ap);
910extern int ata_cable_40wire(struct ata_port *ap); 929extern int ata_cable_40wire(struct ata_port *ap);
911extern int ata_cable_80wire(struct ata_port *ap); 930extern int ata_cable_80wire(struct ata_port *ap);
912extern int ata_cable_sata(struct ata_port *ap); 931extern int ata_cable_sata(struct ata_port *ap);
932extern int ata_cable_ignore(struct ata_port *ap);
913extern int ata_cable_unknown(struct ata_port *ap); 933extern int ata_cable_unknown(struct ata_port *ap);
914 934
915/* 935/*
@@ -917,11 +937,13 @@ extern int ata_cable_unknown(struct ata_port *ap);
917 */ 937 */
918 938
919extern unsigned int ata_pio_need_iordy(const struct ata_device *); 939extern unsigned int ata_pio_need_iordy(const struct ata_device *);
940extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode);
920extern int ata_timing_compute(struct ata_device *, unsigned short, 941extern int ata_timing_compute(struct ata_device *, unsigned short,
921 struct ata_timing *, int, int); 942 struct ata_timing *, int, int);
922extern void ata_timing_merge(const struct ata_timing *, 943extern void ata_timing_merge(const struct ata_timing *,
923 const struct ata_timing *, struct ata_timing *, 944 const struct ata_timing *, struct ata_timing *,
924 unsigned int); 945 unsigned int);
946extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle);
925 947
926enum { 948enum {
927 ATA_TIMING_SETUP = (1 << 0), 949 ATA_TIMING_SETUP = (1 << 0),
@@ -948,15 +970,40 @@ static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
948 return &ap->__acpi_init_gtm; 970 return &ap->__acpi_init_gtm;
949 return NULL; 971 return NULL;
950} 972}
951extern int ata_acpi_cbl_80wire(struct ata_port *ap);
952int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); 973int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm);
953int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); 974int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm);
975unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
976 const struct ata_acpi_gtm *gtm);
977int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm);
954#else 978#else
955static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) 979static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
956{ 980{
957 return NULL; 981 return NULL;
958} 982}
959static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } 983
984static inline int ata_acpi_stm(const struct ata_port *ap,
985 struct ata_acpi_gtm *stm)
986{
987 return -ENOSYS;
988}
989
990static inline int ata_acpi_gtm(const struct ata_port *ap,
991 struct ata_acpi_gtm *stm)
992{
993 return -ENOSYS;
994}
995
996static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev,
997 const struct ata_acpi_gtm *gtm)
998{
999 return 0;
1000}
1001
1002static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
1003 const struct ata_acpi_gtm *gtm)
1004{
1005 return 0;
1006}
960#endif 1007#endif
961 1008
962#ifdef CONFIG_PCI 1009#ifdef CONFIG_PCI
@@ -985,8 +1032,12 @@ extern int ata_pci_init_bmdma(struct ata_host *host);
985extern int ata_pci_prepare_sff_host(struct pci_dev *pdev, 1032extern int ata_pci_prepare_sff_host(struct pci_dev *pdev,
986 const struct ata_port_info * const * ppi, 1033 const struct ata_port_info * const * ppi,
987 struct ata_host **r_host); 1034 struct ata_host **r_host);
1035extern int ata_pci_activate_sff_host(struct ata_host *host,
1036 irq_handler_t irq_handler,
1037 struct scsi_host_template *sht);
988extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 1038extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
989extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); 1039extern unsigned long ata_pci_default_filter(struct ata_device *dev,
1040 unsigned long xfer_mask);
990#endif /* CONFIG_PCI */ 1041#endif /* CONFIG_PCI */
991 1042
992/* 1043/*
@@ -1074,35 +1125,6 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
1074 const char *name); 1125 const char *name);
1075#endif 1126#endif
1076 1127
1077/*
1078 * qc helpers
1079 */
1080static inline struct scatterlist *
1081ata_qc_first_sg(struct ata_queued_cmd *qc)
1082{
1083 qc->n_iter = 0;
1084 if (qc->n_elem)
1085 return qc->__sg;
1086 if (qc->pad_len)
1087 return &qc->pad_sgent;
1088 return NULL;
1089}
1090
1091static inline struct scatterlist *
1092ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
1093{
1094 if (sg == &qc->pad_sgent)
1095 return NULL;
1096 if (++qc->n_iter < qc->n_elem)
1097 return sg_next(sg);
1098 if (qc->pad_len)
1099 return &qc->pad_sgent;
1100 return NULL;
1101}
1102
1103#define ata_for_each_sg(sg, qc) \
1104 for (sg = ata_qc_first_sg(qc); sg; sg = ata_qc_next_sg(sg, qc))
1105
1106static inline unsigned int ata_tag_valid(unsigned int tag) 1128static inline unsigned int ata_tag_valid(unsigned int tag)
1107{ 1129{
1108 return (tag < ATA_MAX_QUEUE) ? 1 : 0; 1130 return (tag < ATA_MAX_QUEUE) ? 1 : 0;
@@ -1337,15 +1359,16 @@ static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)
1337static inline void ata_qc_reinit(struct ata_queued_cmd *qc) 1359static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
1338{ 1360{
1339 qc->dma_dir = DMA_NONE; 1361 qc->dma_dir = DMA_NONE;
1340 qc->__sg = NULL; 1362 qc->sg = NULL;
1341 qc->flags = 0; 1363 qc->flags = 0;
1342 qc->cursg = NULL; 1364 qc->cursg = NULL;
1343 qc->cursg_ofs = 0; 1365 qc->cursg_ofs = 0;
1344 qc->nbytes = qc->curbytes = 0; 1366 qc->nbytes = qc->raw_nbytes = qc->curbytes = 0;
1345 qc->n_elem = 0; 1367 qc->n_elem = 0;
1346 qc->n_iter = 0; 1368 qc->mapped_n_elem = 0;
1347 qc->err_mask = 0; 1369 qc->err_mask = 0;
1348 qc->pad_len = 0; 1370 qc->pad_len = 0;
1371 qc->last_sg = NULL;
1349 qc->sect_size = ATA_SECT_SIZE; 1372 qc->sect_size = ATA_SECT_SIZE;
1350 1373
1351 ata_tf_init(qc->dev, &qc->tf); 1374 ata_tf_init(qc->dev, &qc->tf);
@@ -1362,6 +1385,27 @@ static inline int ata_try_flush_cache(const struct ata_device *dev)
1362 ata_id_has_flush_ext(dev->id); 1385 ata_id_has_flush_ext(dev->id);
1363} 1386}
1364 1387
1388static inline int atapi_cmd_type(u8 opcode)
1389{
1390 switch (opcode) {
1391 case GPCMD_READ_10:
1392 case GPCMD_READ_12:
1393 return ATAPI_READ;
1394
1395 case GPCMD_WRITE_10:
1396 case GPCMD_WRITE_12:
1397 case GPCMD_WRITE_AND_VERIFY_10:
1398 return ATAPI_WRITE;
1399
1400 case GPCMD_READ_CD:
1401 case GPCMD_READ_CD_MSF:
1402 return ATAPI_READ_CD;
1403
1404 default:
1405 return ATAPI_MISC;
1406 }
1407}
1408
1365static inline unsigned int ac_err_mask(u8 status) 1409static inline unsigned int ac_err_mask(u8 status)
1366{ 1410{
1367 if (status & (ATA_BUSY | ATA_DRQ)) 1411 if (status & (ATA_BUSY | ATA_DRQ))