aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2008-01-22 11:32:00 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-30 14:14:24 -0500
commit072d0bb3ce3507ac6e101ca8ce0b94c5777c62ed (patch)
treea14ccd8aa0ec666c1217536791cc0a4828ad2997 /drivers
parent3de9f944797177e405dcab05f12560a497c019bb (diff)
[SCSI] scsi_debug: add bidi data transfer support
This enables fill_from_dev_buffer and fetch_to_dev_buffer to handle bidi commands. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Douglas Gilbert <dougg@torque.net> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_debug.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 31f7378c5c46..d810aa7aee40 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -594,18 +594,18 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
594 int k, req_len, act_len, len, active; 594 int k, req_len, act_len, len, active;
595 void * kaddr; 595 void * kaddr;
596 void * kaddr_off; 596 void * kaddr_off;
597 struct scatterlist * sg; 597 struct scatterlist *sg;
598 struct scsi_data_buffer *sdb = scsi_in(scp);
598 599
599 if (0 == scsi_bufflen(scp)) 600 if (!sdb->length)
600 return 0; 601 return 0;
601 if (NULL == scsi_sglist(scp)) 602 if (!sdb->table.sgl)
602 return (DID_ERROR << 16); 603 return (DID_ERROR << 16);
603 if (! ((scp->sc_data_direction == DMA_BIDIRECTIONAL) || 604 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE))
604 (scp->sc_data_direction == DMA_FROM_DEVICE)))
605 return (DID_ERROR << 16); 605 return (DID_ERROR << 16);
606 active = 1; 606 active = 1;
607 req_len = act_len = 0; 607 req_len = act_len = 0;
608 scsi_for_each_sg(scp, sg, scsi_sg_count(scp), k) { 608 for_each_sg(sdb->table.sgl, sg, sdb->table.nents, k) {
609 if (active) { 609 if (active) {
610 kaddr = (unsigned char *) 610 kaddr = (unsigned char *)
611 kmap_atomic(sg_page(sg), KM_USER0); 611 kmap_atomic(sg_page(sg), KM_USER0);
@@ -623,10 +623,10 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
623 } 623 }
624 req_len += sg->length; 624 req_len += sg->length;
625 } 625 }
626 if (scsi_get_resid(scp)) 626 if (sdb->resid)
627 scsi_set_resid(scp, scsi_get_resid(scp) - act_len); 627 sdb->resid -= act_len;
628 else 628 else
629 scsi_set_resid(scp, req_len - act_len); 629 sdb->resid = req_len - act_len;
630 return 0; 630 return 0;
631} 631}
632 632
@@ -643,8 +643,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
643 return 0; 643 return 0;
644 if (NULL == scsi_sglist(scp)) 644 if (NULL == scsi_sglist(scp))
645 return -1; 645 return -1;
646 if (! ((scp->sc_data_direction == DMA_BIDIRECTIONAL) || 646 if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE))
647 (scp->sc_data_direction == DMA_TO_DEVICE)))
648 return -1; 647 return -1;
649 req_len = fin = 0; 648 req_len = fin = 0;
650 scsi_for_each_sg(scp, sg, scsi_sg_count(scp), k) { 649 scsi_for_each_sg(scp, sg, scsi_sg_count(scp), k) {