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>
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index c3fd528..b56af49 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -638,12 +638,20 @@
{
struct ide_atapi_pc *pc;
ide_hwif_t *hwif = drive->hwif;
+ const struct ide_dma_ops *dma_ops = hwif->dma_ops;
+ struct ide_cmd *cmd = &hwif->cmd;
ide_expiry_t *expiry = NULL;
struct request *rq = hwif->rq;
unsigned int timeout;
u32 tf_flags;
u16 bcount;
+ if (drive->media != ide_floppy) {
+ if (rq_data_dir(rq))
+ cmd->tf_flags |= IDE_TFLAG_WRITE;
+ cmd->rq = rq;
+ }
+
if (dev_is_idecd(drive)) {
tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
bcount = ide_cd_get_xferlen(rq);
@@ -651,8 +659,8 @@
timeout = ATAPI_WAIT_PC;
if (drive->dma) {
- if (ide_build_sglist(drive, rq))
- drive->dma = !hwif->dma_ops->dma_setup(drive);
+ if (ide_build_sglist(drive, cmd))
+ drive->dma = !dma_ops->dma_setup(drive, cmd);
else
drive->dma = 0;
}
@@ -675,8 +683,8 @@
if ((pc->flags & PC_FLAG_DMA_OK) &&
(drive->dev_flags & IDE_DFLAG_USING_DMA)) {
- if (ide_build_sglist(drive, rq))
- drive->dma = !hwif->dma_ops->dma_setup(drive);
+ if (ide_build_sglist(drive, cmd))
+ drive->dma = !dma_ops->dma_setup(drive, cmd);
else
drive->dma = 0;
}