ide: add ide_dma_prepare() helper
* Add ide_dma_prepare() helper. * Convert ide_issue_pc() and do_rw_taskfile() to use it. * Make ide_build_sglist() static. There should be no functional changes caused by this patch. Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
@@ -638,7 +638,6 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
|
|||||||
{
|
{
|
||||||
struct ide_atapi_pc *pc;
|
struct ide_atapi_pc *pc;
|
||||||
ide_hwif_t *hwif = drive->hwif;
|
ide_hwif_t *hwif = drive->hwif;
|
||||||
const struct ide_dma_ops *dma_ops = hwif->dma_ops;
|
|
||||||
ide_expiry_t *expiry = NULL;
|
ide_expiry_t *expiry = NULL;
|
||||||
struct request *rq = hwif->rq;
|
struct request *rq = hwif->rq;
|
||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
@@ -652,12 +651,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
|
|||||||
expiry = ide_cd_expiry;
|
expiry = ide_cd_expiry;
|
||||||
timeout = ATAPI_WAIT_PC;
|
timeout = ATAPI_WAIT_PC;
|
||||||
|
|
||||||
if (drive->dma) {
|
if (drive->dma)
|
||||||
if (ide_build_sglist(drive, cmd))
|
drive->dma = !ide_dma_prepare(drive, cmd);
|
||||||
drive->dma = !dma_ops->dma_setup(drive, cmd);
|
|
||||||
else
|
|
||||||
drive->dma = 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pc = drive->pc;
|
pc = drive->pc;
|
||||||
|
|
||||||
@@ -675,13 +670,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
|
|||||||
ide_dma_off(drive);
|
ide_dma_off(drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pc->flags & PC_FLAG_DMA_OK) &&
|
if (pc->flags & PC_FLAG_DMA_OK)
|
||||||
(drive->dev_flags & IDE_DFLAG_USING_DMA)) {
|
drive->dma = !ide_dma_prepare(drive, cmd);
|
||||||
if (ide_build_sglist(drive, cmd))
|
|
||||||
drive->dma = !dma_ops->dma_setup(drive, cmd);
|
|
||||||
else
|
|
||||||
drive->dma = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!drive->dma)
|
if (!drive->dma)
|
||||||
pc->flags &= ~PC_FLAG_DMA_OK;
|
pc->flags &= ~PC_FLAG_DMA_OK;
|
||||||
|
@@ -128,7 +128,7 @@ int ide_dma_good_drive(ide_drive_t *drive)
|
|||||||
* operate in a portable fashion.
|
* operate in a portable fashion.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int ide_build_sglist(ide_drive_t *drive, struct ide_cmd *cmd)
|
static int ide_build_sglist(ide_drive_t *drive, struct ide_cmd *cmd)
|
||||||
{
|
{
|
||||||
ide_hwif_t *hwif = drive->hwif;
|
ide_hwif_t *hwif = drive->hwif;
|
||||||
struct scatterlist *sg = hwif->sg_table;
|
struct scatterlist *sg = hwif->sg_table;
|
||||||
@@ -563,3 +563,12 @@ int ide_allocate_dma_engine(ide_hwif_t *hwif)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ide_allocate_dma_engine);
|
EXPORT_SYMBOL_GPL(ide_allocate_dma_engine);
|
||||||
|
|
||||||
|
int ide_dma_prepare(ide_drive_t *drive, struct ide_cmd *cmd)
|
||||||
|
{
|
||||||
|
if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
|
||||||
|
ide_build_sglist(drive, cmd) == 0 ||
|
||||||
|
drive->hwif->dma_ops->dma_setup(drive, cmd))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -100,9 +100,7 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
|
|||||||
ide_execute_command(drive, cmd, handler, WAIT_WORSTCASE);
|
ide_execute_command(drive, cmd, handler, WAIT_WORSTCASE);
|
||||||
return ide_started;
|
return ide_started;
|
||||||
case ATA_PROT_DMA:
|
case ATA_PROT_DMA:
|
||||||
if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
|
if (ide_dma_prepare(drive, cmd))
|
||||||
ide_build_sglist(drive, cmd) == 0 ||
|
|
||||||
dma_ops->dma_setup(drive, cmd))
|
|
||||||
return ide_stopped;
|
return ide_stopped;
|
||||||
hwif->expiry = dma_ops->dma_timer_expiry;
|
hwif->expiry = dma_ops->dma_timer_expiry;
|
||||||
ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD);
|
ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD);
|
||||||
|
@@ -1443,7 +1443,8 @@ ide_startstop_t ide_dma_intr(ide_drive_t *);
|
|||||||
int ide_allocate_dma_engine(ide_hwif_t *);
|
int ide_allocate_dma_engine(ide_hwif_t *);
|
||||||
void ide_release_dma_engine(ide_hwif_t *);
|
void ide_release_dma_engine(ide_hwif_t *);
|
||||||
|
|
||||||
int ide_build_sglist(ide_drive_t *, struct ide_cmd *);
|
int ide_dma_prepare(ide_drive_t *, struct ide_cmd *);
|
||||||
|
|
||||||
void ide_destroy_dmatable(ide_drive_t *);
|
void ide_destroy_dmatable(ide_drive_t *);
|
||||||
|
|
||||||
#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
|
#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
|
||||||
@@ -1477,8 +1478,8 @@ static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
|
|||||||
static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; }
|
static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; }
|
||||||
static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
|
static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
|
||||||
static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
|
static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
|
||||||
static inline int ide_build_sglist(ide_drive_t *drive,
|
static inline int ide_dma_prepare(ide_drive_t *drive,
|
||||||
struct ide_cmd *cmd) { return 0; }
|
struct ide_cmd *cmd) { return 1; }
|
||||||
static inline void ide_destroy_dmatable(ide_drive_t *drive) { ; }
|
static inline void ide_destroy_dmatable(ide_drive_t *drive) { ; }
|
||||||
#endif /* CONFIG_BLK_DEV_IDEDMA */
|
#endif /* CONFIG_BLK_DEV_IDEDMA */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user