Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfashe...
[sfrench/cifs-2.6.git] / drivers / ata / pdc_adma.c
index 8d1b03d5bcb1e65d63c5b67121791e8fe1eee77a..8e1b7e9c0ae42b7fe66ed4fb047234dbeee10c46 100644 (file)
 #define DRV_VERSION    "1.0"
 
 /* macro to calculate base address for ATA regs */
-#define ADMA_ATA_REGS(base,port_no)    ((base) + ((port_no) * 0x40))
+#define ADMA_ATA_REGS(base, port_no)   ((base) + ((port_no) * 0x40))
 
 /* macro to calculate base address for ADMA regs */
-#define ADMA_REGS(base,port_no)                ((base) + 0x80 + ((port_no) * 0x20))
+#define ADMA_REGS(base, port_no)       ((base) + 0x80 + ((port_no) * 0x20))
 
 /* macro to obtain addresses from ata_port */
 #define ADMA_PORT_REGS(ap) \
@@ -128,7 +128,7 @@ struct adma_port_priv {
        adma_state_t            state;
 };
 
-static int adma_ata_init_one (struct pci_dev *pdev,
+static int adma_ata_init_one(struct pci_dev *pdev,
                                const struct pci_device_id *ent);
 static int adma_port_start(struct ata_port *ap);
 static void adma_host_stop(struct ata_host *host);
@@ -318,11 +318,12 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
        struct scatterlist *sg;
        struct ata_port *ap = qc->ap;
        struct adma_port_priv *pp = ap->private_data;
-       u8  *buf = pp->pkt;
+       u8  *buf = pp->pkt, *last_buf = NULL;
        int i = (2 + buf[3]) * 8;
        u8 pFLAGS = pORD | ((qc->tf.flags & ATA_TFLAG_WRITE) ? pDIRO : 0);
+       unsigned int si;
 
-       ata_for_each_sg(sg, qc) {
+       for_each_sg(qc->sg, sg, qc->n_elem, si) {
                u32 addr;
                u32 len;
 
@@ -334,20 +335,23 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
                *(__le32 *)(buf + i) = cpu_to_le32(len);
                i += 4;
 
-               if (ata_sg_is_last(sg, qc))
-                       pFLAGS |= pEND;
+               last_buf = &buf[i];
                buf[i++] = pFLAGS;
                buf[i++] = qc->dev->dma_mode & 0xf;
                buf[i++] = 0;   /* pPKLW */
                buf[i++] = 0;   /* reserved */
 
-               *(__le32 *)(buf + i)
-                       (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
+               *(__le32 *)(buf + i) =
+                       (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
                i += 4;
 
                VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4,
                                        (unsigned long)addr, len);
        }
+
+       if (likely(last_buf))
+               *last_buf |= pEND;
+
        return i;
 }
 
@@ -452,7 +456,7 @@ static unsigned int adma_qc_issue(struct ata_queued_cmd *qc)
                adma_packet_start(qc);
                return 0;
 
-       case ATA_PROT_ATAPI_DMA:
+       case ATAPI_PROT_DMA:
                BUG();
                break;
 
@@ -614,7 +618,7 @@ static int adma_port_start(struct ata_port *ap)
                return -ENOMEM;
        /* paranoia? */
        if ((pp->pkt_dma & 7) != 0) {
-               printk("bad alignment for pp->pkt_dma: %08x\n",
+               printk(KERN_ERR "bad alignment for pp->pkt_dma: %08x\n",
                                                (u32)pp->pkt_dma);
                return -ENOMEM;
        }