aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/sgiioc4.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:46 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:46 -0400
commit2298169418f43ba5e0919762a4bab95a1227872a (patch)
tree67cf3133c7bae747ad957c68a650534105a7d8e7 /drivers/ide/sgiioc4.c
parent130e886708d6e11f3d54e5d27c266578de56f343 (diff)
ide: pass command to ide_map_sg()
* Set IDE_TFLAG_WRITE flag and ->rq also for ATA_CMD_PACKET commands. * Pass command to ->dma_setup method and update all its implementations accordingly. * Pass command instead of request to ide_build_sglist(), *_build_dmatable() and ide_map_sg(). While at it: * Fix scc_dma_setup() documentation + use ATA_DMA_WR define. * Rename sgiioc4_build_dma_table() to sgiioc4_build_dmatable(), change return value type to 'int' and drop unused 'ddir' argument. * Do some minor cleanups in [tx4939]ide_dma_setup(). There should be no functional changes caused by this patch. Acked-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/sgiioc4.c')
-rw-r--r--drivers/ide/sgiioc4.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c
index b0769e96d32f..b12de8346c73 100644
--- a/drivers/ide/sgiioc4.c
+++ b/drivers/ide/sgiioc4.c
@@ -424,12 +424,11 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive)
424/* | Upper 32 bits - Zero |EOL| 15 unused | 16 Bit Length| */ 424/* | Upper 32 bits - Zero |EOL| 15 unused | 16 Bit Length| */
425/* --------------------------------------------------------------------- */ 425/* --------------------------------------------------------------------- */
426/* Creates the scatter gather list, DMA Table */ 426/* Creates the scatter gather list, DMA Table */
427static unsigned int 427static int sgiioc4_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
428sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
429{ 428{
430 ide_hwif_t *hwif = drive->hwif; 429 ide_hwif_t *hwif = drive->hwif;
431 unsigned int *table = hwif->dmatable_cpu; 430 unsigned int *table = hwif->dmatable_cpu;
432 unsigned int count = 0, i = hwif->cmd.sg_nents; 431 unsigned int count = 0, i = cmd->sg_nents;
433 struct scatterlist *sg = hwif->sg_table; 432 struct scatterlist *sg = hwif->sg_table;
434 433
435 while (i && sg_dma_len(sg)) { 434 while (i && sg_dma_len(sg)) {
@@ -484,24 +483,18 @@ use_pio_instead:
484 return 0; /* revert to PIO for this request */ 483 return 0; /* revert to PIO for this request */
485} 484}
486 485
487static int sgiioc4_dma_setup(ide_drive_t *drive) 486static int sgiioc4_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
488{ 487{
489 struct request *rq = drive->hwif->rq;
490 unsigned int count = 0;
491 int ddir; 488 int ddir;
489 u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
492 490
493 if (rq_data_dir(rq)) 491 if (sgiioc4_build_dmatable(drive, cmd) == 0) {
494 ddir = PCI_DMA_TODEVICE;
495 else
496 ddir = PCI_DMA_FROMDEVICE;
497
498 if (!(count = sgiioc4_build_dma_table(drive, rq, ddir))) {
499 /* try PIO instead of DMA */ 492 /* try PIO instead of DMA */
500 ide_map_sg(drive, rq); 493 ide_map_sg(drive, cmd);
501 return 1; 494 return 1;
502 } 495 }
503 496
504 if (rq_data_dir(rq)) 497 if (write)
505 /* Writes TO the IOC4 FROM Main Memory */ 498 /* Writes TO the IOC4 FROM Main Memory */
506 ddir = IOC4_DMA_READ; 499 ddir = IOC4_DMA_READ;
507 else 500 else