diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-05-14 07:26:06 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-26 20:12:56 -0400 |
commit | c66cc13c16377d177d8887f15a3cc42ab3866f57 (patch) | |
tree | 8ee8325b502ae9ba33662215d300b42d587450b9 /drivers/scsi/aha1740.c | |
parent | 985c0a7277760512c65bda2eb12c1c7213233eeb (diff) |
[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: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/aha1740.c')
-rw-r--r-- | drivers/scsi/aha1740.c | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c index d7af9c63a04d..e4a4f3a965d9 100644 --- a/drivers/scsi/aha1740.c +++ b/drivers/scsi/aha1740.c | |||
@@ -271,20 +271,8 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id) | |||
271 | continue; | 271 | continue; |
272 | } | 272 | } |
273 | sgptr = (struct aha1740_sg *) SCtmp->host_scribble; | 273 | sgptr = (struct aha1740_sg *) SCtmp->host_scribble; |
274 | if (SCtmp->use_sg) { | 274 | scsi_dma_unmap(SCtmp); |
275 | /* We used scatter-gather. | 275 | |
276 | Do the unmapping dance. */ | ||
277 | dma_unmap_sg (&edev->dev, | ||
278 | (struct scatterlist *) SCtmp->request_buffer, | ||
279 | SCtmp->use_sg, | ||
280 | SCtmp->sc_data_direction); | ||
281 | } else { | ||
282 | dma_unmap_single (&edev->dev, | ||
283 | sgptr->buf_dma_addr, | ||
284 | SCtmp->request_bufflen, | ||
285 | DMA_BIDIRECTIONAL); | ||
286 | } | ||
287 | |||
288 | /* Free the sg block */ | 276 | /* Free the sg block */ |
289 | dma_free_coherent (&edev->dev, | 277 | dma_free_coherent (&edev->dev, |
290 | sizeof (struct aha1740_sg), | 278 | sizeof (struct aha1740_sg), |
@@ -349,11 +337,9 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) | |||
349 | unchar target = scmd_id(SCpnt); | 337 | unchar target = scmd_id(SCpnt); |
350 | struct aha1740_hostdata *host = HOSTDATA(SCpnt->device->host); | 338 | struct aha1740_hostdata *host = HOSTDATA(SCpnt->device->host); |
351 | unsigned long flags; | 339 | unsigned long flags; |
352 | void *buff = SCpnt->request_buffer; | ||
353 | int bufflen = SCpnt->request_bufflen; | ||
354 | dma_addr_t sg_dma; | 340 | dma_addr_t sg_dma; |
355 | struct aha1740_sg *sgptr; | 341 | struct aha1740_sg *sgptr; |
356 | int ecbno; | 342 | int ecbno, nseg; |
357 | DEB(int i); | 343 | DEB(int i); |
358 | 344 | ||
359 | if(*cmd == REQUEST_SENSE) { | 345 | if(*cmd == REQUEST_SENSE) { |
@@ -423,24 +409,23 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) | |||
423 | } | 409 | } |
424 | sgptr = (struct aha1740_sg *) SCpnt->host_scribble; | 410 | sgptr = (struct aha1740_sg *) SCpnt->host_scribble; |
425 | sgptr->sg_dma_addr = sg_dma; | 411 | sgptr->sg_dma_addr = sg_dma; |
426 | 412 | ||
427 | if (SCpnt->use_sg) { | 413 | nseg = scsi_dma_map(SCpnt); |
428 | struct scatterlist * sgpnt; | 414 | BUG_ON(nseg < 0); |
415 | if (nseg) { | ||
416 | struct scatterlist *sg; | ||
429 | struct aha1740_chain * cptr; | 417 | struct aha1740_chain * cptr; |
430 | int i, count; | 418 | int i; |
431 | DEB(unsigned char * ptr); | 419 | DEB(unsigned char * ptr); |
432 | 420 | ||
433 | host->ecb[ecbno].sg = 1; /* SCSI Initiator Command | 421 | host->ecb[ecbno].sg = 1; /* SCSI Initiator Command |
434 | * w/scatter-gather*/ | 422 | * w/scatter-gather*/ |
435 | sgpnt = (struct scatterlist *) SCpnt->request_buffer; | ||
436 | cptr = sgptr->sg_chain; | 423 | cptr = sgptr->sg_chain; |
437 | count = dma_map_sg (&host->edev->dev, sgpnt, SCpnt->use_sg, | 424 | scsi_for_each_sg(SCpnt, sg, nseg, i) { |
438 | SCpnt->sc_data_direction); | 425 | cptr[i].datalen = sg_dma_len (sg); |
439 | for(i=0; i < count; i++) { | 426 | cptr[i].dataptr = sg_dma_address (sg); |
440 | cptr[i].datalen = sg_dma_len (sgpnt + i); | ||
441 | cptr[i].dataptr = sg_dma_address (sgpnt + i); | ||
442 | } | 427 | } |
443 | host->ecb[ecbno].datalen = count*sizeof(struct aha1740_chain); | 428 | host->ecb[ecbno].datalen = nseg * sizeof(struct aha1740_chain); |
444 | host->ecb[ecbno].dataptr = sg_dma; | 429 | host->ecb[ecbno].dataptr = sg_dma; |
445 | #ifdef DEBUG | 430 | #ifdef DEBUG |
446 | printk("cptr %x: ",cptr); | 431 | printk("cptr %x: ",cptr); |
@@ -448,11 +433,8 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) | |||
448 | for(i=0;i<24;i++) printk("%02x ", ptr[i]); | 433 | for(i=0;i<24;i++) printk("%02x ", ptr[i]); |
449 | #endif | 434 | #endif |
450 | } else { | 435 | } else { |
451 | host->ecb[ecbno].datalen = bufflen; | 436 | host->ecb[ecbno].datalen = 0; |
452 | sgptr->buf_dma_addr = dma_map_single (&host->edev->dev, | 437 | host->ecb[ecbno].dataptr = 0; |
453 | buff, bufflen, | ||
454 | DMA_BIDIRECTIONAL); | ||
455 | host->ecb[ecbno].dataptr = sgptr->buf_dma_addr; | ||
456 | } | 438 | } |
457 | host->ecb[ecbno].lun = SCpnt->device->lun; | 439 | host->ecb[ecbno].lun = SCpnt->device->lun; |
458 | host->ecb[ecbno].ses = 1; /* Suppress underrun errors */ | 440 | host->ecb[ecbno].ses = 1; /* Suppress underrun errors */ |