aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/tmscsim.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2007-05-25 13:41:54 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-27 17:11:01 -0400
commit85289f2efa108d1586a86d0c426ffc9d641bbdc2 (patch)
tree7720ceaee4bb332b585256a9d486e99deff2c367 /drivers/scsi/tmscsim.c
parent70c8d897763e19405a160de729e62a0e727150d2 (diff)
[SCSI] tmscsim: 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: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/tmscsim.c')
-rw-r--r--drivers/scsi/tmscsim.c59
1 files changed, 22 insertions, 37 deletions
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index e7b85e832eb5..73c5ca082e65 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -457,28 +457,21 @@ static int dc390_pci_map (struct dc390_srb* pSRB)
457 error = 1; 457 error = 1;
458 DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __FUNCTION__, pcmd->sense_buffer, cmdp->saved_dma_handle)); 458 DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __FUNCTION__, pcmd->sense_buffer, cmdp->saved_dma_handle));
459 /* Map SG list */ 459 /* Map SG list */
460 } else if (pcmd->use_sg) { 460 } else if (scsi_sg_count(pcmd)) {
461 pSRB->pSegmentList = (struct scatterlist *) pcmd->request_buffer; 461 int nseg;
462 pSRB->SGcount = pci_map_sg(pdev, pSRB->pSegmentList, pcmd->use_sg, 462
463 pcmd->sc_data_direction); 463 nseg = scsi_dma_map(pcmd);
464
465 pSRB->pSegmentList = scsi_sglist(pcmd);
466 pSRB->SGcount = nseg;
467
464 /* TODO: error handling */ 468 /* TODO: error handling */
465 if (!pSRB->SGcount) 469 if (nseg < 0)
466 error = 1; 470 error = 1;
467 DEBUG1(printk("%s(): Mapped SG %p with %d (%d) elements\n",\ 471 DEBUG1(printk("%s(): Mapped SG %p with %d (%d) elements\n",\
468 __FUNCTION__, pcmd->request_buffer, pSRB->SGcount, pcmd->use_sg)); 472 __FUNCTION__, scsi_sglist(pcmd), nseg, scsi_sg_count(pcmd)));
469 /* Map single segment */ 473 /* Map single segment */
470 } else if (pcmd->request_buffer && pcmd->request_bufflen) { 474 } else
471 pSRB->pSegmentList = dc390_sg_build_single(&pSRB->Segmentx, pcmd->request_buffer, pcmd->request_bufflen);
472 pSRB->SGcount = pci_map_sg(pdev, pSRB->pSegmentList, 1,
473 pcmd->sc_data_direction);
474 cmdp->saved_dma_handle = sg_dma_address(pSRB->pSegmentList);
475
476 /* TODO: error handling */
477 if (pSRB->SGcount != 1)
478 error = 1;
479 DEBUG1(printk("%s(): Mapped request buffer %p at %x\n", __FUNCTION__, pcmd->request_buffer, cmdp->saved_dma_handle));
480 /* No mapping !? */
481 } else
482 pSRB->SGcount = 0; 475 pSRB->SGcount = 0;
483 476
484 return error; 477 return error;
@@ -494,12 +487,10 @@ static void dc390_pci_unmap (struct dc390_srb* pSRB)
494 if (pSRB->SRBFlag) { 487 if (pSRB->SRBFlag) {
495 pci_unmap_sg(pdev, &pSRB->Segmentx, 1, DMA_FROM_DEVICE); 488 pci_unmap_sg(pdev, &pSRB->Segmentx, 1, DMA_FROM_DEVICE);
496 DEBUG1(printk("%s(): Unmapped sense buffer at %x\n", __FUNCTION__, cmdp->saved_dma_handle)); 489 DEBUG1(printk("%s(): Unmapped sense buffer at %x\n", __FUNCTION__, cmdp->saved_dma_handle));
497 } else if (pcmd->use_sg) { 490 } else {
498 pci_unmap_sg(pdev, pcmd->request_buffer, pcmd->use_sg, pcmd->sc_data_direction); 491 scsi_dma_unmap(pcmd);
499 DEBUG1(printk("%s(): Unmapped SG at %p with %d elements\n", __FUNCTION__, pcmd->request_buffer, pcmd->use_sg)); 492 DEBUG1(printk("%s(): Unmapped SG at %p with %d elements\n",
500 } else if (pcmd->request_buffer && pcmd->request_bufflen) { 493 __FUNCTION__, scsi_sglist(pcmd), scsi_sg_count(pcmd)));
501 pci_unmap_sg(pdev, &pSRB->Segmentx, 1, pcmd->sc_data_direction);
502 DEBUG1(printk("%s(): Unmapped request buffer at %x\n", __FUNCTION__, cmdp->saved_dma_handle));
503 } 494 }
504} 495}
505 496
@@ -1153,9 +1144,9 @@ dc390_restore_ptr (struct dc390_acb* pACB, struct dc390_srb* pSRB)
1153 struct scatterlist *psgl; 1144 struct scatterlist *psgl;
1154 pSRB->TotalXferredLen = 0; 1145 pSRB->TotalXferredLen = 0;
1155 pSRB->SGIndex = 0; 1146 pSRB->SGIndex = 0;
1156 if (pcmd->use_sg) { 1147 if (scsi_sg_count(pcmd)) {
1157 size_t saved; 1148 size_t saved;
1158 pSRB->pSegmentList = (struct scatterlist *)pcmd->request_buffer; 1149 pSRB->pSegmentList = scsi_sglist(pcmd);
1159 psgl = pSRB->pSegmentList; 1150 psgl = pSRB->pSegmentList;
1160 //dc390_pci_sync(pSRB); 1151 //dc390_pci_sync(pSRB);
1161 1152
@@ -1179,12 +1170,6 @@ dc390_restore_ptr (struct dc390_acb* pACB, struct dc390_srb* pSRB)
1179 printk (KERN_INFO "DC390: Pointer restored. Segment %i, Total %li, Bus %08lx\n", 1170 printk (KERN_INFO "DC390: Pointer restored. Segment %i, Total %li, Bus %08lx\n",
1180 pSRB->SGIndex, pSRB->Saved_Ptr, pSRB->SGBusAddr); 1171 pSRB->SGIndex, pSRB->Saved_Ptr, pSRB->SGBusAddr);
1181 1172
1182 } else if(pcmd->request_buffer) {
1183 //dc390_pci_sync(pSRB);
1184
1185 sg_dma_len(&pSRB->Segmentx) = pcmd->request_bufflen - pSRB->Saved_Ptr;
1186 pSRB->SGcount = 1;
1187 pSRB->pSegmentList = (struct scatterlist *) &pSRB->Segmentx;
1188 } else { 1173 } else {
1189 pSRB->SGcount = 0; 1174 pSRB->SGcount = 0;
1190 printk (KERN_INFO "DC390: RESTORE_PTR message for Transfer without Scatter-Gather ??\n"); 1175 printk (KERN_INFO "DC390: RESTORE_PTR message for Transfer without Scatter-Gather ??\n");
@@ -1612,7 +1597,7 @@ dc390_Reselect( struct dc390_acb* pACB )
1612 if( !( pACB->scan_devices ) ) 1597 if( !( pACB->scan_devices ) )
1613 { 1598 {
1614 struct scsi_cmnd *pcmd = pSRB->pcmd; 1599 struct scsi_cmnd *pcmd = pSRB->pcmd;
1615 pcmd->resid = pcmd->request_bufflen; 1600 scsi_set_resid(pcmd, scsi_bufflen(pcmd));
1616 SET_RES_DID(pcmd->result, DID_SOFT_ERROR); 1601 SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
1617 dc390_Going_remove(pDCB, pSRB); 1602 dc390_Going_remove(pDCB, pSRB);
1618 dc390_Free_insert(pACB, pSRB); 1603 dc390_Free_insert(pACB, pSRB);
@@ -1695,7 +1680,7 @@ dc390_RequestSense(struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_
1695 pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN)); 1680 pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN));
1696 1681
1697 pSRB->SRBFlag |= AUTO_REQSENSE; 1682 pSRB->SRBFlag |= AUTO_REQSENSE;
1698 pSRB->SavedSGCount = pcmd->use_sg; 1683 pSRB->SavedSGCount = scsi_sg_count(pcmd);
1699 pSRB->SavedTotXLen = pSRB->TotalXferredLen; 1684 pSRB->SavedTotXLen = pSRB->TotalXferredLen;
1700 pSRB->AdaptStatus = 0; 1685 pSRB->AdaptStatus = 0;
1701 pSRB->TargetStatus = 0; /* CHECK_CONDITION<<1; */ 1686 pSRB->TargetStatus = 0; /* CHECK_CONDITION<<1; */
@@ -1743,7 +1728,7 @@ dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb*
1743 (u32) pcmd->result, (u32) pSRB->TotalXferredLen)); 1728 (u32) pcmd->result, (u32) pSRB->TotalXferredLen));
1744 } else { 1729 } else {
1745 SET_RES_DRV(pcmd->result, DRIVER_SENSE); 1730 SET_RES_DRV(pcmd->result, DRIVER_SENSE);
1746 pcmd->use_sg = pSRB->SavedSGCount; 1731 scsi_sg_count(pcmd) = pSRB->SavedSGCount;
1747 //pSRB->ScsiCmdLen = (u8) (pSRB->Segment1[0] >> 8); 1732 //pSRB->ScsiCmdLen = (u8) (pSRB->Segment1[0] >> 8);
1748 DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun)); 1733 DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
1749 pSRB->TotalXferredLen = 0; 1734 pSRB->TotalXferredLen = 0;
@@ -1765,7 +1750,7 @@ dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb*
1765 else if( status_byte(status) == QUEUE_FULL ) 1750 else if( status_byte(status) == QUEUE_FULL )
1766 { 1751 {
1767 scsi_track_queue_full(pcmd->device, pDCB->GoingSRBCnt - 1); 1752 scsi_track_queue_full(pcmd->device, pDCB->GoingSRBCnt - 1);
1768 pcmd->use_sg = pSRB->SavedSGCount; 1753 scsi_sg_count(pcmd) = pSRB->SavedSGCount;
1769 DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun)); 1754 DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
1770 pSRB->TotalXferredLen = 0; 1755 pSRB->TotalXferredLen = 0;
1771 SET_RES_DID(pcmd->result, DID_SOFT_ERROR); 1756 SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
@@ -1816,7 +1801,7 @@ dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb*
1816 } 1801 }
1817 1802
1818cmd_done: 1803cmd_done:
1819 pcmd->resid = pcmd->request_bufflen - pSRB->TotalXferredLen; 1804 scsi_set_resid(pcmd, scsi_bufflen(pcmd) - pSRB->TotalXferredLen);
1820 1805
1821 dc390_Going_remove (pDCB, pSRB); 1806 dc390_Going_remove (pDCB, pSRB);
1822 /* Add to free list */ 1807 /* Add to free list */