]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/scsi/sym53c416.c
[SG] Update drivers to use sg helpers
[mirror_ubuntu-artful-kernel.git] / drivers / scsi / sym53c416.c
index 32c883f1efa1aecbd5f525af8354f552bf5d1e6c..90cee94d9522df03d493a833ed7297c368bc9126 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
-#include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/proc_fs.h>
@@ -197,7 +196,7 @@ static unsigned int sym53c416_base_3[2] = {0,0};
 
 #define MAXHOSTS 4
 
-#define SG_ADDRESS(buffer)     ((char *) (page_address((buffer)->page)+(buffer)->offset))
+#define SG_ADDRESS(buffer)     ((char *) sg_virt((buffer)))
 
 enum phases
 {
@@ -333,8 +332,7 @@ static irqreturn_t sym53c416_intr_handle(int irq, void *dev_id)
        int i;
        unsigned long flags = 0;
        unsigned char status_reg, pio_int_reg, int_reg;
-       struct scatterlist *sglist;
-       unsigned int sgcount;
+       struct scatterlist *sg;
        unsigned int tot_trans = 0;
 
        /* We search the base address of the host adapter which caused the interrupt */
@@ -430,19 +428,15 @@ static irqreturn_t sym53c416_intr_handle(int irq, void *dev_id)
                        {
                                current_command->SCp.phase = data_out;
                                outb(FLUSH_FIFO, base + COMMAND_REG);
-                               sym53c416_set_transfer_counter(base, current_command->request_bufflen);
+                               sym53c416_set_transfer_counter(base,
+                                                              scsi_bufflen(current_command));
                                outb(TRANSFER_INFORMATION | PIO_MODE, base + COMMAND_REG);
-                               if(!current_command->use_sg)
-                                       tot_trans = sym53c416_write(base, current_command->request_buffer, current_command->request_bufflen);
-                               else
-                               {
-                                       sgcount = current_command->use_sg;
-                                       sglist = current_command->request_buffer;
-                                       while(sgcount--)
-                                       {
-                                               tot_trans += sym53c416_write(base, SG_ADDRESS(sglist), sglist->length);
-                                               sglist++;
-                                       }
+
+                               scsi_for_each_sg(current_command,
+                                                sg, scsi_sg_count(current_command), i) {
+                                       tot_trans += sym53c416_write(base,
+                                                                    SG_ADDRESS(sg),
+                                                                    sg->length);
                                }
                                if(tot_trans < current_command->underflow)
                                        printk(KERN_WARNING "sym53c416: Underflow, wrote %d bytes, request for %d bytes.\n", tot_trans, current_command->underflow);
@@ -456,19 +450,16 @@ static irqreturn_t sym53c416_intr_handle(int irq, void *dev_id)
                        {
                                current_command->SCp.phase = data_in;
                                outb(FLUSH_FIFO, base + COMMAND_REG);
-                               sym53c416_set_transfer_counter(base, current_command->request_bufflen);
+                               sym53c416_set_transfer_counter(base,
+                                                              scsi_bufflen(current_command));
+
                                outb(TRANSFER_INFORMATION | PIO_MODE, base + COMMAND_REG);
-                               if(!current_command->use_sg)
-                                       tot_trans = sym53c416_read(base, current_command->request_buffer, current_command->request_bufflen);
-                               else
-                               {
-                                       sgcount = current_command->use_sg;
-                                       sglist = current_command->request_buffer;
-                                       while(sgcount--)
-                                       {
-                                               tot_trans += sym53c416_read(base, SG_ADDRESS(sglist), sglist->length);
-                                               sglist++;
-                                       }
+
+                               scsi_for_each_sg(current_command,
+                                                sg, scsi_sg_count(current_command), i) {
+                                       tot_trans += sym53c416_read(base,
+                                                                   SG_ADDRESS(sg),
+                                                                   sg->length);
                                }
                                if(tot_trans < current_command->underflow)
                                        printk(KERN_WARNING "sym53c416: Underflow, read %d bytes, request for %d bytes.\n", tot_trans, current_command->underflow);
@@ -863,5 +854,6 @@ static struct scsi_host_template driver_template = {
        .cmd_per_lun =          1,
        .unchecked_isa_dma =    1,
        .use_clustering =       ENABLE_CLUSTERING,
+       .use_sg_chaining =      ENABLE_SG_CHAINING,
 };
 #include "scsi_module.c"