]> err.no Git - linux-2.6/commitdiff
[SCSI] 53c700: convert to use the data buffer accessors
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Mon, 14 May 2007 10:12:55 +0000 (19:12 +0900)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Sat, 26 May 2007 21:30:04 +0000 (16:30 -0500)
- remove the unnecessary map_single path.

- convert to use the new accessors for the sg lists and the
parameters.

Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/53c700.c

index cb02656eb54c1e9592fd552f1014a556981ca8e0..405d9d6f965342410a7fecc19dcb7dc67fed6049 100644 (file)
@@ -585,16 +585,8 @@ NCR_700_unmap(struct NCR_700_Host_Parameters *hostdata, struct scsi_cmnd *SCp,
              struct NCR_700_command_slot *slot)
 {
        if(SCp->sc_data_direction != DMA_NONE &&
-          SCp->sc_data_direction != DMA_BIDIRECTIONAL) {
-               if(SCp->use_sg) {
-                       dma_unmap_sg(hostdata->dev, SCp->request_buffer,
-                                    SCp->use_sg, SCp->sc_data_direction);
-               } else {
-                       dma_unmap_single(hostdata->dev, slot->dma_handle,
-                                        SCp->request_bufflen,
-                                        SCp->sc_data_direction);
-               }
-       }
+          SCp->sc_data_direction != DMA_BIDIRECTIONAL)
+               scsi_dma_unmap(SCp);
 }
 
 STATIC inline void
@@ -1263,14 +1255,13 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
                       host->host_no, pun, lun, NCR_700_condition[i],
                       NCR_700_phase[j], dsp - hostdata->pScript);
                if(SCp != NULL) {
-                       scsi_print_command(SCp);
+                       struct scatterlist *sg;
 
-                       if(SCp->use_sg) {
-                               for(i = 0; i < SCp->use_sg + 1; i++) {
-                                       printk(KERN_INFO " SG[%d].length = %d, move_insn=%08x, addr %08x\n", i, ((struct scatterlist *)SCp->request_buffer)[i].length, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].ins, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].pAddr);
-                               }
+                       scsi_print_command(SCp);
+                       scsi_for_each_sg(SCp, sg, scsi_sg_count(SCp) + 1, i) {
+                               printk(KERN_INFO " SG[%d].length = %d, move_insn=%08x, addr %08x\n", i, sg->length, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].ins, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].pAddr);
                        }
-               }              
+               }
                NCR_700_internal_bus_reset(host);
        } else if((dsps & 0xfffff000) == A_DEBUG_INTERRUPT) {
                printk(KERN_NOTICE "scsi%d (%d:%d) DEBUG INTERRUPT %d AT %08x[%04x], continuing\n",
@@ -1844,8 +1835,8 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
        }
        /* sanity check: some of the commands generated by the mid-layer
         * have an eccentric idea of their sc_data_direction */
-       if(!SCp->use_sg && !SCp->request_bufflen 
-          && SCp->sc_data_direction != DMA_NONE) {
+       if(!scsi_sg_count(SCp) && !scsi_bufflen(SCp) &&
+          SCp->sc_data_direction != DMA_NONE) {
 #ifdef NCR_700_DEBUG
                printk("53c700: Command");
                scsi_print_command(SCp);
@@ -1887,31 +1878,15 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
                int i;
                int sg_count;
                dma_addr_t vPtr = 0;
+               struct scatterlist *sg;
                __u32 count = 0;
 
-               if(SCp->use_sg) {
-                       sg_count = dma_map_sg(hostdata->dev,
-                                             SCp->request_buffer, SCp->use_sg,
-                                             direction);
-               } else {
-                       vPtr = dma_map_single(hostdata->dev,
-                                             SCp->request_buffer, 
-                                             SCp->request_bufflen,
-                                             direction);
-                       count = SCp->request_bufflen;
-                       slot->dma_handle = vPtr;
-                       sg_count = 1;
-               }
-                       
+               sg_count = scsi_dma_map(SCp);
+               BUG_ON(sg_count < 0);
 
-               for(i = 0; i < sg_count; i++) {
-
-                       if(SCp->use_sg) {
-                               struct scatterlist *sg = SCp->request_buffer;
-
-                               vPtr = sg_dma_address(&sg[i]);
-                               count = sg_dma_len(&sg[i]);
-                       }
+               scsi_for_each_sg(SCp, sg, sg_count, i) {
+                       vPtr = sg_dma_address(sg);
+                       count = sg_dma_len(sg);
 
                        slot->SG[i].ins = bS_to_host(move_ins | count);
                        DEBUG((" scatter block %d: move %d[%08x] from 0x%lx\n",