Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e37bdc0 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: add struct ide_dma_ops (take 3)



Add struct ide_dma_ops and convert core code + drivers to use it.

While at it:

* Drop "ide_" prefix from ->ide_dma_end and ->ide_dma_test_irq methods.

* Drop "ide_" "infixes" from DMA methods.

* au1xxx-ide.c:
  - use auide_dma_{test_irq,end}() directly in auide_dma_timeout()

* pdc202xx_old.c:
  - drop "old_" "infixes" from DMA methods

* siimage.c:
  - add siimage_dma_test_irq() helper
  - print SATA warning in siimage_init_one()

* Remove no longer needed ->init_hwif implementations.

v2:
* Changes based on review from Sergei:
  - s/siimage_ide_dma_test_irq/siimage_dma_test_irq/
  - s/drive->hwif/hwif/ in idefloppy_pc_intr().
  - fix patch description w.r.t. au1xxx-ide changes
  - fix au1xxx-ide build
  - fix naming for cmd64*_dma_ops
  - drop "ide_" and "old_" infixes
  - s/hpt3xxx_dma_ops/hpt37x_dma_ops/
  - s/hpt370x_dma_ops/hpt370_dma_ops/
  - use correct DMA ops for HPT302/N, HPT371/N and HPT374
  - s/it821x_smart_dma_ops/it821x_pass_through_dma_ops/

v3:
* Two bugs slipped in v2 (noticed by Sergei):
  - use correct DMA ops for HPT374 (for real this time)
  - handle HPT370/HPT370A properly

Acked-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 1fd18905
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -389,17 +389,21 @@ static int icside_dma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
	hwif->dmatable_cpu	= NULL;
	hwif->dmatable_dma	= 0;

	hwif->dma_host_set	= icside_dma_host_set;
	hwif->dma_setup		= icside_dma_setup;
	hwif->dma_exec_cmd	= icside_dma_exec_cmd;
	hwif->dma_start		= icside_dma_start;
	hwif->ide_dma_end	= icside_dma_end;
	hwif->ide_dma_test_irq	= icside_dma_test_irq;
	hwif->dma_timeout	= icside_dma_timeout;
	hwif->dma_lost_irq	= icside_dma_lost_irq;

	return 0;
}

static struct ide_dma_ops icside_v6_dma_ops = {
	.dma_host_set		= icside_dma_host_set,
	.dma_setup		= icside_dma_setup,
	.dma_exec_cmd		= icside_dma_exec_cmd,
	.dma_start		= icside_dma_start,
	.dma_end		= icside_dma_end,
	.dma_test_irq		= icside_dma_test_irq,
	.dma_timeout		= icside_dma_timeout,
	.dma_lost_irq		= icside_dma_lost_irq,
};
#else
#define icside_v6_dma_ops NULL
#endif

static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d)
@@ -475,6 +479,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
static const struct ide_port_info icside_v6_port_info __initdata = {
	.init_dma		= icside_dma_off_init,
	.port_ops		= &icside_v6_no_dma_port_ops,
	.dma_ops		= &icside_v6_dma_ops,
	.host_flags		= IDE_HFLAG_SERIALIZE |
				  IDE_HFLAG_NO_AUTOTUNE,
	.mwdma_mask		= ATA_MWDMA2,
@@ -550,6 +555,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
	if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) {
		d.init_dma = icside_dma_init;
		d.port_ops = &icside_v6_dma_port_ops;
		d.dma_ops = NULL;
	}

	idx[0] = hwif->index;
+1 −1
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif,
	if (ide_allocate_dma_engine(hwif))
		return -1;

	ide_setup_dma(hwif, base);
	ide_setup_dma(hwif, base, d);

	return 0;
}
+12 −11
Original line number Diff line number Diff line
@@ -673,11 +673,6 @@ cris_ide_inb(unsigned long reg)
	return (unsigned char)cris_ide_inw(reg);
}

