V4L/DVB: saa7127: support new vbi ops to set/get VBI format
[safe/jmp/linux-2.6] / drivers / scsi / eata.c
index 05163ce..d1c3137 100644 (file)
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 #include <asm/dma.h>
 #include <asm/io.h>
@@ -524,7 +525,6 @@ static struct scsi_host_template driver_template = {
        .this_id = 7,
        .unchecked_isa_dma = 1,
        .use_clustering = ENABLE_CLUSTERING,
-       .use_sg_chaining = ENABLE_SG_CHAINING,
 };
 
 #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD)
@@ -1427,7 +1427,7 @@ static int port_detect(unsigned long port_base, unsigned int j,
 
        if (ha->pdev) {
                pci_set_master(ha->pdev);
-               if (pci_set_dma_mask(ha->pdev, DMA_32BIT_MASK))
+               if (pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(32)))
                        printk("%s: warning, pci_set_dma_mask failed.\n",
                               ha->board_name);
        }
@@ -1510,7 +1510,7 @@ static int option_setup(char *str)
        char *cur = str;
        int i = 1;
 
-       while (cur && isdigit(*cur) && i <= MAX_INT_PARAM) {
+       while (cur && isdigit(*cur) && i < MAX_INT_PARAM) {
                ints[i++] = simple_strtoul(cur, NULL, 0);
 
                if ((cur = strchr(cur, ',')) != NULL)
@@ -1627,8 +1627,15 @@ static void map_dma(unsigned int i, struct hostdata *ha)
 
        cpp->sense_len = SCSI_SENSE_BUFFERSIZE;
 
-       count = scsi_dma_map(SCpnt);
-       BUG_ON(count < 0);
+       if (!scsi_sg_count(SCpnt)) {
+               cpp->data_len = 0;
+               return;
+       }
+
+       count = pci_map_sg(ha->pdev, scsi_sglist(SCpnt), scsi_sg_count(SCpnt),
+                          pci_dir);
+       BUG_ON(!count);
+
        scsi_for_each_sg(SCpnt, sg, count, k) {
                cpp->sglist[k].address = H2DEV(sg_dma_address(sg));
                cpp->sglist[k].num_bytes = H2DEV(sg_dma_len(sg));
@@ -1656,7 +1663,9 @@ static void unmap_dma(unsigned int i, struct hostdata *ha)
                pci_unmap_single(ha->pdev, DEV2H(cpp->sense_addr),
                                 DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE);
 
-       scsi_dma_unmap(SCpnt);
+       if (scsi_sg_count(SCpnt))
+               pci_unmap_sg(ha->pdev, scsi_sglist(SCpnt), scsi_sg_count(SCpnt),
+                            pci_dir);
 
        if (!DEV2H(cpp->data_len))
                pci_dir = PCI_DMA_BIDIRECTIONAL;
@@ -1817,7 +1826,7 @@ static int eata2x_queuecommand(struct scsi_cmnd *SCpnt,
        if (linked_comm && SCpnt->device->queue_depth > 2
            && TLDEV(SCpnt->device->type)) {
                ha->cp_stat[i] = READY;
-               flush_dev(SCpnt->device, SCpnt->request->sector, ha, 0);
+               flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), ha, 0);
                return 0;
        }
 
@@ -2136,13 +2145,13 @@ static int reorder(struct hostdata *ha, unsigned long cursec,
                if (!cpp->din)
                        input_only = 0;
 
-               if (SCpnt->request->sector < minsec)
-                       minsec = SCpnt->request->sector;
-               if (SCpnt->request->sector > maxsec)
-                       maxsec = SCpnt->request->sector;
+               if (blk_rq_pos(SCpnt->request) < minsec)
+                       minsec = blk_rq_pos(SCpnt->request);
+               if (blk_rq_pos(SCpnt->request) > maxsec)
+                       maxsec = blk_rq_pos(SCpnt->request);
 
-               sl[n] = SCpnt->request->sector;
-               ioseek += SCpnt->request->nr_sectors;
+               sl[n] = blk_rq_pos(SCpnt->request);
+               ioseek += blk_rq_sectors(SCpnt->request);
 
                if (!n)
                        continue;
@@ -2182,7 +2191,7 @@ static int reorder(struct hostdata *ha, unsigned long cursec,
                        k = il[n];
                        cpp = &ha->cp[k];
                        SCpnt = cpp->SCpnt;
-                       ll[n] = SCpnt->request->nr_sectors;
+                       ll[n] = blk_rq_sectors(SCpnt->request);
                        pl[n] = SCpnt->serial_number;
 
                        if (!n)
@@ -2228,12 +2237,12 @@ static int reorder(struct hostdata *ha, unsigned long cursec,
                        cpp = &ha->cp[k];
                        SCpnt = cpp->SCpnt;
                        scmd_printk(KERN_INFO, SCpnt,
-                           "%s pid %ld mb %d fc %d nr %d sec %ld ns %ld"
+                           "%s pid %ld mb %d fc %d nr %d sec %ld ns %u"
                             " cur %ld s:%c r:%c rev:%c in:%c ov:%c xd %d.\n",
                             (ihdlr ? "ihdlr" : "qcomm"),
                             SCpnt->serial_number, k, flushcount,
-                            n_ready, SCpnt->request->sector,
-                            SCpnt->request->nr_sectors, cursec, YESNO(s),
+                            n_ready, blk_rq_pos(SCpnt->request),
+                            blk_rq_sectors(SCpnt->request), cursec, YESNO(s),
                             YESNO(r), YESNO(rev), YESNO(input_only),
                             YESNO(overlap), cpp->din);
                }
@@ -2287,17 +2296,14 @@ static void flush_dev(struct scsi_device *dev, unsigned long cursec,
        }
 }
 
-static irqreturn_t ihdlr(int irq, struct Scsi_Host *shost)
+static irqreturn_t ihdlr(struct Scsi_Host *shost)
 {
        struct scsi_cmnd *SCpnt;
        unsigned int i, k, c, status, tstatus, reg;
        struct mssp *spp;
        struct mscp *cpp;
        struct hostdata *ha = (struct hostdata *)shost->hostdata;
-
-       if (shost->irq != irq)
-               panic("%s: ihdlr, irq %d, shost->irq %d.\n", ha->board_name, irq,
-                     shost->irq);
+       int irq = shost->irq;
 
        /* Check if this board need to be serviced */
        if (!(inb(shost->io_port + REG_AUX_STATUS) & IRQ_ASSERTED))
@@ -2403,7 +2409,7 @@ static irqreturn_t ihdlr(int irq, struct Scsi_Host *shost)
 
        if (linked_comm && SCpnt->device->queue_depth > 2
            && TLDEV(SCpnt->device->type))
-               flush_dev(SCpnt->device, SCpnt->request->sector, ha, 1);
+               flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), ha, 1);
 
        tstatus = status_byte(spp->target_status);
 
@@ -2536,7 +2542,7 @@ static irqreturn_t ihdlr(int irq, struct Scsi_Host *shost)
        return IRQ_NONE;
 }
 
-static irqreturn_t do_interrupt_handler(int irq, void *shap)
+static irqreturn_t do_interrupt_handler(int dummy, void *shap)
 {
        struct Scsi_Host *shost;
        unsigned int j;
@@ -2549,7 +2555,7 @@ static irqreturn_t do_interrupt_handler(int irq, void *shap)
        shost = sh[j];
 
        spin_lock_irqsave(shost->host_lock, spin_flags);
-       ret = ihdlr(irq, shost);
+       ret = ihdlr(shost);
        spin_unlock_irqrestore(shost->host_lock, spin_flags);
        return ret;
 }