[PATCH] libata: move err_mask to ata_queued_cmd
[pandora-kernel.git] / drivers / scsi / sata_sx4.c
index 0ec21e0..58da854 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/device.h>
-#include "scsi.h"
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
 #include <asm/io.h>
 #include "sata_promise.h"
 
 #define DRV_NAME       "sata_sx4"
-#define DRV_VERSION    "0.7"
+#define DRV_VERSION    "0.8"
 
 
 enum {
@@ -177,7 +177,7 @@ static void pdc20621_irq_clear(struct ata_port *ap);
 static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc);
 
 
-static Scsi_Host_Template pdc_sata_sht = {
+static struct scsi_host_template pdc_sata_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
@@ -215,7 +215,7 @@ static const struct ata_port_operations pdc_20621_ops = {
        .host_stop              = pdc20621_host_stop,
 };
 
-static struct ata_port_info pdc_port_info[] = {
+static const struct ata_port_info pdc_port_info[] = {
        /* board_20621 */
        {
                .sht            = &pdc_sata_sht,
@@ -229,7 +229,7 @@ static struct ata_port_info pdc_port_info[] = {
 
 };
 
-static struct pci_device_id pdc_sata_pci_tbl[] = {
+static const struct pci_device_id pdc_sata_pci_tbl[] = {
        { PCI_VENDOR_ID_PROMISE, 0x6622, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
          board_20621 },
        { }     /* terminate list */
@@ -450,14 +450,14 @@ static inline void pdc20621_host_pkt(struct ata_taskfile *tf, u8 *buf,
 
 static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
 {
-       struct scatterlist *sg = qc->sg;
+       struct scatterlist *sg;
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
        void __iomem *mmio = ap->host_set->mmio_base;
        struct pdc_host_priv *hpriv = ap->host_set->private_data;
        void __iomem *dimm_mmio = hpriv->dimm_mmio;
        unsigned int portno = ap->port_no;
-       unsigned int i, last, idx, total_len = 0, sgt_len;
+       unsigned int i, idx, total_len = 0, sgt_len;
        u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
 
        assert(qc->flags & ATA_QCFLAG_DMAMAP);
@@ -470,12 +470,11 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
        /*
         * Build S/G table
         */
-       last = qc->n_elem;
        idx = 0;
-       for (i = 0; i < last; i++) {
-               buf[idx++] = cpu_to_le32(sg_dma_address(&sg[i]));
-               buf[idx++] = cpu_to_le32(sg_dma_len(&sg[i]));
-               total_len += sg_dma_len(&sg[i]);
+       ata_for_each_sg(sg, qc) {
+               buf[idx++] = cpu_to_le32(sg_dma_address(sg));
+               buf[idx++] = cpu_to_le32(sg_dma_len(sg));
+               total_len += sg_dma_len(sg);
        }
        buf[idx - 1] |= cpu_to_le32(ATA_PRD_EOT);
        sgt_len = idx * 4;
@@ -719,7 +718,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
                        VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id,
                                readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
                        /* get drive status; clear intr; complete txn */
-                       ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
+                       qc->err_mask |= ac_err_mask(ata_wait_idle(ap));
+                       ata_qc_complete(qc);
                        pdc20621_pop_hdma(qc);
                }
 
@@ -757,7 +757,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
                        VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id,
                                readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
                        /* get drive status; clear intr; complete txn */
-                       ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
+                       qc->err_mask |= ac_err_mask(ata_wait_idle(ap));
+                       ata_qc_complete(qc);
                        pdc20621_pop_hdma(qc);
                }
                handled = 1;
@@ -767,7 +768,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
 
                status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
                DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status);
-               ata_qc_complete(qc, ac_err_mask(status));
+               qc->err_mask |= ac_err_mask(status);
+               ata_qc_complete(qc);
                handled = 1;
 
        } else {
@@ -882,7 +884,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
        case ATA_PROT_DMA:
        case ATA_PROT_NODATA:
                printk(KERN_ERR "ata%u: command timeout\n", ap->id);
-               ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap)));
+               qc->err_mask |= __ac_err_mask(ata_wait_idle(ap));
+               ata_qc_complete(qc);
                break;
 
        default:
@@ -891,7 +894,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
                printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
                       ap->id, qc->tf.command, drv_stat);
 
-               ata_qc_complete(qc, ac_err_mask(drv_stat));
+               qc->err_mask |= ac_err_mask(drv_stat);
+               ata_qc_complete(qc);
                break;
        }