[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>
This commit is contained in:
parent
70c8d89776
commit
85289f2efa
|
@ -457,28 +457,21 @@ static int dc390_pci_map (struct dc390_srb* pSRB)
|
||||||
error = 1;
|
error = 1;
|
||||||
DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __FUNCTION__, pcmd->sense_buffer, cmdp->saved_dma_handle));
|
DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __FUNCTION__, pcmd->sense_buffer, cmdp->saved_dma_handle));
|
||||||
/* Map SG list */
|
/* Map SG list */
|
||||||
} else if (pcmd->use_sg) {
|
} else if (scsi_sg_count(pcmd)) {
|
||||||
pSRB->pSegmentList = (struct scatterlist *) pcmd->request_buffer;
|
int nseg;
|
||||||
pSRB->SGcount = pci_map_sg(pdev, pSRB->pSegmentList, pcmd->use_sg,
|
|
||||||
pcmd->sc_data_direction);
|
nseg = scsi_dma_map(pcmd);
|
||||||
/* TODO: error handling */
|
|
||||||
if (!pSRB->SGcount)
|
pSRB->pSegmentList = scsi_sglist(pcmd);
|
||||||
error = 1;
|
pSRB->SGcount = nseg;
|
||||||
DEBUG1(printk("%s(): Mapped SG %p with %d (%d) elements\n",\
|
|
||||||
__FUNCTION__, pcmd->request_buffer, pSRB->SGcount, pcmd->use_sg));
|
|
||||||
/* Map single segment */
|
|
||||||
} else if (pcmd->request_buffer && pcmd->request_bufflen) {
|
|
||||||
pSRB->pSegmentList = dc390_sg_build_single(&pSRB->Segmentx, pcmd->request_buffer, pcmd->request_bufflen);
|
|
||||||
pSRB->SGcount = pci_map_sg(pdev, pSRB->pSegmentList, 1,
|
|
||||||
pcmd->sc_data_direction);
|
|
||||||
cmdp->saved_dma_handle = sg_dma_address(pSRB->pSegmentList);
|
|
||||||
|
|
||||||
/* TODO: error handling */
|
/* TODO: error handling */
|
||||||
if (pSRB->SGcount != 1)
|
if (nseg < 0)
|
||||||
error = 1;
|
error = 1;
|
||||||
DEBUG1(printk("%s(): Mapped request buffer %p at %x\n", __FUNCTION__, pcmd->request_buffer, cmdp->saved_dma_handle));
|
DEBUG1(printk("%s(): Mapped SG %p with %d (%d) elements\n",\
|
||||||
/* No mapping !? */
|
__FUNCTION__, scsi_sglist(pcmd), nseg, scsi_sg_count(pcmd)));
|
||||||
} else
|
/* Map single segment */
|
||||||
|
} else
|
||||||
pSRB->SGcount = 0;
|
pSRB->SGcount = 0;
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
@ -494,12 +487,10 @@ static void dc390_pci_unmap (struct dc390_srb* pSRB)
|
||||||
if (pSRB->SRBFlag) {
|
if (pSRB->SRBFlag) {
|
||||||
pci_unmap_sg(pdev, &pSRB->Segmentx, 1, DMA_FROM_DEVICE);
|
pci_unmap_sg(pdev, &pSRB->Segmentx, 1, DMA_FROM_DEVICE);
|
||||||
DEBUG1(printk("%s(): Unmapped sense buffer at %x\n", __FUNCTION__, cmdp->saved_dma_handle));
|
DEBUG1(printk("%s(): Unmapped sense buffer at %x\n", __FUNCTION__, cmdp->saved_dma_handle));
|
||||||
} else if (pcmd->use_sg) {
|
} else {
|
||||||
pci_unmap_sg(pdev, pcmd->request_buffer, pcmd->use_sg, pcmd->sc_data_direction);
|
scsi_dma_unmap(pcmd);
|
||||||
DEBUG1(printk("%s(): Unmapped SG at %p with %d elements\n", __FUNCTION__, pcmd->request_buffer, pcmd->use_sg));
|
DEBUG1(printk("%s(): Unmapped SG at %p with %d elements\n",
|
||||||
} else if (pcmd->request_buffer && pcmd->request_bufflen) {
|
__FUNCTION__, scsi_sglist(pcmd), scsi_sg_count(pcmd)));
|
||||||
pci_unmap_sg(pdev, &pSRB->Segmentx, 1, pcmd->sc_data_direction);
|
|
||||||
DEBUG1(printk("%s(): Unmapped request buffer at %x\n", __FUNCTION__, cmdp->saved_dma_handle));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,9 +1144,9 @@ dc390_restore_ptr (struct dc390_acb* pACB, struct dc390_srb* pSRB)
|
||||||
struct scatterlist *psgl;
|
struct scatterlist *psgl;
|
||||||
pSRB->TotalXferredLen = 0;
|
pSRB->TotalXferredLen = 0;
|
||||||
pSRB->SGIndex = 0;
|
pSRB->SGIndex = 0;
|
||||||
if (pcmd->use_sg) {
|
if (scsi_sg_count(pcmd)) {
|
||||||
size_t saved;
|
size_t saved;
|
||||||
pSRB->pSegmentList = (struct scatterlist *)pcmd->request_buffer;
|
pSRB->pSegmentList = scsi_sglist(pcmd);
|
||||||
psgl = pSRB->pSegmentList;
|
psgl = pSRB->pSegmentList;
|
||||||
//dc390_pci_sync(pSRB);
|
//dc390_pci_sync(pSRB);
|
||||||
|
|
||||||
|
@ -1179,12 +1170,6 @@ dc390_restore_ptr (struct dc390_acb* pACB, struct dc390_srb* pSRB)
|
||||||
printk (KERN_INFO "DC390: Pointer restored. Segment %i, Total %li, Bus %08lx\n",
|
printk (KERN_INFO "DC390: Pointer restored. Segment %i, Total %li, Bus %08lx\n",
|
||||||
pSRB->SGIndex, pSRB->Saved_Ptr, pSRB->SGBusAddr);
|
pSRB->SGIndex, pSRB->Saved_Ptr, pSRB->SGBusAddr);
|
||||||
|
|
||||||
} else if(pcmd->request_buffer) {
|
|
||||||
//dc390_pci_sync(pSRB);
|
|
||||||
|
|
||||||
sg_dma_len(&pSRB->Segmentx) = pcmd->request_bufflen - pSRB->Saved_Ptr;
|
|
||||||
pSRB->SGcount = 1;
|
|
||||||
pSRB->pSegmentList = (struct scatterlist *) &pSRB->Segmentx;
|
|
||||||
} else {
|
} else {
|
||||||
pSRB->SGcount = 0;
|
pSRB->SGcount = 0;
|
||||||
printk (KERN_INFO "DC390: RESTORE_PTR message for Transfer without Scatter-Gather ??\n");
|
printk (KERN_INFO "DC390: RESTORE_PTR message for Transfer without Scatter-Gather ??\n");
|
||||||
|
@ -1612,7 +1597,7 @@ dc390_Reselect( struct dc390_acb* pACB )
|
||||||
if( !( pACB->scan_devices ) )
|
if( !( pACB->scan_devices ) )
|
||||||
{
|
{
|
||||||
struct scsi_cmnd *pcmd = pSRB->pcmd;
|
struct scsi_cmnd *pcmd = pSRB->pcmd;
|
||||||
pcmd->resid = pcmd->request_bufflen;
|
scsi_set_resid(pcmd, scsi_bufflen(pcmd));
|
||||||
SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
|
SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
|
||||||
dc390_Going_remove(pDCB, pSRB);
|
dc390_Going_remove(pDCB, pSRB);
|
||||||
dc390_Free_insert(pACB, pSRB);
|
dc390_Free_insert(pACB, pSRB);
|
||||||
|
@ -1695,7 +1680,7 @@ dc390_RequestSense(struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_
|
||||||
pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN));
|
pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN));
|
||||||
|
|
||||||
pSRB->SRBFlag |= AUTO_REQSENSE;
|
pSRB->SRBFlag |= AUTO_REQSENSE;
|
||||||
pSRB->SavedSGCount = pcmd->use_sg;
|
pSRB->SavedSGCount = scsi_sg_count(pcmd);
|
||||||
pSRB->SavedTotXLen = pSRB->TotalXferredLen;
|
pSRB->SavedTotXLen = pSRB->TotalXferredLen;
|
||||||
pSRB->AdaptStatus = 0;
|
pSRB->AdaptStatus = 0;
|
||||||
pSRB->TargetStatus = 0; /* CHECK_CONDITION<<1; */
|
pSRB->TargetStatus = 0; /* CHECK_CONDITION<<1; */
|
||||||
|
@ -1743,7 +1728,7 @@ dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb*
|
||||||
(u32) pcmd->result, (u32) pSRB->TotalXferredLen));
|
(u32) pcmd->result, (u32) pSRB->TotalXferredLen));
|
||||||
} else {
|
} else {
|
||||||
SET_RES_DRV(pcmd->result, DRIVER_SENSE);
|
SET_RES_DRV(pcmd->result, DRIVER_SENSE);
|
||||||
pcmd->use_sg = pSRB->SavedSGCount;
|
scsi_sg_count(pcmd) = pSRB->SavedSGCount;
|
||||||
//pSRB->ScsiCmdLen = (u8) (pSRB->Segment1[0] >> 8);
|
//pSRB->ScsiCmdLen = (u8) (pSRB->Segment1[0] >> 8);
|
||||||
DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
|
DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
|
||||||
pSRB->TotalXferredLen = 0;
|
pSRB->TotalXferredLen = 0;
|
||||||
|
@ -1765,7 +1750,7 @@ dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb*
|
||||||
else if( status_byte(status) == QUEUE_FULL )
|
else if( status_byte(status) == QUEUE_FULL )
|
||||||
{
|
{
|
||||||
scsi_track_queue_full(pcmd->device, pDCB->GoingSRBCnt - 1);
|
scsi_track_queue_full(pcmd->device, pDCB->GoingSRBCnt - 1);
|
||||||
pcmd->use_sg = pSRB->SavedSGCount;
|
scsi_sg_count(pcmd) = pSRB->SavedSGCount;
|
||||||
DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
|
DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
|
||||||
pSRB->TotalXferredLen = 0;
|
pSRB->TotalXferredLen = 0;
|
||||||
SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
|
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*
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_done:
|
cmd_done:
|
||||||
pcmd->resid = pcmd->request_bufflen - pSRB->TotalXferredLen;
|
scsi_set_resid(pcmd, scsi_bufflen(pcmd) - pSRB->TotalXferredLen);
|
||||||
|
|
||||||
dc390_Going_remove (pDCB, pSRB);
|
dc390_Going_remove (pDCB, pSRB);
|
||||||
/* Add to free list */
|
/* Add to free list */
|
||||||
|
|
Loading…
Reference in New Issue