aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-09-06 17:50:20 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-11 19:22:38 -0500
commitc73961e563dde3239e2e5da08b25ab2832b2e840 (patch)
tree9785cf3ed4419bc75f0a6395834c3400d9fbb64a /drivers/scsi
parent48c23d3e377bb090bf49ea6c45d024b4c11439b0 (diff)
[SCSI] scsi_debug: convert to use the data buffer accessors
- remove the unnecessary map_single path. - convert to use the new accessors for the sg lists and the parameters. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Acked-by: Douglas Gilbert <dougg@torque.net> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/scsi_debug.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 46cae5a212de..82c06f0a9d02 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -329,7 +329,7 @@ int scsi_debug_queuecommand(struct scsi_cmnd * SCpnt, done_funct_t done)
329 if (done == NULL) 329 if (done == NULL)
330 return 0; /* assume mid level reprocessing command */ 330 return 0; /* assume mid level reprocessing command */
331 331
332 SCpnt->resid = 0; 332 scsi_set_resid(SCpnt, 0);
333 if ((SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) && cmd) { 333 if ((SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) && cmd) {
334 printk(KERN_INFO "scsi_debug: cmd "); 334 printk(KERN_INFO "scsi_debug: cmd ");
335 for (k = 0, len = SCpnt->cmd_len; k < len; ++k) 335 for (k = 0, len = SCpnt->cmd_len; k < len; ++k)
@@ -603,26 +603,16 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
603 void * kaddr_off; 603 void * kaddr_off;
604 struct scatterlist * sg; 604 struct scatterlist * sg;
605 605
606 if (0 == scp->request_bufflen) 606 if (0 == scsi_bufflen(scp))
607 return 0; 607 return 0;
608 if (NULL == scp->request_buffer) 608 if (NULL == scsi_sglist(scp))
609 return (DID_ERROR << 16); 609 return (DID_ERROR << 16);
610 if (! ((scp->sc_data_direction == DMA_BIDIRECTIONAL) || 610 if (! ((scp->sc_data_direction == DMA_BIDIRECTIONAL) ||
611 (scp->sc_data_direction == DMA_FROM_DEVICE))) 611 (scp->sc_data_direction == DMA_FROM_DEVICE)))
612 return (DID_ERROR << 16); 612 return (DID_ERROR << 16);
613 if (0 == scp->use_sg) {
614 req_len = scp->request_bufflen;
615 act_len = (req_len < arr_len) ? req_len : arr_len;
616 memcpy(scp->request_buffer, arr, act_len);
617 if (scp->resid)
618 scp->resid -= act_len;
619 else
620 scp->resid = req_len - act_len;
621 return 0;
622 }
623 active = 1; 613 active = 1;
624 req_len = act_len = 0; 614 req_len = act_len = 0;
625 scsi_for_each_sg(scp, sg, scp->use_sg, k) { 615 scsi_for_each_sg(scp, sg, scsi_sg_count(scp), k) {
626 if (active) { 616 if (active) {
627 kaddr = (unsigned char *) 617 kaddr = (unsigned char *)
628 kmap_atomic(sg_page(sg), KM_USER0); 618 kmap_atomic(sg_page(sg), KM_USER0);
@@ -640,10 +630,10 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
640 } 630 }
641 req_len += sg->length; 631 req_len += sg->length;
642 } 632 }
643 if (scp->resid) 633 if (scsi_get_resid(scp))
644 scp->resid -= act_len; 634 scsi_set_resid(scp, scsi_get_resid(scp) - act_len);
645 else 635 else
646 scp->resid = req_len - act_len; 636 scsi_set_resid(scp, req_len - act_len);
647 return 0; 637 return 0;
648} 638}
649 639
@@ -656,22 +646,15 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
656 void * kaddr_off; 646 void * kaddr_off;
657 struct scatterlist * sg; 647 struct scatterlist * sg;
658 648
659 if (0 == scp->request_bufflen) 649 if (0 == scsi_bufflen(scp))
660 return 0; 650 return 0;
661 if (NULL == scp->request_buffer) 651 if (NULL == scsi_sglist(scp))
662 return -1; 652 return -1;
663 if (! ((scp->sc_data_direction == DMA_BIDIRECTIONAL) || 653 if (! ((scp->sc_data_direction == DMA_BIDIRECTIONAL) ||
664 (scp->sc_data_direction == DMA_TO_DEVICE))) 654 (scp->sc_data_direction == DMA_TO_DEVICE)))
665 return -1; 655 return -1;
666 if (0 == scp->use_sg) {
667 req_len = scp->request_bufflen;
668 len = (req_len < max_arr_len) ? req_len : max_arr_len;
669 memcpy(arr, scp->request_buffer, len);
670 return len;
671 }
672 sg = scsi_sglist(scp);
673 req_len = fin = 0; 656 req_len = fin = 0;
674 for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) { 657 scsi_for_each_sg(scp, sg, scsi_sg_count(scp), k) {
675 kaddr = (unsigned char *)kmap_atomic(sg_page(sg), KM_USER0); 658 kaddr = (unsigned char *)kmap_atomic(sg_page(sg), KM_USER0);
676 if (NULL == kaddr) 659 if (NULL == kaddr)
677 return -1; 660 return -1;