]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/libata.h
libata: Fix a large collection of DMA mode mismatches
[linux-2.6-omap-h63xx.git] / include / linux / libata.h
index 80233fdc159f06bb7c6b2635f1a4a6802fb0ca71..225bfc5bd9ec1eb43b143d059f926918a30c2656 100644 (file)
@@ -1429,6 +1429,28 @@ static inline unsigned long ata_deadline(unsigned long from_jiffies,
        return from_jiffies + msecs_to_jiffies(timeout_msecs);
 }
 
+/* Don't open code these in drivers as there are traps. Firstly the range may
+   change in future hardware and specs, secondly 0xFF means 'no DMA' but is
+   > UDMA_0. Dyma ddreigiau */
+
+static inline int ata_using_mwdma(struct ata_device *adev)
+{
+       if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
+               return 1;
+       return 0;
+}
+
+static inline int ata_using_udma(struct ata_device *adev)
+{
+       if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
+               return 1;
+       return 0;
+}
+
+static inline int ata_dma_enabled(struct ata_device *adev)
+{
+       return (adev->dma_mode == 0xFF ? 0 : 1);
+}
 
 /**************************************************************************
  * PMP - drivers/ata/libata-pmp.c