Commit c66cc13c authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by James Bottomley

[SCSI] aha1740: 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.

Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup.
Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 985c0a72
...@@ -271,19 +271,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id) ...@@ -271,19 +271,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id)
continue; continue;
} }
sgptr = (struct aha1740_sg *) SCtmp->host_scribble; sgptr = (struct aha1740_sg *) SCtmp->host_scribble;
if (SCtmp->use_sg) { scsi_dma_unmap(SCtmp);
/* We used scatter-gather.
Do the unmapping dance. */
dma_unmap_sg (&edev->dev,
(struct scatterlist *) SCtmp->request_buffer,
SCtmp->use_sg,
SCtmp->sc_data_direction);
} else {
dma_unmap_single (&edev->dev,
sgptr->buf_dma_addr,
SCtmp->request_bufflen,
DMA_BIDIRECTIONAL);
}
/* Free the sg block */ /* Free the sg block */
dma_free_coherent (&edev->dev, dma_free_coherent (&edev->dev,
...@@ -349,11 +337,9 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) ...@@ -349,11 +337,9 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
unchar target = scmd_id(SCpnt); unchar target = scmd_id(SCpnt);
struct aha1740_hostdata *host = HOSTDATA(SCpnt->device->host); struct aha1740_hostdata *host = HOSTDATA(SCpnt->device->host);
unsigned long flags; unsigned long flags;
void *buff = SCpnt->request_buffer;
int bufflen = SCpnt->request_bufflen;
dma_addr_t sg_dma; dma_addr_t sg_dma;
struct aha1740_sg *sgptr; struct aha1740_sg *sgptr;
int ecbno; int ecbno, nseg;
DEB(int i); DEB(int i);
if(*cmd == REQUEST_SENSE) { if(*cmd == REQUEST_SENSE) {
...@@ -424,23 +410,22 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) ...@@ -424,23 +410,22 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
sgptr = (struct aha1740_sg *) SCpnt->host_scribble; sgptr = (struct aha1740_sg *) SCpnt->host_scribble;
sgptr->sg_dma_addr = sg_dma; sgptr->sg_dma_addr = sg_dma;
if (SCpnt->use_sg) { nseg = scsi_dma_map(SCpnt);
struct scatterlist * sgpnt; BUG_ON(nseg < 0);
if (nseg) {
struct scatterlist *sg;
struct aha1740_chain * cptr; struct aha1740_chain * cptr;
int i, count; int i;
DEB(unsigned char * ptr); DEB(unsigned char * ptr);
host->ecb[ecbno].sg = 1; /* SCSI Initiator Command host->ecb[ecbno].sg = 1; /* SCSI Initiator Command
* w/scatter-gather*/ * w/scatter-gather*/
sgpnt = (struct scatterlist *) SCpnt->request_buffer;
cptr = sgptr->sg_chain; cptr = sgptr->sg_chain;
count = dma_map_sg (&host->edev->dev, sgpnt, SCpnt->use_sg, scsi_for_each_sg(SCpnt, sg, nseg, i) {
SCpnt->sc_data_direction); cptr[i].datalen = sg_dma_len (sg);
for(i=0; i < count; i++) { cptr[i].dataptr = sg_dma_address (sg);
cptr[i].datalen = sg_dma_len (sgpnt + i);
cptr[i].dataptr = sg_dma_address (sgpnt + i);
} }
host->ecb[ecbno].datalen = count*sizeof(struct aha1740_chain); host->ecb[ecbno].datalen = nseg * sizeof(struct aha1740_chain);
host->ecb[ecbno].dataptr = sg_dma; host->ecb[ecbno].dataptr = sg_dma;
#ifdef DEBUG #ifdef DEBUG
printk("cptr %x: ",cptr); printk("cptr %x: ",cptr);
...@@ -448,11 +433,8 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) ...@@ -448,11 +433,8 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
for(i=0;i<24;i++) printk("%02x ", ptr[i]); for(i=0;i<24;i++) printk("%02x ", ptr[i]);
#endif #endif
} else { } else {
host->ecb[ecbno].datalen = bufflen; host->ecb[ecbno].datalen = 0;
sgptr->buf_dma_addr = dma_map_single (&host->edev->dev, host->ecb[ecbno].dataptr = 0;
buff, bufflen,
DMA_BIDIRECTIONAL);
host->ecb[ecbno].dataptr = sgptr->buf_dma_addr;
} }
host->ecb[ecbno].lun = SCpnt->device->lun; host->ecb[ecbno].lun = SCpnt->device->lun;
host->ecb[ecbno].ses = 1; /* Suppress underrun errors */ host->ecb[ecbno].ses = 1; /* Suppress underrun errors */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment