[PATCH 02/18] ide: use I/O ops directly in ide-dma.c

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-ide@...>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...>, <linux-kernel@...>
Date: Friday, June 20, 2008 - 5:33 pm

Use I/O ops directly in ide_dma_host_set(), ide_dma_setup(),
ide_dma_start() and __ide_dma_end().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-dma.c |   59 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 45 insertions(+), 14 deletions(-)

Index: b/drivers/ide/ide-dma.c
===================================================================
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -376,7 +376,10 @@ void ide_dma_host_set(ide_drive_t *drive
 	else
 		dma_stat &= ~(1 << (5 + unit));
 
-	hwif->OUTB(dma_stat, hwif->dma_status);
+	if (hwif->host_flags & IDE_HFLAG_MMIO)
+		writeb(dma_stat, (void __iomem *)hwif->dma_status);
+	else
+		outb(dma_stat, hwif->dma_status);
 }
 
 EXPORT_SYMBOL_GPL(ide_dma_host_set);
@@ -449,6 +452,7 @@ int ide_dma_setup(ide_drive_t *drive)
 	ide_hwif_t *hwif = drive->hwif;
 	struct request *rq = HWGROUP(drive)->rq;
 	unsigned int reading;
+	u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
 	u8 dma_stat;
 
 	if (rq_data_dir(rq))
@@ -470,13 +474,20 @@ int ide_dma_setup(ide_drive_t *drive)
 		outl(hwif->dmatable_dma, hwif->dma_base + ATA_DMA_TABLE_OFS);
 
 	/* specify r/w */
-	hwif->OUTB(reading, hwif->dma_command);
+	if (mmio)
+		writeb(reading, (void __iomem *)hwif->dma_command);
+	else
+		outb(reading, hwif->dma_command);
 
 	/* read DMA status for INTR & ERROR flags */
 	dma_stat = hwif->read_sff_dma_status(hwif);
 
 	/* clear INTR & ERROR flags */
-	hwif->OUTB(dma_stat|6, hwif->dma_status);
+	if (mmio)
+		writeb(dma_stat | 6, (void __iomem *)hwif->dma_status);
+	else
+		outb(dma_stat | 6, hwif->dma_status);
+
 	drive->waiting_for_dma = 1;
 	return 0;
 }
@@ -492,16 +503,23 @@ EXPORT_SYMBOL_GPL(ide_dma_exec_cmd);
 
 void ide_dma_start(ide_drive_t *drive)
 {
-	ide_hwif_t *hwif	= HWIF(drive);
-	u8 dma_cmd		= hwif->INB(hwif->dma_command);
+	ide_hwif_t *hwif = drive->hwif;
+	u8 dma_cmd;
 
 	/* Note that this is done *after* the cmd has
 	 * been issued to the drive, as per the BM-IDE spec.
 	 * The Promise Ultra33 doesn't work correctly when
 	 * we do this part before issuing the drive cmd.
 	 */
-	/* start DMA */
-	hwif->OUTB(dma_cmd|1, hwif->dma_command);
+	if (hwif->host_flags & IDE_HFLAG_MMIO) {
+		dma_cmd = readb((void __iomem *)hwif->dma_command);
+		/* start DMA */
+		writeb(dma_cmd | 1, (void __iomem *)hwif->dma_command);
+	} else {
+		dma_cmd = inb(hwif->dma_command);
+		outb(dma_cmd | 1, hwif->dma_command);
+	}
+
 	hwif->dma = 1;
 	wmb();
 }
@@ -511,18 +529,31 @@ EXPORT_SYMBOL_GPL(ide_dma_start);
 /* returns 1 on error, 0 otherwise */
 int __ide_dma_end (ide_drive_t *drive)
 {
-	ide_hwif_t *hwif	= HWIF(drive);
+	ide_hwif_t *hwif = drive->hwif;
+	u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
 	u8 dma_stat = 0, dma_cmd = 0;
 
 	drive->waiting_for_dma = 0;
-	/* get dma_command mode */
-	dma_cmd = hwif->INB(hwif->dma_command);
-	/* stop DMA */
-	hwif->OUTB(dma_cmd&~1, hwif->dma_command);
+
+	if (mmio) {
+		/* get DMA command mode */
+		dma_cmd = readb((void __iomem *)hwif->dma_command);
+		/* stop DMA */
+		writeb(dma_cmd & ~1, (void __iomem *)hwif->dma_command);
+	} else {
+		dma_cmd = inb(hwif->dma_command);
+		outb(dma_cmd & ~1, hwif->dma_command);
+	}
+
 	/* get DMA status */
 	dma_stat = hwif->read_sff_dma_status(hwif);
-	/* clear the INTR & ERROR bits */
-	hwif->OUTB(dma_stat|6, hwif->dma_status);
+
+	if (mmio)
+		/* clear the INTR & ERROR bits */
+		writeb(dma_stat | 6, (void __iomem *)hwif->dma_status);
+	else
+		outb(dma_stat | 6, hwif->dma_status);
+
 	/* purge DMA mappings */
 	ide_destroy_dmatable(drive);
 	/* verify good DMA status */
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 01/18] ide: add -&gt;read_sff_dma_status method, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:33 pm)
Re: [PATCH 01/18] ide: add -&gt;read_sff_dma_status method, Sergei Shtylyov, (Wed Sep 3, 9:19 am)
Re: [PATCH 01/18] ide: add -&gt;read_sff_dma_status method, Bartlomiej Zolnierkiewicz..., (Wed Sep 3, 2:13 pm)
Re: [PATCH 01/18] ide: add -&gt;read_sff_dma_status method, Sergei Shtylyov, (Sun Sep 7, 2:15 pm)
Re: [PATCH 01/18] ide: add -&gt;read_sff_dma_status method, Bartlomiej Zolnierkiewicz..., (Sun Sep 7, 3:23 pm)
Re: [PATCH 01/18] ide: add -&gt;read_sff_dma_status method, Sergei Shtylyov, (Sun Sep 7, 6:26 pm)
Re: [PATCH 01/18] ide: add -&gt;read_sff_dma_status method, Sergei Shtylyov, (Sun Sep 7, 2:49 pm)
[PATCH 18/18] ide: remove -&gt;INB, -&gt;OUTB and -&gt;OUTBSYNC methods, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:35 pm)
[PATCH 17/18] ide: add ide_read_bcount_and_ireason() helper, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:35 pm)
[PATCH 16/18] ide: add ide_read_ireason() helper, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:35 pm)
[PATCH 15/18] ide: add ide_read_device() helper, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:35 pm)
[PATCH 14/18] ide: use -&gt;tf_read in ide_read_error(), Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
[PATCH 13/18] ide: use -&gt;tf_load in SELECT_DRIVE(), Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
[PATCH 12/18] ide: use -&gt;tf_load in actual_try_to_identify(), Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
Re: [PATCH 12/18] ide: use -&gt;tf_load in actual_try_to_ide..., Bartlomiej Zolnierkiewicz..., (Sat Jun 21, 3:10 pm)
[PATCH 11/18] ide: use -&gt;tf_load in ide_config_drive_speed(), Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
[PATCH 10/18] ide: change order of register access in ide_co..., Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
[PATCH 09/18] ide: add -&gt;set_irq method, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
Re: [PATCH 09/18] ide: add -&gt;set_irq method, Sergei Shtylyov, (Wed Oct 15, 8:20 am)
Re: [PATCH 09/18] ide: add -&gt;set_irq method, Bartlomiej Zolnierkiewicz..., (Wed Oct 15, 2:22 pm)
Re: [PATCH 09/18] ide: add -&gt;set_irq method, Sergei Shtylyov, (Wed Oct 15, 5:22 pm)
[PATCH 08/18] ide: add -&gt;read_altstatus method, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
[PATCH 07/18] ide: add -&gt;read_status method, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
[PATCH 06/18] ide: add -&gt;exec_command method, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:34 pm)
[PATCH 05/18] ide: factor out simplex handling from ide_pci_..., Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:33 pm)
[PATCH 04/18] ide: remove ide_setup_dma(), Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:33 pm)
Re: [PATCH 04/18] ide: remove ide_setup_dma(), Sergei Shtylyov, (Thu Aug 21, 1:16 pm)
Re: [PATCH 04/18] ide: remove ide_setup_dma(), Sergei Shtylyov, (Thu Aug 21, 1:56 pm)
Re: [PATCH 04/18] ide: remove ide_setup_dma(), Sergei Shtylyov, (Fri Jun 20, 6:03 pm)
Re: [PATCH 04/18] ide: remove ide_setup_dma(), Bartlomiej Zolnierkiewicz..., (Sat Jun 21, 3:06 pm)
Re: [PATCH 04/18] ide: remove ide_setup_dma(), Sergei Shtylyov, (Sat Jun 21, 3:29 pm)
[PATCH 03/18] ide: remove -&gt;dma_{status,command} fields f..., Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:33 pm)
[PATCH 02/18] ide: use I/O ops directly in ide-dma.c, Bartlomiej Zolnierkiewicz..., (Fri Jun 20, 5:33 pm)
Re: [PATCH 02/18] ide: use I/O ops directly in ide-dma.c, Sergei Shtylyov, (Mon Sep 8, 11:49 am)