static int cris_dma_end (ide_drive_t *drive);
static int cris_dma_setup (ide_drive_t *drive);
static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command);
static int cris_dma_test_irq(ide_drive_t *drive);
static void cris_dma_start(ide_drive_t *drive);
static void cris_ide_input_data (ide_drive_t *drive, void *, unsigned int);
static void cris_ide_output_data (ide_drive_t *drive, void *, unsigned int);
static void cris_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int);
@@ -787,9 +782,12 @@ static const struct ide_port_ops cris_port_ops = {
	.set_dma_mode		= cris_set_dma_mode,
};

static struct ide_dma_ops cris_dma_ops;

static const struct ide_port_info cris_port_info __initdata = {
	.chipset		= ide_etrax100,
	.port_ops		= &cris_port_ops,
	.dma_ops		= &cris_dma_ops,
	.host_flags		= IDE_HFLAG_NO_ATAPI_DMA |
				  IDE_HFLAG_NO_DMA, /* no SFF-style DMA */
	.pio_mask		= ATA_PIO4,
@@ -820,12 +818,6 @@ static int __init init_e100_ide(void)
		hwif->ata_output_data = &cris_ide_output_data;
		hwif->atapi_input_bytes = &cris_atapi_input_bytes;
		hwif->atapi_output_bytes = &cris_atapi_output_bytes;
		hwif->dma_host_set = &cris_dma_host_set;
		hwif->ide_dma_end = &cris_dma_end;
		hwif->dma_setup = &cris_dma_setup;
		hwif->dma_exec_cmd = &cris_dma_exec_cmd;
		hwif->ide_dma_test_irq = &cris_dma_test_irq;
		hwif->dma_start = &cris_dma_start;
		hwif->OUTB = &cris_ide_outb;
		hwif->OUTW = &cris_ide_outw;
		hwif->OUTBSYNC = &cris_ide_outbsync;
@@ -1080,6 +1072,15 @@ static void cris_dma_start(ide_drive_t *drive)
	}
}

static struct ide_dma_ops cris_dma_ops = {
	.dma_host_set		= cris_dma_host_set,
	.dma_setup		= cris_dma_setup,
	.dma_exec_cmd		= cris_dma_exec_cmd,
	.dma_start		= cris_dma_start,
	.dma_end		= cris_dma_end,
	.dma_test_irq		= cris_dma_test_irq,
};

module_init(init_e100_ide);

MODULE_LICENSE("GPL");
+3 −3
Original line number Diff line number Diff line
@@ -539,7 +539,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,

	/* FIXME: for Virtual DMA we must check harder */
	if (info->dma)
		info->dma = !hwif->dma_setup(drive);
		info->dma = !hwif->dma_ops->dma_setup(drive);

	/* set up the controller registers */
	ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL |
@@ -617,7 +617,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,

	/* start the DMA if need be */
	if (info->dma)
		hwif->dma_start(drive);
		hwif->dma_ops->dma_start(drive);

	return ide_started;
}
@@ -929,7 +929,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
	dma = info->dma;
	if (dma) {
		info->dma = 0;
		dma_error = HWIF(drive)->ide_dma_end(drive);
		dma_error = hwif->dma_ops->dma_end(drive);
		if (dma_error) {
			printk(KERN_ERR "%s: DMA %s error\n", drive->name,
					write ? "write" : "read");
+37 −22
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
{
	u8 stat = 0, dma_stat = 0;

	dma_stat = HWIF(drive)->ide_dma_end(drive);
	dma_stat = drive->hwif->dma_ops->dma_end(drive);
	stat = ide_read_status(drive);

	if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
@@ -394,7 +394,7 @@ void ide_dma_off_quietly(ide_drive_t *drive)
	drive->using_dma = 0;
	ide_toggle_bounce(drive, 0);

	drive->hwif->dma_host_set(drive, 0);
	drive->hwif->dma_ops->dma_host_set(drive, 0);
}

EXPORT_SYMBOL(ide_dma_off_quietly);
@@ -427,7 +427,7 @@ void ide_dma_on(ide_drive_t *drive)
	drive->using_dma = 1;
	ide_toggle_bounce(drive, 1);

	drive->hwif->dma_host_set(drive, 1);
	drive->hwif->dma_ops->dma_host_set(drive, 1);
}

#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
@@ -802,10 +802,10 @@ void ide_dma_timeout (ide_drive_t *drive)

	printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name);

	if (hwif->ide_dma_test_irq(drive))
	if (hwif->dma_ops->dma_test_irq(drive))
		return;

	hwif->ide_dma_end(drive);
	hwif->dma_ops->dma_end(drive);
}

