ide-dma-sff: factor out ide_dma_sff_write_status()

Factor out ide_dma_sff_write_status(), symmetric to ide_dma_sff_read_status().

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
Sergei Shtylyov 2009-01-06 17:21:02 +01:00 committed by Bartlomiej Zolnierkiewicz
parent 592b531521
commit 05789634ef

View file

@ -61,6 +61,16 @@ u8 ide_dma_sff_read_status(ide_hwif_t *hwif)
} }
EXPORT_SYMBOL_GPL(ide_dma_sff_read_status); EXPORT_SYMBOL_GPL(ide_dma_sff_read_status);
static void ide_dma_sff_write_status(ide_hwif_t *hwif, u8 val)
{
unsigned long addr = hwif->dma_base + ATA_DMA_STATUS;
if (hwif->host_flags & IDE_HFLAG_MMIO)
writeb(val, (void __iomem *)addr);
else
outb(val, addr);
}
/** /**
* ide_dma_host_set - Enable/disable DMA on a host * ide_dma_host_set - Enable/disable DMA on a host
* @drive: drive to control * @drive: drive to control
@ -80,11 +90,7 @@ void ide_dma_host_set(ide_drive_t *drive, int on)
else else
dma_stat &= ~(1 << (5 + unit)); dma_stat &= ~(1 << (5 + unit));
if (hwif->host_flags & IDE_HFLAG_MMIO) ide_dma_sff_write_status(hwif, dma_stat);
writeb(dma_stat,
(void __iomem *)(hwif->dma_base + ATA_DMA_STATUS));
else
outb(dma_stat, hwif->dma_base + ATA_DMA_STATUS);
} }
EXPORT_SYMBOL_GPL(ide_dma_host_set); EXPORT_SYMBOL_GPL(ide_dma_host_set);
@ -198,7 +204,7 @@ int ide_dma_setup(ide_drive_t *drive)
} }
/* PRD table */ /* PRD table */
if (hwif->host_flags & IDE_HFLAG_MMIO) if (mmio)
writel(hwif->dmatable_dma, writel(hwif->dmatable_dma,
(void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS));
else else
@ -214,12 +220,7 @@ int ide_dma_setup(ide_drive_t *drive)
dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);
/* clear INTR & ERROR flags */ /* clear INTR & ERROR flags */
if (mmio) ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR);
writeb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR,
(void __iomem *)(hwif->dma_base + ATA_DMA_STATUS));
else
outb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR,
hwif->dma_base + ATA_DMA_STATUS);
drive->waiting_for_dma = 1; drive->waiting_for_dma = 1;
return 0; return 0;
@ -300,13 +301,12 @@ EXPORT_SYMBOL_GPL(ide_dma_start);
int ide_dma_end(ide_drive_t *drive) int ide_dma_end(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
u8 dma_stat = 0, dma_cmd = 0, mask; u8 dma_stat = 0, dma_cmd = 0, mask;
drive->waiting_for_dma = 0; drive->waiting_for_dma = 0;
/* stop DMA */ /* stop DMA */
if (mmio) { if (hwif->host_flags & IDE_HFLAG_MMIO) {
dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD));
writeb(dma_cmd & ~ATA_DMA_START, writeb(dma_cmd & ~ATA_DMA_START,
(void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); (void __iomem *)(hwif->dma_base + ATA_DMA_CMD));
@ -318,13 +318,8 @@ int ide_dma_end(ide_drive_t *drive)
/* get DMA status */ /* get DMA status */
dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);
if (mmio) /* clear INTR & ERROR bits */
/* clear the INTR & ERROR bits */ ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR);
writeb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR,
(void __iomem *)(hwif->dma_base + ATA_DMA_STATUS));
else
outb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR,
hwif->dma_base + ATA_DMA_STATUS);
/* purge DMA mappings */ /* purge DMA mappings */
ide_destroy_dmatable(drive); ide_destroy_dmatable(drive);