EXPORT_SYMBOL(ide_dma_timeout);
@@ -839,8 +839,21 @@ int ide_allocate_dma_engine(ide_hwif_t *hwif)
}
EXPORT_SYMBOL_GPL(ide_allocate_dma_engine);

void ide_setup_dma(ide_hwif_t *hwif, unsigned long base)
static struct ide_dma_ops sff_dma_ops = {
	.dma_host_set		= ide_dma_host_set,
	.dma_setup		= ide_dma_setup,
	.dma_exec_cmd		= ide_dma_exec_cmd,
	.dma_start		= ide_dma_start,
	.dma_end		= __ide_dma_end,
	.dma_test_irq		= __ide_dma_test_irq,
	.dma_timeout		= ide_dma_timeout,
	.dma_lost_irq		= ide_dma_lost_irq,
};

void ide_setup_dma(ide_hwif_t *hwif, unsigned long base,
		   const struct ide_port_info *d)
{
	struct ide_dma_ops *dma_ops = d->dma_ops ? d->dma_ops : &sff_dma_ops;
	hwif->dma_base = base;

	if (!hwif->dma_command)
@@ -854,22 +867,24 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base)
	if (!hwif->dma_prdtable)
		hwif->dma_prdtable	= hwif->dma_base + 4;

	if (!hwif->dma_host_set)
		hwif->dma_host_set = &ide_dma_host_set;
	if (!hwif->dma_setup)
		hwif->dma_setup = &ide_dma_setup;
	if (!hwif->dma_exec_cmd)
		hwif->dma_exec_cmd = &ide_dma_exec_cmd;
	if (!hwif->dma_start)
		hwif->dma_start = &ide_dma_start;
	if (!hwif->ide_dma_end)
		hwif->ide_dma_end = &__ide_dma_end;
	if (!hwif->ide_dma_test_irq)
		hwif->ide_dma_test_irq = &__ide_dma_test_irq;
	if (!hwif->dma_timeout)
		hwif->dma_timeout = &ide_dma_timeout;
	if (!hwif->dma_lost_irq)
		hwif->dma_lost_irq = &ide_dma_lost_irq;
	hwif->dma_ops = dma_ops;

	if (dma_ops->dma_host_set == NULL)
		dma_ops->dma_host_set	= ide_dma_host_set;
	if (dma_ops->dma_setup == NULL)
		dma_ops->dma_setup	= ide_dma_setup;
	if (dma_ops->dma_exec_cmd == NULL)
		dma_ops->dma_exec_cmd	= ide_dma_exec_cmd;
	if (dma_ops->dma_start == NULL)
		dma_ops->dma_start	= ide_dma_start;
	if (dma_ops->dma_end == NULL)
		dma_ops->dma_end	= __ide_dma_end;
	if (dma_ops->dma_test_irq == NULL)
		dma_ops->dma_test_irq	= __ide_dma_test_irq;
	if (dma_ops->dma_timeout == NULL)
		dma_ops->dma_timeout	= ide_dma_timeout;
	if (dma_ops->dma_lost_irq == NULL)
		dma_ops->dma_lost_irq	= ide_dma_lost_irq;
}

EXPORT_SYMBOL_GPL(ide_setup_dma);
Loading