LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/19] ide: add it8213 driver
@ 2007-01-12  4:26 Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 3/19] ide: it8213 driver update Bartlomiej Zolnierkiewicz
                   ` (16 more replies)
  0 siblings, 17 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:26 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: add it8213 driver

From: Jack Lee <Jack.Lee@ite.com.tw>
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---

 drivers/ide/Kconfig      |    5 
 drivers/ide/pci/Makefile |    2 
 drivers/ide/pci/it8213.c |  402 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 408 insertions(+), 1 deletion(-)

Index: a/drivers/ide/Kconfig
===================================================================
--- a.orig/drivers/ide/Kconfig
+++ a/drivers/ide/Kconfig
@@ -606,6 +606,11 @@ config BLK_DEV_PIIX
 	  the kernel to change PIO, DMA and UDMA speeds and to configure
 	  the chip to optimum performance.
 
+config BLK_DEV_IT8213
+	tristate "IT8213 IDE support"
+	help
+	 This driver adds support for the ITE 8213 IDE controller.
+
 config BLK_DEV_IT821X
 	tristate "IT821X IDE support"
 	help
Index: a/drivers/ide/pci/Makefile
===================================================================
--- a.orig/drivers/ide/pci/Makefile
+++ a/drivers/ide/pci/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_BLK_DEV_SC1200)		+= sc1200.
 obj-$(CONFIG_BLK_DEV_CY82C693)		+= cy82c693.o
 obj-$(CONFIG_BLK_DEV_HPT34X)		+= hpt34x.o
 obj-$(CONFIG_BLK_DEV_HPT366)		+= hpt366.o
-#obj-$(CONFIG_BLK_DEV_HPT37X)		+= hpt37x.o
+obj-$(CONFIG_BLK_DEV_IT8213)		+= it8213.o
 obj-$(CONFIG_BLK_DEV_IT821X)		+= it821x.o
 obj-$(CONFIG_BLK_DEV_JMICRON)		+= jmicron.o
 obj-$(CONFIG_BLK_DEV_NS87415)		+= ns87415.o
Index: a/drivers/ide/pci/it8213.c
===================================================================
--- /dev/null
+++ a/drivers/ide/pci/it8213.c
@@ -0,0 +1,402 @@
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+
+#include <asm/io.h>
+
+/*
+ *	it8213_ratemask	-	Compute available modes
+ *	@drive: IDE drive
+ *
+ *	Compute the available speeds for the devices on the interface. This
+ *	is all modes to ATA100 clipped by drive cable setup.
+ */
+
+static u8 it8213_ratemask (ide_drive_t *drive)
+{
+	u8 mode	= 4;
+	if (!eighty_ninty_three(drive))
+		mode = min(mode, (u8)1);
+	return mode;
+}
+
+/**
+ *	it8213_dma_2_pio		-	return the PIO mode matching DMA
+ *	@xfer_rate: transfer speed
+ *
+ *	Returns the nearest equivalent PIO timing for the PIO or DMA
+ *	mode requested by the controller.
+ */
+
+static u8 it8213_dma_2_pio (u8 xfer_rate) {
+	switch(xfer_rate) {
+		case XFER_UDMA_6:
+		case XFER_UDMA_5:
+		case XFER_UDMA_4:
+		case XFER_UDMA_3:
+		case XFER_UDMA_2:
+		case XFER_UDMA_1:
+		case XFER_UDMA_0:
+		case XFER_MW_DMA_2:
+		case XFER_PIO_4:
+			return 4;
+		case XFER_MW_DMA_1:
+		case XFER_PIO_3:
+			return 3;
+		case XFER_SW_DMA_2:
+		case XFER_PIO_2:
+			return 2;
+		case XFER_MW_DMA_0:
+		case XFER_SW_DMA_1:
+		case XFER_SW_DMA_0:
+		case XFER_PIO_1:
+		case XFER_PIO_0:
+		case XFER_PIO_SLOW:
+		default:
+			return 0;
+	}
+}
+
+static spinlock_t tune_lock = SPIN_LOCK_UNLOCKED;
+
+/*
+ *	it8213_tuneproc	-	tune a drive
+ *	@drive: drive to tune
+ *	@mode_wanted: the target operating mode
+ *
+ *	Load the timing settings for this device mode into the
+ *	controller. By the time we are called the mode has been
+ *	modified as neccessary to handle the absence of seperate
+ *	master/slave timers for MWDMA/PIO.
+ *
+ *	This code is only used in pass through mode.
+ */
+
+static void it8213_tuneproc (ide_drive_t *drive,  u8 pio)
+{
+	ide_hwif_t *hwif	= HWIF(drive);
+	struct pci_dev *dev	= hwif->pci_dev;
+	int is_slave		= (&hwif->drives[1] == drive);
+	int master_port		= 0x40;
+	int slave_port		= 0x44;
+	unsigned long flags;
+	u16 master_data;
+	u8 slave_data;
+
+	u8 timings[][2]	= { { 0, 0 },
+			    { 0, 0 },
+			    { 1, 0 },
+			    { 2, 1 },
+			    { 2, 3 }, };
+
+	pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
+
+	spin_lock_irqsave(&tune_lock, flags);
+	pci_read_config_word(dev, master_port, &master_data);
+	if (is_slave) {
+		master_data = master_data | 0x4000;
+		if (pio > 1)
+
+			master_data = master_data | 0x0070;
+		pci_read_config_byte(dev, slave_port, &slave_data);
+		slave_data = slave_data & 0xf0;
+		slave_data = slave_data | (((timings[pio][0] << 2) | (timings[pio][1]) << 0));
+	} else {
+		master_data = master_data & 0xccf8;
+		if (pio > 1)
+
+			master_data = master_data | 0x0007;
+		master_data = master_data | (timings[pio][0] << 12) | (timings[pio][1] << 8);
+	}
+	pci_write_config_word(dev, master_port, master_data);
+	if (is_slave)
+		pci_write_config_byte(dev, slave_port, slave_data);
+	spin_unlock_irqrestore(&tune_lock, flags);
+}
+
+
+/**
+ *	it8213_tune_chipset	-	set controller timings
+ *	@drive: Drive to set up
+ *	@xferspeed: speed we want to achieve
+ *
+ *	Tune the ITE chipset for the desired mode. If we can't achieve
+ *	the desired mode then tune for a lower one, but ultimately
+ *	make the thing work.
+ */
+
+static int it8213_tune_chipset (ide_drive_t *drive, byte xferspeed)
+{
+
+	ide_hwif_t *hwif	= HWIF(drive);
+	struct pci_dev *dev	= hwif->pci_dev;
+	u8 maslave		= 0x40;
+	u8 speed		= ide_rate_filter(it8213_ratemask(drive), xferspeed);
+	int a_speed		= 3 << (drive->dn * 4);
+	int u_flag		= 1 << drive->dn;
+	int v_flag		= 0x01 << drive->dn;
+	int w_flag		= 0x10 << drive->dn;
+	int u_speed		= 0;
+	u16			reg4042, reg4a;
+	u8			reg48, reg54, reg55;
+
+	pci_read_config_word(dev, maslave, &reg4042);
+	pci_read_config_byte(dev, 0x48, &reg48);
+	pci_read_config_word(dev, 0x4a, &reg4a);
+	pci_read_config_byte(dev, 0x54, &reg54);
+	pci_read_config_byte(dev, 0x55, &reg55);
+
+	switch(speed) {
+		case XFER_UDMA_6:
+		case XFER_UDMA_4:
+		case XFER_UDMA_2:u_speed = 2 << (drive->dn * 4); break;
+		case XFER_UDMA_5:
+		case XFER_UDMA_3:
+		case XFER_UDMA_1:u_speed = 1 << (drive->dn * 4); break;
+		case XFER_UDMA_0:u_speed = 0 << (drive->dn * 4); break;
+			break;
+		case XFER_MW_DMA_2:
+		case XFER_MW_DMA_1:
+		case XFER_MW_DMA_0:
+			break;
+		case XFER_PIO_4:
+		case XFER_PIO_3:
+		case XFER_PIO_2:
+		case XFER_PIO_1:
+		case XFER_PIO_0:
+			break;
+		default:
+			return -1;
+	}
+
+		if (speed >= XFER_UDMA_0)
+		{
+		if (!(reg48 & u_flag))
+			pci_write_config_byte(dev, 0x48, reg48 | u_flag);
+		if (speed >= XFER_UDMA_5) {
+			pci_write_config_byte(dev, 0x55, (u8) reg55|w_flag);
+		} else {
+			pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
+		}
+
+		if ((reg4a & a_speed) != u_speed)
+			pci_write_config_word(dev, 0x4a, (reg4a & ~a_speed) | u_speed);
+		if (speed > XFER_UDMA_2)
+		{
+			if (!(reg54 & v_flag))
+				pci_write_config_byte(dev, 0x54, reg54 | v_flag);
+		} else
+			pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
+		} else /*if(speed >= XFER_UDMA_0)*/
+		{
+		if (reg48 & u_flag)
+			pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
+		if (reg4a & a_speed)
+			pci_write_config_word(dev, 0x4a, reg4a & ~a_speed);
+		if (reg54 & v_flag)
+			pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
+		if (reg55 & w_flag)
+			pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
+		}
+	it8213_tuneproc(drive, it8213_dma_2_pio(speed));
+	return ide_config_drive_speed(drive, speed);
+	}
+
+
+/*
+ *	config_chipset_for_dma	-	configure for DMA
+ *	@drive: drive to configure
+ *
+ *	Called by the IDE layer when it wants the timings set up.
+ */
+
+static int config_chipset_for_dma (ide_drive_t *drive)
+{
+	  u8 speed	= ide_dma_speed(drive, it8213_ratemask(drive));
+	if (!speed)
+	{
+		u8 tspeed = ide_get_best_pio_mode(drive, 255, 5, NULL);
+		speed = it8213_dma_2_pio(XFER_PIO_0 + tspeed);
+	}
+//	config_it8213_chipset_for_pio(drive, !speed);
+	it8213_tune_chipset(drive, speed);
+	return ide_dma_enable(drive);
+}
+
+/**
+ *	config_it8213_chipset_for_pio	-	set drive timings
+ *	@drive: drive to tune
+ *	@speed we want
+ *
+ *	Compute the best pio mode we can for a given device. We must
+ *	pick a speed that does not cause problems with the other device
+ *	on the cable.
+ */
+/*
+static void config_it8213_chipset_for_pio (ide_drive_t *drive, byte set_speed)
+{
+	ide_hwif_t *hwif	= HWIF(drive);
+//	u8 unit = drive->select.b.unit;
+	ide_hwif_t *hwif = drive->hwif;
+	ide_drive_t *pair = &hwif->drives[1-unit];
+	u8 speed = 0, set_pio	= ide_get_best_pio_mode(drive, 255, 5, NULL);
+	u8 pair_pio;
+
+	if(pair != NULL) {
+		pair_pio = ide_get_best_pio_mode(pair, 255, 5, NULL);
+		if(pair_pio < set_pio)
+			set_pio = pair_pio;
+	}
+	it8213_tuneproc(drive, set_pio);
+	speed = XFER_PIO_0 + set_pio;
+	if (set_speed)
+		(void) ide_config_drive_speed(drive, speed);
+}
+*/
+/**
+ *	it8213_configure_drive_for_dma	-	set up for DMA transfers
+ *	@drive: drive we are going to set up
+ *
+ *	Set up the drive for DMA, tune the controller and drive as
+ *	required. If the drive isn't suitable for DMA or we hit
+ *	other problems then we will drop down to PIO and set up
+ *	PIO appropriately
+ */
+
+static int it8213_config_drive_for_dma (ide_drive_t *drive)
+{
+//	ide_hwif_t *hwif	= drive->hwif;
+//	struct hd_driveid *id = drive->id;
+	ide_hwif_t *hwif	= HWIF(drive);
+	if (ide_use_dma(drive)) {
+		if (config_chipset_for_dma(drive))
+			return hwif->ide_dma_on(drive);
+	}
+//	config_it8213_chipset_for_pio(drive, 1);
+	hwif->tuneproc(drive, 255);
+ 	return hwif->ide_dma_off_quietly(drive);
+}
+
+
+static unsigned int __devinit init_chipset_it8213(struct pci_dev *dev, const char *name)
+{
+	printk(KERN_INFO "it8213: controller in IDE mode.\n");
+	return 0;
+}
+
+
+/**
+ *	init_hwif_it8213	-	set up hwif structs
+ *	@hwif: interface to set up
+ *
+ *	We do the basic set up of the interface structure. The IT8212
+ *	requires several custom handlers so we override the default
+ *	ide DMA handlers appropriately
+ */
+
+static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
+{
+	u8 reg42h = 0, ata66 = 0;
+	u8 mask = 0x02;
+
+	hwif->atapi_dma = 1;
+
+	hwif->speedproc = &it8213_tune_chipset;
+	hwif->tuneproc	= &it8213_tuneproc;
+
+	hwif->autodma = 0;
+
+	hwif->drives[0].autotune = 1;
+	hwif->drives[1].autotune = 1;
+
+	if (!hwif->dma_base)
+		goto fallback;
+	hwif->atapi_dma = 1;
+	hwif->ultra_mask = 0x7f;
+	hwif->mwdma_mask = 0x07;
+	hwif->swdma_mask = 0x07;
+
+	pci_read_config_byte(hwif->pci_dev, 0x42, &reg42h);
+	ata66 = (reg42h & mask) ? 0 : 1;
+
+	hwif->ide_dma_check = &it8213_config_drive_for_dma;
+	if (!(hwif->udma_four))
+		hwif->udma_four = ata66;
+//		hwif->udma_four = 0;
+
+	/*
+	 *	The BIOS often doesn't set up DMA on this controller
+	 *	so we always do it.
+	 */
+	if (!noautodma)
+		hwif->autodma = 1;
+
+	hwif->drives[0].autodma = hwif->autodma;
+	hwif->drives[1].autodma = hwif->autodma;
+	return;
+fallback:
+	hwif->autodma = 0;
+	return;
+}
+
+
+#define DECLARE_ITE_DEV(name_str)			\
+	{						\
+		.name		= name_str,		\
+		.init_chipset	= init_chipset_it8213,	\
+		.init_hwif	= init_hwif_it8213,	\
+		.channels	= 1,			\
+		.autodma		= AUTODMA,		\
+		.enablebits	= {{0x41,0x80,0x80}}, \
+		.bootable	= ON_BOARD,		\
+	}
+
+static ide_pci_device_t it8213_chipsets[] __devinitdata = {
+	/* 0 */ DECLARE_ITE_DEV("IT8213"),
+};
+
+
+/**
+ *	it8213_init_one	-	pci layer discovery entry
+ *	@dev: PCI device
+ *	@id: ident table entry
+ *
+ *	Called by the PCI code when it finds an ITE8213 controller. As
+ *	this device follows the standard interfaces we can use the
+ *	standard helper functions to do almost all the work for us.
+ */
+
+static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id)
+{
+	ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]);
+	return 0;
+}
+
+
+static struct pci_device_id it8213_pci_tbl[] = {
+	{ PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8213,  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ 0, },
+};
+
+MODULE_DEVICE_TABLE(pci, it8213_pci_tbl);
+
+static struct pci_driver driver = {
+	.name		= "ITE8213_IDE",
+	.id_table	= it8213_pci_tbl,
+	.probe		= it8213_init_one,
+};
+
+static int __init it8213_ide_init(void)
+{
+	return ide_pci_register_driver(&driver); }
+
+module_init(it8213_ide_init);
+
+MODULE_AUTHOR("Jack and Alan Cox");		/* Update this */
+MODULE_DESCRIPTION("PCI driver module for the ITE 8213");
+MODULE_LICENSE("GPL");

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 3/19] ide: it8213 driver update
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:26 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 4/19] ia64: add pci_get_legacy_ide_irq() Bartlomiej Zolnierkiewicz
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:26 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: it8213 driver update

* set ATAPI/IORDY/TIME bits correctly in it8213_tuneproc()
* fix UDMA/MWDMA/SWDMA masks in it8213_init_hwif()
* in it8213_tune_chipset() SWDMA2 mode should be used instead of MWDMA0
* backport various fixes from piix/slc90e66 drivers:
  - in it8213_tuneproc() the highest possible PIO mode is PIO4 (not PIO5)
  - clear ATAPI/IORDY/TIME bits before setting them also for slave device
  - use ->speedproc in it8213_config_drive_for_dma()
  - don't try to tune PIO in config_chipset_for_pio()
  - simplify is_slave calculation in it8213_tuneproc()
  - misc cleanups
* fix it8213_ratemask() and it8213_tuneproc() comments
* simplify it8213_init_hwif()
* remove init_chipset_it8213()
* add missing Copyrights and update MODULE_AUTHOR()
* CodingStyle cleanups
* remove dead code

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/it8213.c |  172 ++++++++++++++++++-----------------------------
 1 file changed, 66 insertions(+), 106 deletions(-)

Index: a/drivers/ide/pci/it8213.c
===================================================================
--- a.orig/drivers/ide/pci/it8213.c
+++ a/drivers/ide/pci/it8213.c
@@ -1,3 +1,11 @@
+/*
+ * ITE 8213 IDE driver
+ *
+ * Copyright (C) 2006 Jack Lee
+ * Copyright (C) 2006 Alan Cox
+ * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
+ */
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/module.h>
@@ -14,14 +22,14 @@
  *	@drive: IDE drive
  *
  *	Compute the available speeds for the devices on the interface. This
- *	is all modes to ATA100 clipped by drive cable setup.
+ *	is all modes to ATA133 clipped by drive cable setup.
  */
 
 static u8 it8213_ratemask (ide_drive_t *drive)
 {
 	u8 mode	= 4;
 	if (!eighty_ninty_three(drive))
-		mode = min(mode, (u8)1);
+		mode = min_t(u8, mode, 1);
 	return mode;
 }
 
@@ -62,55 +70,57 @@ static u8 it8213_dma_2_pio (u8 xfer_rate
 	}
 }
 
-static spinlock_t tune_lock = SPIN_LOCK_UNLOCKED;
-
 /*
  *	it8213_tuneproc	-	tune a drive
  *	@drive: drive to tune
- *	@mode_wanted: the target operating mode
- *
- *	Load the timing settings for this device mode into the
- *	controller. By the time we are called the mode has been
- *	modified as neccessary to handle the absence of seperate
- *	master/slave timers for MWDMA/PIO.
+ *	@pio: desired PIO mode
  *
- *	This code is only used in pass through mode.
+ *	Set the interface PIO mode.
  */
 
-static void it8213_tuneproc (ide_drive_t *drive,  u8 pio)
+static void it8213_tuneproc (ide_drive_t *drive, u8 pio)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct pci_dev *dev	= hwif->pci_dev;
-	int is_slave		= (&hwif->drives[1] == drive);
+	int is_slave		= drive->dn & 1;
 	int master_port		= 0x40;
 	int slave_port		= 0x44;
 	unsigned long flags;
 	u16 master_data;
 	u8 slave_data;
+	static DEFINE_SPINLOCK(tune_lock);
+	int control = 0;
 
-	u8 timings[][2]	= { { 0, 0 },
-			    { 0, 0 },
-			    { 1, 0 },
-			    { 2, 1 },
-			    { 2, 3 }, };
+	static const u8 timings[][2]= {
+					{ 0, 0 },
+					{ 0, 0 },
+					{ 1, 0 },
+					{ 2, 1 },
+					{ 2, 3 }, };
 
-	pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
+	pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
 
 	spin_lock_irqsave(&tune_lock, flags);
 	pci_read_config_word(dev, master_port, &master_data);
+
+	if (pio > 1)
+		control |= 1;	/* Programmable timing on */
+	if (drive->media != ide_disk)
+		control |= 4;	/* ATAPI */
+	if (pio > 2)
+		control |= 2;	/* IORDY */
 	if (is_slave) {
-		master_data = master_data | 0x4000;
+		master_data |=  0x4000;
+		master_data &= ~0x0070;
 		if (pio > 1)
-
-			master_data = master_data | 0x0070;
+			master_data = master_data | (control << 4);
 		pci_read_config_byte(dev, slave_port, &slave_data);
 		slave_data = slave_data & 0xf0;
-		slave_data = slave_data | (((timings[pio][0] << 2) | (timings[pio][1]) << 0));
+		slave_data = slave_data | (timings[pio][0] << 2) | timings[pio][1];
 	} else {
-		master_data = master_data & 0xccf8;
+		master_data &= ~0x3307;
 		if (pio > 1)
-
-			master_data = master_data | 0x0007;
+			master_data = master_data | control;
 		master_data = master_data | (timings[pio][0] << 12) | (timings[pio][1] << 8);
 	}
 	pci_write_config_word(dev, master_port, master_data);
@@ -119,7 +129,6 @@ static void it8213_tuneproc (ide_drive_t
 	spin_unlock_irqrestore(&tune_lock, flags);
 }
 
-
 /**
  *	it8213_tune_chipset	-	set controller timings
  *	@drive: Drive to set up
@@ -130,7 +139,7 @@ static void it8213_tuneproc (ide_drive_t
  *	make the thing work.
  */
 
-static int it8213_tune_chipset (ide_drive_t *drive, byte xferspeed)
+static int it8213_tune_chipset (ide_drive_t *drive, u8 xferspeed)
 {
 
 	ide_hwif_t *hwif	= HWIF(drive);
@@ -154,15 +163,15 @@ static int it8213_tune_chipset (ide_driv
 	switch(speed) {
 		case XFER_UDMA_6:
 		case XFER_UDMA_4:
-		case XFER_UDMA_2:u_speed = 2 << (drive->dn * 4); break;
+		case XFER_UDMA_2:	u_speed = 2 << (drive->dn * 4); break;
 		case XFER_UDMA_5:
 		case XFER_UDMA_3:
-		case XFER_UDMA_1:u_speed = 1 << (drive->dn * 4); break;
-		case XFER_UDMA_0:u_speed = 0 << (drive->dn * 4); break;
+		case XFER_UDMA_1:	u_speed = 1 << (drive->dn * 4); break;
+		case XFER_UDMA_0:	u_speed = 0 << (drive->dn * 4); break;
 			break;
 		case XFER_MW_DMA_2:
 		case XFER_MW_DMA_1:
-		case XFER_MW_DMA_0:
+		case XFER_SW_DMA_2:
 			break;
 		case XFER_PIO_4:
 		case XFER_PIO_3:
@@ -174,8 +183,7 @@ static int it8213_tune_chipset (ide_driv
 			return -1;
 	}
 
-		if (speed >= XFER_UDMA_0)
-		{
+	if (speed >= XFER_UDMA_0) {
 		if (!(reg48 & u_flag))
 			pci_write_config_byte(dev, 0x48, reg48 | u_flag);
 		if (speed >= XFER_UDMA_5) {
@@ -186,14 +194,12 @@ static int it8213_tune_chipset (ide_driv
 
 		if ((reg4a & a_speed) != u_speed)
 			pci_write_config_word(dev, 0x4a, (reg4a & ~a_speed) | u_speed);
-		if (speed > XFER_UDMA_2)
-		{
+		if (speed > XFER_UDMA_2) {
 			if (!(reg54 & v_flag))
 				pci_write_config_byte(dev, 0x54, reg54 | v_flag);
 		} else
 			pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
-		} else /*if(speed >= XFER_UDMA_0)*/
-		{
+	} else {
 		if (reg48 & u_flag)
 			pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
 		if (reg4a & a_speed)
@@ -202,11 +208,10 @@ static int it8213_tune_chipset (ide_driv
 			pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
 		if (reg55 & w_flag)
 			pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
-		}
+	}
 	it8213_tuneproc(drive, it8213_dma_2_pio(speed));
 	return ide_config_drive_speed(drive, speed);
-	}
-
+}
 
 /*
  *	config_chipset_for_dma	-	configure for DMA
@@ -217,48 +222,17 @@ static int it8213_tune_chipset (ide_driv
 
 static int config_chipset_for_dma (ide_drive_t *drive)
 {
-	  u8 speed	= ide_dma_speed(drive, it8213_ratemask(drive));
+	u8 speed = ide_dma_speed(drive, it8213_ratemask(drive));
+
 	if (!speed)
-	{
-		u8 tspeed = ide_get_best_pio_mode(drive, 255, 5, NULL);
-		speed = it8213_dma_2_pio(XFER_PIO_0 + tspeed);
-	}
-//	config_it8213_chipset_for_pio(drive, !speed);
+		return 0;
+
 	it8213_tune_chipset(drive, speed);
+
 	return ide_dma_enable(drive);
 }
 
 /**
- *	config_it8213_chipset_for_pio	-	set drive timings
- *	@drive: drive to tune
- *	@speed we want
- *
- *	Compute the best pio mode we can for a given device. We must
- *	pick a speed that does not cause problems with the other device
- *	on the cable.
- */
-/*
-static void config_it8213_chipset_for_pio (ide_drive_t *drive, byte set_speed)
-{
-	ide_hwif_t *hwif	= HWIF(drive);
-//	u8 unit = drive->select.b.unit;
-	ide_hwif_t *hwif = drive->hwif;
-	ide_drive_t *pair = &hwif->drives[1-unit];
-	u8 speed = 0, set_pio	= ide_get_best_pio_mode(drive, 255, 5, NULL);
-	u8 pair_pio;
-
-	if(pair != NULL) {
-		pair_pio = ide_get_best_pio_mode(pair, 255, 5, NULL);
-		if(pair_pio < set_pio)
-			set_pio = pair_pio;
-	}
-	it8213_tuneproc(drive, set_pio);
-	speed = XFER_PIO_0 + set_pio;
-	if (set_speed)
-		(void) ide_config_drive_speed(drive, speed);
-}
-*/
-/**
  *	it8213_configure_drive_for_dma	-	set up for DMA transfers
  *	@drive: drive we are going to set up
  *
@@ -270,26 +244,19 @@ static void config_it8213_chipset_for_pi
 
 static int it8213_config_drive_for_dma (ide_drive_t *drive)
 {
-//	ide_hwif_t *hwif	= drive->hwif;
-//	struct hd_driveid *id = drive->id;
-	ide_hwif_t *hwif	= HWIF(drive);
+	ide_hwif_t *hwif = drive->hwif;
+
 	if (ide_use_dma(drive)) {
 		if (config_chipset_for_dma(drive))
 			return hwif->ide_dma_on(drive);
 	}
-//	config_it8213_chipset_for_pio(drive, 1);
-	hwif->tuneproc(drive, 255);
- 	return hwif->ide_dma_off_quietly(drive);
-}
 
+	hwif->speedproc(drive, XFER_PIO_0
+			+ ide_get_best_pio_mode(drive, 255, 4, NULL));
 
-static unsigned int __devinit init_chipset_it8213(struct pci_dev *dev, const char *name)
-{
-	printk(KERN_INFO "it8213: controller in IDE mode.\n");
-	return 0;
+ 	return hwif->ide_dma_off_quietly(drive);
 }
 
-
 /**
  *	init_hwif_it8213	-	set up hwif structs
  *	@hwif: interface to set up
@@ -302,9 +269,6 @@ static unsigned int __devinit init_chips
 static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
 {
 	u8 reg42h = 0, ata66 = 0;
-	u8 mask = 0x02;
-
-	hwif->atapi_dma = 1;
 
 	hwif->speedproc = &it8213_tune_chipset;
 	hwif->tuneproc	= &it8213_tuneproc;
@@ -315,19 +279,19 @@ static void __devinit init_hwif_it8213(i
 	hwif->drives[1].autotune = 1;
 
 	if (!hwif->dma_base)
-		goto fallback;
+		return;
+
 	hwif->atapi_dma = 1;
-	hwif->ultra_mask = 0x7f;
-	hwif->mwdma_mask = 0x07;
-	hwif->swdma_mask = 0x07;
+	hwif->ultra_mask = 0x3f;
+	hwif->mwdma_mask = 0x06;
+	hwif->swdma_mask = 0x04;
 
 	pci_read_config_byte(hwif->pci_dev, 0x42, &reg42h);
-	ata66 = (reg42h & mask) ? 0 : 1;
+	ata66 = (reg42h & 0x02) ? 0 : 1;
 
 	hwif->ide_dma_check = &it8213_config_drive_for_dma;
 	if (!(hwif->udma_four))
 		hwif->udma_four = ata66;
-//		hwif->udma_four = 0;
 
 	/*
 	 *	The BIOS often doesn't set up DMA on this controller
@@ -338,20 +302,15 @@ static void __devinit init_hwif_it8213(i
 
 	hwif->drives[0].autodma = hwif->autodma;
 	hwif->drives[1].autodma = hwif->autodma;
-	return;
-fallback:
-	hwif->autodma = 0;
-	return;
 }
 
 
 #define DECLARE_ITE_DEV(name_str)			\
 	{						\
 		.name		= name_str,		\
-		.init_chipset	= init_chipset_it8213,	\
 		.init_hwif	= init_hwif_it8213,	\
 		.channels	= 1,			\
-		.autodma		= AUTODMA,		\
+		.autodma	= AUTODMA,		\
 		.enablebits	= {{0x41,0x80,0x80}}, \
 		.bootable	= ON_BOARD,		\
 	}
@@ -393,10 +352,11 @@ static struct pci_driver driver = {
 
 static int __init it8213_ide_init(void)
 {
-	return ide_pci_register_driver(&driver); }
+	return ide_pci_register_driver(&driver);
+}
 
 module_init(it8213_ide_init);
 
-MODULE_AUTHOR("Jack and Alan Cox");		/* Update this */
+MODULE_AUTHOR("Jack Lee, Alan Cox");
 MODULE_DESCRIPTION("PCI driver module for the ITE 8213");
 MODULE_LICENSE("GPL");

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 4/19] ia64: add pci_get_legacy_ide_irq()
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 3/19] ide: it8213 driver update Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:26 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 5/19] ide: add missing __init tags to IDE PCI host drivers Bartlomiej Zolnierkiewicz
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:26 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ia64: add pci_get_legacy_ide_irq()

Add pci_get_legacy_ide_irq() identical to the one used by i386/x86_64.
Fixes amd74xx driver build on ia64 (bugzilla bug #6644).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 include/asm-ia64/pci.h |    6 ++++++
 1 file changed, 6 insertions(+)

Index: a/include/asm-ia64/pci.h
===================================================================
--- a.orig/include/asm-ia64/pci.h
+++ a/include/asm-ia64/pci.h
@@ -167,4 +167,10 @@ pcibios_select_root(struct pci_dev *pdev
 
 #define pcibios_scan_all_fns(a, b)	0
 
+#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	return channel ? 15 : 14;
+}
+
 #endif /* _ASM_IA64_PCI_H */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 5/19] ide: add missing __init tags to IDE PCI host drivers
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 3/19] ide: it8213 driver update Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 4/19] ia64: add pci_get_legacy_ide_irq() Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:26 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 6/19] pdc202xx_old: remove dead code Bartlomiej Zolnierkiewicz
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:26 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: add missing __init tags to IDE PCI host drivers

also change __devinit tag for sgiioc4.c:ioc4_ide_init() to __init

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/aec62xx.c      |    2 +-
 drivers/ide/pci/alim15x3.c     |    2 +-
 drivers/ide/pci/amd74xx.c      |    2 +-
 drivers/ide/pci/atiixp.c       |    2 +-
 drivers/ide/pci/cmd64x.c       |    2 +-
 drivers/ide/pci/cs5520.c       |    2 +-
 drivers/ide/pci/cs5530.c       |    2 +-
 drivers/ide/pci/cy82c693.c     |    2 +-
 drivers/ide/pci/generic.c      |    2 +-
 drivers/ide/pci/hpt34x.c       |    2 +-
 drivers/ide/pci/hpt366.c       |    2 +-
 drivers/ide/pci/ns87415.c      |    2 +-
 drivers/ide/pci/opti621.c      |    2 +-
 drivers/ide/pci/pdc202xx_new.c |    2 +-
 drivers/ide/pci/pdc202xx_old.c |    2 +-
 drivers/ide/pci/rz1000.c       |    2 +-
 drivers/ide/pci/sc1200.c       |    2 +-
 drivers/ide/pci/serverworks.c  |    2 +-
 drivers/ide/pci/sgiioc4.c      |    3 +--
 drivers/ide/pci/siimage.c      |    2 +-
 drivers/ide/pci/sis5513.c      |    2 +-
 drivers/ide/pci/sl82c105.c     |    2 +-
 drivers/ide/pci/slc90e66.c     |    2 +-
 drivers/ide/pci/tc86c001.c     |    2 +-
 drivers/ide/pci/triflex.c      |    2 +-
 drivers/ide/pci/trm290.c       |    2 +-
 drivers/ide/pci/via82cxxx.c    |    2 +-
 27 files changed, 27 insertions(+), 28 deletions(-)

Index: a/drivers/ide/pci/aec62xx.c
===================================================================
--- a.orig/drivers/ide/pci/aec62xx.c
+++ a/drivers/ide/pci/aec62xx.c
@@ -441,7 +441,7 @@ static struct pci_driver driver = {
 	.probe		= aec62xx_init_one,
 };
 
-static int aec62xx_ide_init(void)
+static int __init aec62xx_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/alim15x3.c
===================================================================
--- a.orig/drivers/ide/pci/alim15x3.c
+++ a/drivers/ide/pci/alim15x3.c
@@ -907,7 +907,7 @@ static struct pci_driver driver = {
 	.probe		= alim15x3_init_one,
 };
 
-static int ali15x3_ide_init(void)
+static int __init ali15x3_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/amd74xx.c
===================================================================
--- a.orig/drivers/ide/pci/amd74xx.c
+++ a/drivers/ide/pci/amd74xx.c
@@ -544,7 +544,7 @@ static struct pci_driver driver = {
 	.probe		= amd74xx_probe,
 };
 
-static int amd74xx_ide_init(void)
+static int __init amd74xx_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/atiixp.c
===================================================================
--- a.orig/drivers/ide/pci/atiixp.c
+++ a/drivers/ide/pci/atiixp.c
@@ -376,7 +376,7 @@ static struct pci_driver driver = {
 	.probe		= atiixp_init_one,
 };
 
-static int atiixp_ide_init(void)
+static int __init atiixp_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/cmd64x.c
===================================================================
--- a.orig/drivers/ide/pci/cmd64x.c
+++ a/drivers/ide/pci/cmd64x.c
@@ -793,7 +793,7 @@ static struct pci_driver driver = {
 	.probe		= cmd64x_init_one,
 };
 
-static int cmd64x_ide_init(void)
+static int __init cmd64x_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/cs5520.c
===================================================================
--- a.orig/drivers/ide/pci/cs5520.c
+++ a/drivers/ide/pci/cs5520.c
@@ -260,7 +260,7 @@ static struct pci_driver driver = {
 	.probe		= cs5520_init_one,
 };
 
-static int cs5520_ide_init(void)
+static int __init cs5520_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/cs5530.c
===================================================================
--- a.orig/drivers/ide/pci/cs5530.c
+++ a/drivers/ide/pci/cs5530.c
@@ -374,7 +374,7 @@ static struct pci_driver driver = {
 	.probe		= cs5530_init_one,
 };
 
-static int cs5530_ide_init(void)
+static int __init cs5530_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/cy82c693.c
===================================================================
--- a.orig/drivers/ide/pci/cy82c693.c
+++ a/drivers/ide/pci/cy82c693.c
@@ -519,7 +519,7 @@ static struct pci_driver driver = {
 	.probe		= cy82c693_init_one,
 };
 
-static int cy82c693_ide_init(void)
+static int __init cy82c693_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/generic.c
===================================================================
--- a.orig/drivers/ide/pci/generic.c
+++ a/drivers/ide/pci/generic.c
@@ -263,7 +263,7 @@ static struct pci_driver driver = {
 	.probe		= generic_init_one,
 };
 
-static int generic_ide_init(void)
+static int __init generic_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/hpt34x.c
===================================================================
--- a.orig/drivers/ide/pci/hpt34x.c
+++ a/drivers/ide/pci/hpt34x.c
@@ -265,7 +265,7 @@ static struct pci_driver driver = {
 	.probe		= hpt34x_init_one,
 };
 
-static int hpt34x_ide_init(void)
+static int __init hpt34x_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/hpt366.c
===================================================================
--- a.orig/drivers/ide/pci/hpt366.c
+++ a/drivers/ide/pci/hpt366.c
@@ -1668,7 +1668,7 @@ static struct pci_driver driver = {
 	.probe		= hpt366_init_one,
 };
 
-static int hpt366_ide_init(void)
+static int __init hpt366_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/ns87415.c
===================================================================
--- a.orig/drivers/ide/pci/ns87415.c
+++ a/drivers/ide/pci/ns87415.c
@@ -302,7 +302,7 @@ static struct pci_driver driver = {
 	.probe		= ns87415_init_one,
 };
 
-static int ns87415_ide_init(void)
+static int __init ns87415_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/opti621.c
===================================================================
--- a.orig/drivers/ide/pci/opti621.c
+++ a/drivers/ide/pci/opti621.c
@@ -382,7 +382,7 @@ static struct pci_driver driver = {
 	.probe		= opti621_init_one,
 };
 
-static int opti621_ide_init(void)
+static int __init opti621_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/pdc202xx_new.c
===================================================================
--- a.orig/drivers/ide/pci/pdc202xx_new.c
+++ a/drivers/ide/pci/pdc202xx_new.c
@@ -716,7 +716,7 @@ static struct pci_driver driver = {
 	.probe		= pdc202new_init_one,
 };
 
-static int pdc202new_ide_init(void)
+static int __init pdc202new_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/pdc202xx_old.c
===================================================================
--- a.orig/drivers/ide/pci/pdc202xx_old.c
+++ a/drivers/ide/pci/pdc202xx_old.c
@@ -704,7 +704,7 @@ static struct pci_driver driver = {
 	.probe		= pdc202xx_init_one,
 };
 
-static int pdc202xx_ide_init(void)
+static int __init pdc202xx_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/rz1000.c
===================================================================
--- a.orig/drivers/ide/pci/rz1000.c
+++ a/drivers/ide/pci/rz1000.c
@@ -77,7 +77,7 @@ static struct pci_driver driver = {
 	.probe		= rz1000_init_one,
 };
 
-static int rz1000_ide_init(void)
+static int __init rz1000_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/sc1200.c
===================================================================
--- a.orig/drivers/ide/pci/sc1200.c
+++ a/drivers/ide/pci/sc1200.c
@@ -507,7 +507,7 @@ static struct pci_driver driver = {
 #endif
 };
 
-static int sc1200_ide_init(void)
+static int __init sc1200_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/serverworks.c
===================================================================
--- a.orig/drivers/ide/pci/serverworks.c
+++ a/drivers/ide/pci/serverworks.c
@@ -666,7 +666,7 @@ static struct pci_driver driver = {
 	.probe		= svwks_init_one,
 };
 
-static int svwks_ide_init(void)
+static int __init svwks_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/sgiioc4.c
===================================================================
--- a.orig/drivers/ide/pci/sgiioc4.c
+++ a/drivers/ide/pci/sgiioc4.c
@@ -762,8 +762,7 @@ static struct ioc4_submodule ioc4_ide_su
 /*	.is_remove = ioc4_ide_remove_one,	*/
 };
 
-static int __devinit
-ioc4_ide_init(void)
+static int __init ioc4_ide_init(void)
 {
 	return ioc4_register_submodule(&ioc4_ide_submodule);
 }
Index: a/drivers/ide/pci/siimage.c
===================================================================
--- a.orig/drivers/ide/pci/siimage.c
+++ a/drivers/ide/pci/siimage.c
@@ -1096,7 +1096,7 @@ static struct pci_driver driver = {
 	.probe		= siimage_init_one,
 };
 
-static int siimage_ide_init(void)
+static int __init siimage_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/sis5513.c
===================================================================
--- a.orig/drivers/ide/pci/sis5513.c
+++ a/drivers/ide/pci/sis5513.c
@@ -968,7 +968,7 @@ static struct pci_driver driver = {
 	.probe		= sis5513_init_one,
 };
 
-static int sis5513_ide_init(void)
+static int __init sis5513_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/sl82c105.c
===================================================================
--- a.orig/drivers/ide/pci/sl82c105.c
+++ a/drivers/ide/pci/sl82c105.c
@@ -492,7 +492,7 @@ static struct pci_driver driver = {
 	.probe		= sl82c105_init_one,
 };
 
-static int sl82c105_ide_init(void)
+static int __init sl82c105_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/slc90e66.c
===================================================================
--- a.orig/drivers/ide/pci/slc90e66.c
+++ a/drivers/ide/pci/slc90e66.c
@@ -266,7 +266,7 @@ static struct pci_driver driver = {
 	.probe		= slc90e66_init_one,
 };
 
-static int slc90e66_ide_init(void)
+static int __init slc90e66_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/tc86c001.c
===================================================================
--- a.orig/drivers/ide/pci/tc86c001.c
+++ a/drivers/ide/pci/tc86c001.c
@@ -298,7 +298,7 @@ static struct pci_driver driver = {
 	.probe		= tc86c001_init_one
 };
 
-static int tc86c001_ide_init(void)
+static int __init tc86c001_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/triflex.c
===================================================================
--- a.orig/drivers/ide/pci/triflex.c
+++ a/drivers/ide/pci/triflex.c
@@ -173,7 +173,7 @@ static struct pci_driver driver = {
 	.probe		= triflex_init_one,
 };
 
-static int triflex_ide_init(void)
+static int __init triflex_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/trm290.c
===================================================================
--- a.orig/drivers/ide/pci/trm290.c
+++ a/drivers/ide/pci/trm290.c
@@ -355,7 +355,7 @@ static struct pci_driver driver = {
 	.probe		= trm290_init_one,
 };
 
-static int trm290_ide_init(void)
+static int __init trm290_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }
Index: a/drivers/ide/pci/via82cxxx.c
===================================================================
--- a.orig/drivers/ide/pci/via82cxxx.c
+++ a/drivers/ide/pci/via82cxxx.c
@@ -514,7 +514,7 @@ static struct pci_driver driver = {
 	.probe 		= via_init_one,
 };
 
-static int via_ide_init(void)
+static int __init via_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
 }

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 6/19] pdc202xx_old: remove dead code
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (2 preceding siblings ...)
  2007-01-12  4:26 ` [PATCH 5/19] ide: add missing __init tags to IDE PCI host drivers Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:26 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 7/19] au1xxx-ide: " Bartlomiej Zolnierkiewicz
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:26 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] pdc202xx_old: remove dead code

CONFIG_PDC202XX_MASTER config option doesn't exist

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/pdc202xx_old.c |   19 -------------------
 1 file changed, 19 deletions(-)

Index: a/drivers/ide/pci/pdc202xx_old.c
===================================================================
--- a.orig/drivers/ide/pci/pdc202xx_old.c
+++ a/drivers/ide/pci/pdc202xx_old.c
@@ -557,25 +557,6 @@ static void __devinit init_dma_pdc202xx(
 			(hwif->INB(dmabase|0x1f)&1) ? "":"IN");
 	}
 #endif /* CONFIG_PDC202XX_BURST */
-#ifdef CONFIG_PDC202XX_MASTER
-	if (!(primary_mode & 1)) {
-		printk(KERN_INFO "%s: FORCING PRIMARY MODE BIT "
-			"0x%02x -> 0x%02x ", hwif->cds->name,
-			primary_mode, (primary_mode|1));
-		hwif->OUTB(primary_mode|1, (dmabase|0x1a));
-		printk("%s\n",
-			(hwif->INB((dmabase|0x1a)) & 1) ? "MASTER" : "PCI");
-	}
-
-	if (!(secondary_mode & 1)) {
-		printk(KERN_INFO "%s: FORCING SECONDARY MODE BIT "
-			"0x%02x -> 0x%02x ", hwif->cds->name,
-			secondary_mode, (secondary_mode|1));
-		hwif->OUTB(secondary_mode|1, (dmabase|0x1b));
-		printk("%s\n",
-			(hwif->INB((dmabase|0x1b)) & 1) ? "MASTER" : "PCI");
-	}
-#endif /* CONFIG_PDC202XX_MASTER */
 
 	ide_setup_dma(hwif, dmabase, 8);
 }

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 7/19] au1xxx-ide: remove dead code
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (3 preceding siblings ...)
  2007-01-12  4:26 ` [PATCH 6/19] pdc202xx_old: remove dead code Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:26 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:26 ` [PATCH 8/19] ide: remove write-only ide_pio_data_t.blacklisted Bartlomiej Zolnierkiewicz
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:26 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] au1xxx-ide: remove dead code

'speed' is always equal to 'mode' when ide_config_drive_speed() is called

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/mips/au1xxx-ide.c |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Index: a/drivers/ide/mips/au1xxx-ide.c
===================================================================
--- a.orig/drivers/ide/mips/au1xxx-ide.c
+++ a/drivers/ide/mips/au1xxx-ide.c
@@ -181,12 +181,6 @@ static int auide_tune_chipset (ide_drive
 {
 	int mem_sttime;
 	int mem_stcfg;
-	unsigned long mode;
-
-#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
-	if (ide_use_dma(drive))
-		mode = ide_dma_speed(drive, 0);
-#endif
 
 	mem_sttime = 0;
 	mem_stcfg  = au_readl(MEM_STCFG2);
@@ -195,7 +189,7 @@ static int auide_tune_chipset (ide_drive
 		auide_tune_drive(drive, speed - XFER_PIO_0);
 		return 0;
 	}
-	      
+
 	switch(speed) {
 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
 	case XFER_MW_DMA_2:
@@ -207,7 +201,6 @@ static int auide_tune_chipset (ide_drive
 		mem_stcfg &= ~TOECS_MASK;
 		mem_stcfg |= SBC_IDE_MDMA2_TCSOE | SBC_IDE_MDMA2_TOECS;
 
-		mode = XFER_MW_DMA_2;
 		break;
 	case XFER_MW_DMA_1:
 		mem_sttime = SBC_IDE_TIMING(MDMA1);
@@ -218,7 +211,6 @@ static int auide_tune_chipset (ide_drive
 		mem_stcfg &= ~TOECS_MASK;
 		mem_stcfg |= SBC_IDE_MDMA1_TCSOE | SBC_IDE_MDMA1_TOECS;
 
-		mode = XFER_MW_DMA_1;
 		break;
 	case XFER_MW_DMA_0:
 		mem_sttime = SBC_IDE_TIMING(MDMA0);
@@ -229,14 +221,13 @@ static int auide_tune_chipset (ide_drive
 		mem_stcfg &= ~TOECS_MASK;
 		mem_stcfg |= SBC_IDE_MDMA0_TCSOE | SBC_IDE_MDMA0_TOECS;
 
-		mode = XFER_MW_DMA_0;
 		break;
 #endif
 	default:
 		return 1;
 	}
-	
-	if (ide_config_drive_speed(drive, mode))
+
+	if (ide_config_drive_speed(drive, speed))
 		return 1;
 
 	au_writel(mem_sttime,MEM_STTIME2);

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 8/19] ide: remove write-only ide_pio_data_t.blacklisted
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (4 preceding siblings ...)
  2007-01-12  4:26 ` [PATCH 7/19] au1xxx-ide: " Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:26 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 9/19] ide: remove write-only ide_hwif_t.no_dsc flag Bartlomiej Zolnierkiewicz
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:26 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: remove write-only ide_pio_data_t.blacklisted

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/ide-lib.c |    3 ---
 include/linux/ide.h   |    1 -
 2 files changed, 4 deletions(-)

Index: a/drivers/ide/ide-lib.c
===================================================================
--- a.orig/drivers/ide/ide-lib.c
+++ a/drivers/ide/ide-lib.c
@@ -349,7 +349,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *d
 	int use_iordy = 0;
 	struct hd_driveid* id = drive->id;
 	int overridden  = 0;
-	int blacklisted = 0;
 
 	if (mode_wanted != 255) {
 		pio_mode = mode_wanted;
@@ -357,7 +356,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *d
 		pio_mode = 0;
 	} else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
 		overridden = 1;
-		blacklisted = 1;
 		use_iordy = (pio_mode > 2);
 	} else {
 		pio_mode = id->tPIO;
@@ -409,7 +407,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *d
 		d->cycle_time = cycle_time ? cycle_time : ide_pio_timings[pio_mode].cycle_time;
 		d->use_iordy = use_iordy;
 		d->overridden = overridden;
-		d->blacklisted = blacklisted;
 	}
 	return pio_mode;
 }
Index: a/include/linux/ide.h
===================================================================
--- a.orig/include/linux/ide.h
+++ a/include/linux/ide.h
@@ -1340,7 +1340,6 @@ typedef struct ide_pio_data_s {
 	u8 pio_mode;
 	u8 use_iordy;
 	u8 overridden;
-	u8 blacklisted;
 	unsigned int cycle_time;
 } ide_pio_data_t;
 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 9/19] ide: remove write-only ide_hwif_t.no_dsc flag
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (5 preceding siblings ...)
  2007-01-12  4:26 ` [PATCH 8/19] ide: remove write-only ide_pio_data_t.blacklisted Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 10/19] trm290: remove redundant CONFIG_BLK_DEV_IDEDMA Bartlomiej Zolnierkiewicz
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: remove write-only ide_hwif_t.no_dsc flag

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/ide-cd.c      |    8 --------
 drivers/ide/ide.c         |    1 -
 drivers/ide/pci/aec62xx.c |    4 +---
 drivers/ide/pci/hpt34x.c  |    1 -
 include/linux/ide.h       |    1 -
 5 files changed, 1 insertion(+), 14 deletions(-)

Index: a/drivers/ide/ide-cd.c
===================================================================
--- a.orig/drivers/ide/ide-cd.c
+++ a/drivers/ide/ide-cd.c
@@ -3247,14 +3247,6 @@ int ide_cdrom_setup (ide_drive_t *drive)
 	if (drive->autotune == IDE_TUNE_DEFAULT ||
 	    drive->autotune == IDE_TUNE_AUTO)
 		drive->dsc_overlap = (drive->next != drive);
-#if 0
-	drive->dsc_overlap = (HWIF(drive)->no_dsc) ? 0 : 1;
-	if (HWIF(drive)->no_dsc) {
-		printk(KERN_INFO "ide-cd: %s: disabling DSC overlap\n",
-			drive->name);
-		drive->dsc_overlap = 0;
-	}
-#endif
 
 	if (ide_cdrom_register(drive, nslots)) {
 		printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
Index: a/drivers/ide/ide.c
===================================================================
--- a.orig/drivers/ide/ide.c
+++ a/drivers/ide/ide.c
@@ -545,7 +545,6 @@ static void ide_hwif_restore(ide_hwif_t 
 	hwif->extra_ports		= tmp_hwif->extra_ports;
 	hwif->autodma			= tmp_hwif->autodma;
 	hwif->udma_four			= tmp_hwif->udma_four;
-	hwif->no_dsc			= tmp_hwif->no_dsc;
 
 	hwif->hwif_data			= tmp_hwif->hwif_data;
 }
Index: a/drivers/ide/pci/aec62xx.c
===================================================================
--- a.orig/drivers/ide/pci/aec62xx.c
+++ a/drivers/ide/pci/aec62xx.c
@@ -286,10 +286,8 @@ static void __devinit init_hwif_aec62xx(
 	hwif->tuneproc = &aec62xx_tune_drive;
 	hwif->speedproc = &aec62xx_tune_chipset;
 
-	if (hwif->pci_dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
+	if (hwif->pci_dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
 		hwif->serialized = hwif->channel;
-		hwif->no_dsc = 1;
-	}
 
 	if (hwif->mate)
 		hwif->mate->serialized = hwif->serialized;
Index: a/drivers/ide/pci/hpt34x.c
===================================================================
--- a.orig/drivers/ide/pci/hpt34x.c
+++ a/drivers/ide/pci/hpt34x.c
@@ -209,7 +209,6 @@ static void __devinit init_hwif_hpt34x(i
 
 	hwif->tuneproc = &hpt34x_tune_drive;
 	hwif->speedproc = &hpt34x_tune_chipset;
-	hwif->no_dsc = 1;
 	hwif->drives[0].autotune = 1;
 	hwif->drives[1].autotune = 1;
 
Index: a/include/linux/ide.h
===================================================================
--- a.orig/include/linux/ide.h
+++ a/include/linux/ide.h
@@ -791,7 +791,6 @@ typedef struct hwif_s {
 	unsigned	udma_four  : 1;	/* 1=ATA-66 capable, 0=default */
 	unsigned	no_lba48   : 1; /* 1 = cannot do LBA48 */
 	unsigned	no_lba48_dma : 1; /* 1 = cannot do LBA48 DMA */
-	unsigned	no_dsc     : 1;	/* 0 default, 1 dsc_overlap disabled */
 	unsigned	auto_poll  : 1; /* supports nop auto-poll */
 	unsigned	sg_mapped  : 1;	/* sg_table and sg_nents are ready */
 	unsigned	no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 10/19] trm290: remove redundant CONFIG_BLK_DEV_IDEDMA
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (6 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 9/19] ide: remove write-only ide_hwif_t.no_dsc flag Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 11/19] ide: remove ide_pci_device_t tables with only one entry Bartlomiej Zolnierkiewicz
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] trm290: remove redundant CONFIG_BLK_DEV_IDEDMA #ifdef-s

In drivers/ide/Kconfig BLK_DEV_TRM290 depends on
BLK_DEV_IDEDMA_PCI (on which is BLK_DEV_IDEDMA dependant on).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/trm290.c |    4 ----
 1 file changed, 4 deletions(-)

Index: a/drivers/ide/pci/trm290.c
===================================================================
--- a.orig/drivers/ide/pci/trm290.c
+++ a/drivers/ide/pci/trm290.c
@@ -177,7 +177,6 @@ static void trm290_selectproc (ide_drive
 	trm290_prepare_drive(drive, drive->using_dma);
 }
 
-#ifdef CONFIG_BLK_DEV_IDEDMA
 static void trm290_ide_dma_exec_cmd(ide_drive_t *drive, u8 command)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
@@ -242,7 +241,6 @@ static int trm290_ide_dma_test_irq (ide_
 	status = hwif->INW(hwif->dma_status);
 	return (status == 0x00ff);
 }
-#endif /* CONFIG_BLK_DEV_IDEDMA */
 
 /*
  * Invoked from ide-dma.c at boot time.
@@ -289,13 +287,11 @@ static void __devinit init_hwif_trm290(i
 
 	ide_setup_dma(hwif, (hwif->config_data + 4) ^ (hwif->channel ? 0x0080 : 0x0000), 3);
 
-#ifdef CONFIG_BLK_DEV_IDEDMA
 	hwif->dma_setup = &trm290_ide_dma_setup;
 	hwif->dma_exec_cmd = &trm290_ide_dma_exec_cmd;
 	hwif->dma_start = &trm290_ide_dma_start;
 	hwif->ide_dma_end = &trm290_ide_dma_end;
 	hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq;
-#endif /* CONFIG_BLK_DEV_IDEDMA */
 
 	hwif->selectproc = &trm290_selectproc;
 	hwif->autodma = 0;		/* play it safe for now */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 11/19] ide: remove ide_pci_device_t tables with only one entry
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (7 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 10/19] trm290: remove redundant CONFIG_BLK_DEV_IDEDMA Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 12/19] ide: remove ide_drive_t.usage Bartlomiej Zolnierkiewicz
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: remove ide_pci_device_t tables with only one entry

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/cy82c693.c |   21 +++++++++------------
 drivers/ide/pci/sgiioc4.c  |    7 ++-----
 2 files changed, 11 insertions(+), 17 deletions(-)

Index: a/drivers/ide/pci/cy82c693.c
===================================================================
--- a.orig/drivers/ide/pci/cy82c693.c
+++ a/drivers/ide/pci/cy82c693.c
@@ -478,21 +478,18 @@ static void __devinit init_iops_cy82c693
 	}
 }
 
-static ide_pci_device_t cy82c693_chipsets[] __devinitdata = {
-	{	/* 0 */
-		.name		= "CY82C693",
-		.init_chipset	= init_chipset_cy82c693,
-		.init_iops	= init_iops_cy82c693,
-		.init_hwif	= init_hwif_cy82c693,
-		.channels	= 1,
-		.autodma	= AUTODMA,
-		.bootable	= ON_BOARD,
-	}
+static ide_pci_device_t cy82c693_chipset __devinitdata = {
+	.name		= "CY82C693",
+	.init_chipset	= init_chipset_cy82c693,
+	.init_iops	= init_iops_cy82c693,
+	.init_hwif	= init_hwif_cy82c693,
+	.channels	= 1,
+	.autodma	= AUTODMA,
+	.bootable	= ON_BOARD,
 };
 
 static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_pci_device_t *d = &cy82c693_chipsets[id->driver_data];
 	struct pci_dev *dev2;
 	int ret = -ENODEV;
 
@@ -501,7 +498,7 @@ static int __devinit cy82c693_init_one(s
         if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE &&
 	    PCI_FUNC(dev->devfn) == 1) {
 		dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
-		ret = ide_setup_pci_devices(dev, dev2, d);
+		ret = ide_setup_pci_devices(dev, dev2, &cy82c693_chipset);
 		/* We leak pci refs here but thats ok - we can't be unloaded */
 	}
 	return ret;
Index: a/drivers/ide/pci/sgiioc4.c
===================================================================
--- a.orig/drivers/ide/pci/sgiioc4.c
+++ a/drivers/ide/pci/sgiioc4.c
@@ -729,8 +729,7 @@ out:
 	return ret;
 }
 
-static ide_pci_device_t sgiioc4_chipsets[] __devinitdata = {
-	{
+static ide_pci_device_t sgiioc4_chipset __devinitdata = {
 	 /* Channel 0 */
 	 .name = "SGIIOC4",
 	 .init_hwif = ide_init_sgiioc4,
@@ -739,7 +738,6 @@ static ide_pci_device_t sgiioc4_chipsets
 	 .autodma = AUTODMA,
 	 /* SGI IOC4 doesn't have enablebits. */
 	 .bootable = ON_BOARD,
-	}
 };
 
 int
@@ -751,8 +749,7 @@ ioc4_ide_attach_one(struct ioc4_driver_d
 	if (idd->idd_variant == IOC4_VARIANT_PCI_RT)
 		return 0;
 
-	return pci_init_sgiioc4(idd->idd_pdev,
-				&sgiioc4_chipsets[idd->idd_pci_id->driver_data]);
+	return pci_init_sgiioc4(idd->idd_pdev, &sgiioc4_chipset);
 }
 
 static struct ioc4_submodule ioc4_ide_submodule = {

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 12/19] ide: remove ide_drive_t.usage
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (8 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 11/19] ide: remove ide_pci_device_t tables with only one entry Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 13/19] hpt366: remove redundant check from init_dma_hpt366() Bartlomiej Zolnierkiewicz
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: remove ide_drive_t.usage

This field is no longer used by the core IDE code so fix ide-{disk,floppy}
drivers to keep openers count in the driver specific objects and remove
it from ide-{cd,scsi,tape} drivers (it was write-only).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/ide-cd.c     |   15 ++++-----------
 drivers/ide/ide-disk.c   |   14 +++++++++-----
 drivers/ide/ide-floppy.c |   18 +++++++++---------
 drivers/ide/ide-tape.c   |    8 --------
 drivers/scsi/ide-scsi.c  |    8 --------
 include/linux/ide.h      |    1 -
 6 files changed, 22 insertions(+), 42 deletions(-)

Index: a/drivers/ide/ide-cd.c
===================================================================
--- a.orig/drivers/ide/ide-cd.c
+++ a/drivers/ide/ide-cd.c
@@ -3345,21 +3345,16 @@ static int idecd_open(struct inode * ino
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct cdrom_info *info;
-	ide_drive_t *drive;
 	int rc = -ENOMEM;
 
 	if (!(info = ide_cd_get(disk)))
 		return -ENXIO;
 
-	drive = info->drive;
-
-	drive->usage++;
-
 	if (!info->buffer)
-		info->buffer = kmalloc(SECTOR_BUFFER_SIZE,
-					GFP_KERNEL|__GFP_REPEAT);
-        if (!info->buffer || (rc = cdrom_open(&info->devinfo, inode, file)))
-		drive->usage--;
+		info->buffer = kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL|__GFP_REPEAT);
+
+	if (info->buffer)
+		rc = cdrom_open(&info->devinfo, inode, file);
 
 	if (rc < 0)
 		ide_cd_put(info);
@@ -3371,10 +3366,8 @@ static int idecd_release(struct inode * 
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct cdrom_info *info = ide_cd_g(disk);
-	ide_drive_t *drive = info->drive;
 
 	cdrom_release (&info->devinfo, file);
-	drive->usage--;
 
 	ide_cd_put(info);
 
Index: a/drivers/ide/ide-disk.c
===================================================================
--- a.orig/drivers/ide/ide-disk.c
+++ a/drivers/ide/ide-disk.c
@@ -77,6 +77,7 @@ struct ide_disk_obj {
 	ide_driver_t	*driver;
 	struct gendisk	*disk;
 	struct kref	kref;
+	unsigned int	openers;	/* protected by BKL for now */
 };
 
 static DEFINE_MUTEX(idedisk_ref_mutex);
@@ -1081,8 +1082,9 @@ static int idedisk_open(struct inode *in
 
 	drive = idkp->drive;
 
-	drive->usage++;
-	if (drive->removable && drive->usage == 1) {
+	idkp->openers++;
+
+	if (drive->removable && idkp->openers == 1) {
 		ide_task_t args;
 		memset(&args, 0, sizeof(ide_task_t));
 		args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK;
@@ -1106,9 +1108,10 @@ static int idedisk_release(struct inode 
 	struct ide_disk_obj *idkp = ide_disk_g(disk);
 	ide_drive_t *drive = idkp->drive;
 
-	if (drive->usage == 1)
+	if (idkp->openers == 1)
 		ide_cacheflush_p(drive);
-	if (drive->removable && drive->usage == 1) {
+
+	if (drive->removable && idkp->openers == 1) {
 		ide_task_t args;
 		memset(&args, 0, sizeof(ide_task_t));
 		args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORUNLOCK;
@@ -1117,7 +1120,8 @@ static int idedisk_release(struct inode 
 		if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
 			drive->doorlocking = 0;
 	}
-	drive->usage--;
+
+	idkp->openers--;
 
 	ide_disk_put(idkp);
 
Index: a/drivers/ide/ide-floppy.c
===================================================================
--- a.orig/drivers/ide/ide-floppy.c
+++ a/drivers/ide/ide-floppy.c
@@ -279,6 +279,7 @@ typedef struct ide_floppy_obj {
 	ide_driver_t	*driver;
 	struct gendisk	*disk;
 	struct kref	kref;
+	unsigned int	openers;	/* protected by BKL for now */
 
 	/* Current packet command */
 	idefloppy_pc_t *pc;
@@ -1949,9 +1950,9 @@ static int idefloppy_open(struct inode *
 
 	drive = floppy->drive;
 
-	drive->usage++;
+	floppy->openers++;
 
-	if (drive->usage == 1) {
+	if (floppy->openers == 1) {
 		clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
 		/* Just in case */
 
@@ -1969,13 +1970,11 @@ static int idefloppy_open(struct inode *
 		    ** capacity of the drive or begin the format - Sam
 		    */
 		    ) {
-			drive->usage--;
 			ret = -EIO;
 			goto out_put_floppy;
 		}
 
 		if (floppy->wp && (filp->f_mode & 2)) {
-			drive->usage--;
 			ret = -EROFS;
 			goto out_put_floppy;
 		}
@@ -1987,13 +1986,13 @@ static int idefloppy_open(struct inode *
 		}
 		check_disk_change(inode->i_bdev);
 	} else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) {
-		drive->usage--;
 		ret = -EBUSY;
 		goto out_put_floppy;
 	}
 	return 0;
 
 out_put_floppy:
+	floppy->openers--;
 	ide_floppy_put(floppy);
 	return ret;
 }
@@ -2007,7 +2006,7 @@ static int idefloppy_release(struct inod
 	
 	debug_log(KERN_INFO "Reached idefloppy_release\n");
 
-	if (drive->usage == 1) {
+	if (floppy->openers == 1) {
 		/* IOMEGA Clik! drives do not support lock/unlock commands */
                 if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
 			idefloppy_create_prevent_cmd(&pc, 0);
@@ -2016,7 +2015,8 @@ static int idefloppy_release(struct inod
 
 		clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
 	}
-	drive->usage--;
+
+	floppy->openers--;
 
 	ide_floppy_put(floppy);
 
@@ -2050,7 +2050,7 @@ static int idefloppy_ioctl(struct inode 
 		prevent = 0;
 		/* fall through */
 	case CDROM_LOCKDOOR:
-		if (drive->usage > 1)
+		if (floppy->openers > 1)
 			return -EBUSY;
 
 		/* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */
@@ -2072,7 +2072,7 @@ static int idefloppy_ioctl(struct inode 
 		if (!(file->f_mode & 2))
 			return -EPERM;
 
-		if (drive->usage > 1) {
+		if (floppy->openers > 1) {
 			/* Don't format if someone is using the disk */
 
 			clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS,
Index: a/drivers/ide/ide-tape.c
===================================================================
--- a.orig/drivers/ide/ide-tape.c
+++ a/drivers/ide/ide-tape.c
@@ -4792,15 +4792,10 @@ static int idetape_open(struct inode *in
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_tape_obj *tape;
-	ide_drive_t *drive;
 
 	if (!(tape = ide_tape_get(disk)))
 		return -ENXIO;
 
-	drive = tape->drive;
-
-	drive->usage++;
-
 	return 0;
 }
 
@@ -4808,9 +4803,6 @@ static int idetape_release(struct inode 
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_tape_obj *tape = ide_tape_g(disk);
-	ide_drive_t *drive = tape->drive;
-
-	drive->usage--;
 
 	ide_tape_put(tape);
 
Index: a/drivers/scsi/ide-scsi.c
===================================================================
--- a.orig/drivers/scsi/ide-scsi.c
+++ a/drivers/scsi/ide-scsi.c
@@ -801,15 +801,10 @@ static int idescsi_ide_open(struct inode
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_scsi_obj *scsi;
-	ide_drive_t *drive;
 
 	if (!(scsi = ide_scsi_get(disk)))
 		return -ENXIO;
 
-	drive = scsi->drive;
-
-	drive->usage++;
-
 	return 0;
 }
 
@@ -817,9 +812,6 @@ static int idescsi_ide_release(struct in
 {
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_scsi_obj *scsi = ide_scsi_g(disk);
-	ide_drive_t *drive = scsi->drive;
-
-	drive->usage--;
 
 	ide_scsi_put(scsi);
 
Index: a/include/linux/ide.h
===================================================================
--- a.orig/include/linux/ide.h
+++ a/include/linux/ide.h
@@ -628,7 +628,6 @@ typedef struct ide_drive_s {
 	unsigned int	bios_cyl;	/* BIOS/fdisk/LILO number of cyls */
 	unsigned int	cyl;		/* "real" number of cyls */
 	unsigned int	drive_data;	/* use by tuneproc/selectproc */
-	unsigned int	usage;		/* current "open()" count for drive */
 	unsigned int	failures;	/* current failure count */
 	unsigned int	max_failures;	/* maximum allowed failure count */
 	u64		probed_capacity;/* initial reported media capacity (ide-cd only currently) */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 13/19] hpt366: remove redundant check from init_dma_hpt366()
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (9 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 12/19] ide: remove ide_drive_t.usage Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 14/19] cs5530: small cleanup Bartlomiej Zolnierkiewicz
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] hpt366: remove redundant check from init_dma_hpt366()

->init_dma() cannot be called with dmabase == 0
(see drivers/ide/setup-pci.c)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/hpt366.c |    3 ---
 1 file changed, 3 deletions(-)

Index: a/drivers/ide/pci/hpt366.c
===================================================================
--- a.orig/drivers/ide/pci/hpt366.c
+++ a/drivers/ide/pci/hpt366.c
@@ -1391,9 +1391,6 @@ static void __devinit init_dma_hpt366(id
 	u8 dma_new	= 0, dma_old	= 0;
 	unsigned long flags;
 
-	if (!dmabase)
-		return;
-		
 	dma_old = hwif->INB(dmabase + 2);
 
 	local_irq_save(flags);

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 14/19] cs5530: small cleanup
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (10 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 13/19] hpt366: remove redundant check from init_dma_hpt366() Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 15/19] svwks: " Bartlomiej Zolnierkiewicz
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] cs5530: small cleanup

* BUG() on unknown DMA mode in cs5530_config_dma()
* there is no need to call hwif->ide_dma_host_{off,on}() in
  cs5530_config_dma() because hwif->ide_dma_host_{off,on}()
  is called by hwif->ide_dma_off_{quietly,on}()

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/cs5530.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Index: a/drivers/ide/pci/cs5530.c
===================================================================
--- a.orig/drivers/ide/pci/cs5530.c
+++ a/drivers/ide/pci/cs5530.c
@@ -103,16 +103,13 @@ static int cs5530_config_dma (ide_drive_
 	int			unit = drive->select.b.unit;
 	ide_drive_t		*mate = &hwif->drives[unit^1];
 	struct hd_driveid	*id = drive->id;
-	unsigned int		reg, timings;
+	unsigned int		reg, timings = 0;
 	unsigned long		basereg;
 
 	/*
 	 * Default to DMA-off in case we run into trouble here.
 	 */
 	hwif->ide_dma_off_quietly(drive);
-	/* turn off DMA while we fiddle */
-	hwif->ide_dma_host_off(drive);
-	/* clear DMA_capable bit */
 
 	/*
 	 * The CS5530 specifies that two drives sharing a cable cannot
@@ -182,9 +179,8 @@ static int cs5530_config_dma (ide_drive_
 		case XFER_MW_DMA_1:	timings = 0x00012121; break;
 		case XFER_MW_DMA_2:	timings = 0x00002020; break;
 		default:
-			printk(KERN_ERR "%s: cs5530_config_dma: huh? mode=%02x\n",
-				drive->name, mode);
-			return 1;	/* failure */
+			BUG();
+			break;
 	}
 	basereg = CS5530_BASEREG(hwif);
 	reg = hwif->INL(basereg+4);		/* get drive0 config register */
@@ -199,8 +195,6 @@ static int cs5530_config_dma (ide_drive_
 		hwif->OUTL(reg,     basereg+4);	/* write drive0 config register */
 		hwif->OUTL(timings, basereg+12);	/* write drive1 config register */
 	}
-	(void) hwif->ide_dma_host_on(drive);
-	/* set DMA_capable bit */
 
 	/*
 	 * Finally, turn DMA on in software, and exit.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 15/19] svwks: small cleanup
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (11 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 14/19] cs5530: small cleanup Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 16/19] sis5513: sis5513_config_xfer_rate() cleanup Bartlomiej Zolnierkiewicz
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] svwks: small cleanup

* remove redundant svwks_ide_dma_end() [ __ide_dma_end() is used by default ]
* remove init_dma_svwks() so the default ide_setup_dma() function is used
  [ init_setup_csb6() takes care of not initializing disabled channels ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/serverworks.c |   34 ++++------------------------------
 1 file changed, 4 insertions(+), 30 deletions(-)

Index: a/drivers/ide/pci/serverworks.c
===================================================================
--- a.orig/drivers/ide/pci/serverworks.c
+++ a/drivers/ide/pci/serverworks.c
@@ -339,13 +339,6 @@ fast_ata_pio:
 	return 0;
 }
 
-/* This can go soon */
-
-static int svwks_ide_dma_end (ide_drive_t *drive)
-{
-	return __ide_dma_end(drive);
-}
-
 static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const char *name)
 {
 	unsigned int reg;
@@ -537,10 +530,10 @@ static void __devinit init_hwif_svwks (i
 	}
 
 	hwif->ide_dma_check = &svwks_config_drive_xfer_rate;
-	if (hwif->pci_dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE)
-		hwif->ide_dma_end = &svwks_ide_dma_end;
-	else if (!(hwif->udma_four))
-		hwif->udma_four = ata66_svwks(hwif);
+	if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
+		if (!hwif->udma_four)
+			hwif->udma_four = ata66_svwks(hwif);
+	}
 	if (!noautodma)
 		hwif->autodma = 1;
 
@@ -551,21 +544,6 @@ static void __devinit init_hwif_svwks (i
 	hwif->drives[1].autotune = (!(dma_stat & 0x40));
 }
 
-/*
- * We allow the BM-DMA driver to only work on enabled interfaces.
- */
-static void __devinit init_dma_svwks (ide_hwif_t *hwif, unsigned long dmabase)
-{
-	struct pci_dev *dev = hwif->pci_dev;
-
-	if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
-	     (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) &&
-	    (!(PCI_FUNC(dev->devfn) & 1)) && (hwif->channel))
-		return;
-
-	ide_setup_dma(hwif, dmabase, 8);
-}
-
 static int __devinit init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d)
 {
 	return ide_setup_pci_device(dev, d);
@@ -600,7 +578,6 @@ static ide_pci_device_t serverworks_chip
 		.init_setup	= init_setup_svwks,
 		.init_chipset	= init_chipset_svwks,
 		.init_hwif	= init_hwif_svwks,
-		.init_dma	= init_dma_svwks,
 		.channels	= 2,
 		.autodma	= AUTODMA,
 		.bootable	= ON_BOARD,
@@ -609,7 +586,6 @@ static ide_pci_device_t serverworks_chip
 		.init_setup	= init_setup_csb6,
 		.init_chipset	= init_chipset_svwks,
 		.init_hwif	= init_hwif_svwks,
-		.init_dma	= init_dma_svwks,
 		.channels	= 2,
 		.autodma	= AUTODMA,
 		.bootable	= ON_BOARD,
@@ -618,7 +594,6 @@ static ide_pci_device_t serverworks_chip
 		.init_setup	= init_setup_csb6,
 		.init_chipset	= init_chipset_svwks,
 		.init_hwif	= init_hwif_svwks,
-		.init_dma	= init_dma_svwks,
 		.channels	= 1,	/* 2 */
 		.autodma	= AUTODMA,
 		.bootable	= ON_BOARD,
@@ -627,7 +602,6 @@ static ide_pci_device_t serverworks_chip
 		.init_setup	= init_setup_svwks,
 		.init_chipset	= init_chipset_svwks,
 		.init_hwif	= init_hwif_svwks,
-		.init_dma	= init_dma_svwks,
 		.channels	= 1,	/* 2 */
 		.autodma	= AUTODMA,
 		.bootable	= ON_BOARD,

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 16/19] sis5513: sis5513_config_xfer_rate() cleanup
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (12 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 15/19] svwks: " Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:27 ` [PATCH 17/19] ide: unexport ide_set_xfer_rate() Bartlomiej Zolnierkiewicz
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] sis5513: sis5513_config_xfer_rate() cleanup

* remove bogus comment for sis5513_config_xfer_rate()
* there is no need to call config_drive_art_rwp() because
  it is called by config_art_rwp_pio()
* remove needless wrapper
* remove stale "TODO" comment
  (IDE core should provide generic tuning code)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/pci/sis5513.c |   41 +++--------------------------------------
 1 file changed, 3 insertions(+), 38 deletions(-)

Index: a/drivers/ide/pci/sis5513.c
===================================================================
--- a.orig/drivers/ide/pci/sis5513.c
+++ a/drivers/ide/pci/sis5513.c
@@ -667,11 +667,13 @@ static int config_chipset_for_dma (ide_d
 	return ide_dma_enable(drive);
 }
 
-static int sis5513_config_drive_xfer_rate (ide_drive_t *drive)
+static int sis5513_config_xfer_rate(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct hd_driveid *id	= drive->id;
 
+	config_art_rwp_pio(drive, 5);
+
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
@@ -692,43 +694,6 @@ fast_ata_pio:
 	return 0;
 }
 
-/* initiates/aborts (U)DMA read/write operations on a drive. */
-static int sis5513_config_xfer_rate (ide_drive_t *drive)
-{
-	config_drive_art_rwp(drive);
-	config_art_rwp_pio(drive, 5);
-	return sis5513_config_drive_xfer_rate(drive);
-}
-
-/*
-  Future simpler config_xfer_rate :
-   When ide_find_best_mode is made bad-drive aware
-   - remove config_drive_xfer_rate and config_chipset_for_dma,
-   - replace config_xfer_rate with the following
-
-static int sis5513_config_xfer_rate (ide_drive_t *drive)
-{
-	u16 w80 = HWIF(drive)->udma_four;
-	u16 speed;
-
-	config_drive_art_rwp(drive);
-	config_art_rwp_pio(drive, 5);
-
-	speed = ide_find_best_mode(drive,
-		XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA |
-		(chipset_family >= ATA_33 ? XFER_UDMA : 0) |
-		(w80 && chipset_family >= ATA_66 ? XFER_UDMA_66 : 0) |
-		(w80 && chipset_family >= ATA_100a ? XFER_UDMA_100 : 0) |
-		(w80 && chipset_family >= ATA_133a ? XFER_UDMA_133 : 0));
-
-	sis5513_tune_chipset(drive, speed);
-
-	if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
-		return HWIF(drive)->ide_dma_on(drive);
-	return HWIF(drive)->ide_dma_off_quietly(drive);
-}
-*/
-
 /* Chip detection and general config */
 static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const char *name)
 {

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 17/19] ide: unexport ide_set_xfer_rate()
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (13 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 16/19] sis5513: sis5513_config_xfer_rate() cleanup Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:27 ` Bartlomiej Zolnierkiewicz
  2007-01-12  4:28 ` [PATCH 18/19] ide: add ide_use_fast_pio() helper Bartlomiej Zolnierkiewicz
  2007-01-12  4:28 ` [PATCH 19/19] ide: use PIO/MMIO operations directly where possible Bartlomiej Zolnierkiewicz
  16 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:27 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: unexport ide_set_xfer_rate()

In cmd64x and siimage drivers:
* don't set drive->init_speed as it should be already
  set by successful execution of ide_set_xfer_rate()
* use hwif->speedproc functions directly

Above changes allows removal of EXPORT_SYMBOL_GPL(ide_set_xfer_rate).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/ide-lib.c     |    2 --
 drivers/ide/pci/cmd64x.c  |    7 ++-----
 drivers/ide/pci/siimage.c |    5 +----
 3 files changed, 3 insertions(+), 11 deletions(-)

Index: a/drivers/ide/ide-lib.c
===================================================================
--- a.orig/drivers/ide/ide-lib.c
+++ a/drivers/ide/ide-lib.c
@@ -459,8 +459,6 @@ int ide_set_xfer_rate(ide_drive_t *drive
 		return -1;
 }
 
-EXPORT_SYMBOL_GPL(ide_set_xfer_rate);
-
 static void ide_dump_opcode(ide_drive_t *drive)
 {
 	struct request *rq;
Index: a/drivers/ide/pci/cmd64x.c
===================================================================
--- a.orig/drivers/ide/pci/cmd64x.c
+++ a/drivers/ide/pci/cmd64x.c
@@ -466,11 +466,8 @@ static int config_chipset_for_dma (ide_d
 	if (!speed)
 		return 0;
 
-	if(ide_set_xfer_rate(drive, speed))
-		return 0; 
-
-	if (!drive->init_speed)
-		drive->init_speed = speed;
+	if (cmd64x_tune_chipset(drive, speed))
+		return 0;
 
 	return ide_dma_enable(drive);
 }
Index: a/drivers/ide/pci/siimage.c
===================================================================
--- a.orig/drivers/ide/pci/siimage.c
+++ a/drivers/ide/pci/siimage.c
@@ -397,12 +397,9 @@ static int config_chipset_for_dma (ide_d
 	if (!speed)
 		return 0;
 
-	if (ide_set_xfer_rate(drive, speed))
+	if (siimage_tune_chipset(drive, speed))
 		return 0;
 
-	if (!drive->init_speed)
-		drive->init_speed = speed;
-
 	return ide_dma_enable(drive);
 }
 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 18/19] ide: add ide_use_fast_pio() helper
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (14 preceding siblings ...)
  2007-01-12  4:27 ` [PATCH 17/19] ide: unexport ide_set_xfer_rate() Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:28 ` Bartlomiej Zolnierkiewicz
  2007-01-12 10:08   ` Alan
  2007-01-12  4:28 ` [PATCH 19/19] ide: use PIO/MMIO operations directly where possible Bartlomiej Zolnierkiewicz
  16 siblings, 1 reply; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:28 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: add ide_use_fast_pio() helper

* add ide_use_fast_pio() helper for use by host drivers
* add DMA capability and autodma checks to ide_use_dma()
  - au1xxx-ide/it8213/it821x drivers didn't check for (id->capability & 1)
  - ide-cris driver didn't set ->autodma

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/cris/ide-cris.c    |   12 +++++-------
 drivers/ide/ide-dma.c          |    3 +++
 drivers/ide/ide-lib.c          |   15 +++++++++++++++
 drivers/ide/pci/aec62xx.c      |   14 +++-----------
 drivers/ide/pci/atiixp.c       |   14 +++-----------
 drivers/ide/pci/cmd64x.c       |   14 +++-----------
 drivers/ide/pci/cs5535.c       |   13 +++----------
 drivers/ide/pci/hpt34x.c       |   16 ++++------------
 drivers/ide/pci/hpt366.c       |   11 +++--------
 drivers/ide/pci/pdc202xx_new.c |   12 +++---------
 drivers/ide/pci/pdc202xx_old.c |   14 +++-----------
 drivers/ide/pci/piix.c         |   12 +++---------
 drivers/ide/pci/serverworks.c  |   14 +++-----------
 drivers/ide/pci/siimage.c      |   14 +++-----------
 drivers/ide/pci/sis5513.c      |   14 +++-----------
 drivers/ide/pci/slc90e66.c     |   12 +++---------
 drivers/ide/pci/tc86c001.c     |   12 +++---------
 drivers/ide/pci/triflex.c      |    9 ++-------
 include/linux/ide.h            |    1 +
 19 files changed, 69 insertions(+), 157 deletions(-)

Index: a/drivers/ide/cris/ide-cris.c
===================================================================
--- a.orig/drivers/ide/cris/ide-cris.c
+++ a/drivers/ide/cris/ide-cris.c
@@ -821,6 +821,9 @@ init_e100_ide (void)
 		hwif->ultra_mask = cris_ultra_mask;
 		hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
 		hwif->swdma_mask = 0x07; /* Singleword DMA 0-2 */
+		hwif->autodma = 1;
+		hwif->drives[0].autodma = 1;
+		hwif->drives[1].autodma = 1;
 	}
 
 	/* Reset pulse */
@@ -1046,14 +1049,9 @@ static ide_startstop_t cris_dma_intr (id
 static int cris_dma_check(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = drive->hwif;
-	struct hd_driveid* id = drive->id;
 
-	if (id && (id->capability & 1)) {
-		if (ide_use_dma(drive)) {
-			if (cris_config_drive_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-	}
+	if (ide_use_dma(drive) && cris_config_drive_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
 	return hwif->ide_dma_off_quietly(drive);
 }
Index: a/drivers/ide/ide-dma.c
===================================================================
--- a.orig/drivers/ide/ide-dma.c
+++ a/drivers/ide/ide-dma.c
@@ -680,6 +680,9 @@ int ide_use_dma(ide_drive_t *drive)
 	struct hd_driveid *id = drive->id;
 	ide_hwif_t *hwif = drive->hwif;
 
+	if ((id->capability & 1) == 0 || drive->autodma == 0)
+		return 0;
+
 	/* consult the list of known "bad" drives */
 	if (__ide_dma_bad_drive(drive))
 		return 0;
Index: a/drivers/ide/ide-lib.c
===================================================================
--- a.orig/drivers/ide/ide-lib.c
+++ a/drivers/ide/ide-lib.c
@@ -205,6 +205,21 @@ int ide_dma_enable (ide_drive_t *drive)
 
 EXPORT_SYMBOL(ide_dma_enable);
 
+int ide_use_fast_pio(ide_drive_t *drive)
+{
+	struct hd_driveid *id = drive->id;
+
+	if ((id->capability & 1) && drive->autodma)
+		return 1;
+
+	if ((id->capability & 8) || (id->field_valid & 2))
+		return 1;
+
+	return 0;
+}
+
+EXPORT_SYMBOL_GPL(ide_use_fast_pio);
+
 /*
  * Standard (generic) timings for PIO modes, from ATA2 specification.
  * These timings are for access to the IDE data port register *only*.
Index: a/drivers/ide/pci/aec62xx.c
===================================================================
--- a.orig/drivers/ide/pci/aec62xx.c
+++ a/drivers/ide/pci/aec62xx.c
@@ -210,19 +210,11 @@ static void aec62xx_tune_drive (ide_driv
 static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive)) {
-			if (config_chipset_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		aec62xx_tune_drive(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/atiixp.c
===================================================================
--- a.orig/drivers/ide/pci/atiixp.c
+++ a/drivers/ide/pci/atiixp.c
@@ -256,22 +256,14 @@ static int atiixp_config_drive_for_dma(i
 static int atiixp_dma_check(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 	u8 tspeed, speed;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && atiixp_config_drive_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive)) {
-			if (atiixp_config_drive_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		tspeed = ide_get_best_pio_mode(drive, 255, 5, NULL);
 		speed = atiixp_dma_2_pio(XFER_PIO_0 + tspeed) + XFER_PIO_0;
 		hwif->speedproc(drive, speed);
Index: a/drivers/ide/pci/cmd64x.c
===================================================================
--- a.orig/drivers/ide/pci/cmd64x.c
+++ a/drivers/ide/pci/cmd64x.c
@@ -475,19 +475,11 @@ static int config_chipset_for_dma (ide_d
 static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
-	if ((id != NULL) && ((id->capability & 1) != 0) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive)) {
-			if (config_chipset_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		config_chipset_for_pio(drive, 1);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/cs5535.c
===================================================================
--- a.orig/drivers/ide/pci/cs5535.c
+++ a/drivers/ide/pci/cs5535.c
@@ -196,21 +196,14 @@ static int cs5535_config_drive_for_dma(i
 static int cs5535_dma_check(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= drive->hwif;
-	struct hd_driveid *id	= drive->id;
 	u8 speed;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
-		if (ide_use_dma(drive)) {
-			if (cs5535_config_drive_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
+	if (ide_use_dma(drive) && cs5535_config_drive_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		speed = ide_get_best_pio_mode(drive, 255, 4, NULL);
 		cs5535_set_drive(drive, speed);
 		return hwif->ide_dma_off_quietly(drive);
Index: a/drivers/ide/pci/hpt34x.c
===================================================================
--- a.orig/drivers/ide/pci/hpt34x.c
+++ a/drivers/ide/pci/hpt34x.c
@@ -125,25 +125,17 @@ static int config_chipset_for_dma (ide_d
 static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if (id && (id->capability & 1) && drive->autodma) {
-
-		if (ide_use_dma(drive)) {
-			if (config_chipset_for_dma(drive))
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
 #ifndef CONFIG_HPT34X_AUTODMA
-				return hwif->ide_dma_off_quietly(drive);
+		return hwif->ide_dma_off_quietly(drive);
 #else
-				return hwif->ide_dma_on(drive);
+		return hwif->ide_dma_on(drive);
 #endif
-		}
-
-		goto fast_ata_pio;
 
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		hpt34x_tune_drive(drive, 255);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/hpt366.c
===================================================================
--- a.orig/drivers/ide/pci/hpt366.c
+++ a/drivers/ide/pci/hpt366.c
@@ -737,18 +737,13 @@ static void hpt3xx_maskproc(ide_drive_t 
 static int hpt366_config_drive_xfer_rate(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
-		if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-			return hwif->ide_dma_on(drive);
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		hpt3xx_tune_drive(drive, 255);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/pdc202xx_new.c
===================================================================
--- a.orig/drivers/ide/pci/pdc202xx_new.c
+++ a/drivers/ide/pci/pdc202xx_new.c
@@ -282,19 +282,13 @@ static int config_chipset_for_dma(ide_dr
 static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-			return hwif->ide_dma_on(drive);
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		hwif->tuneproc(drive, 255);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/pdc202xx_old.c
===================================================================
--- a.orig/drivers/ide/pci/pdc202xx_old.c
+++ a/drivers/ide/pci/pdc202xx_old.c
@@ -333,21 +333,13 @@ chipset_is_set:
 static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if (id && (id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive)) {
-			if (config_chipset_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		hwif->tuneproc(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/piix.c
===================================================================
--- a.orig/drivers/ide/pci/piix.c
+++ a/drivers/ide/pci/piix.c
@@ -387,19 +387,13 @@ static int piix_config_drive_for_dma (id
 static int piix_config_drive_xfer_rate (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && piix_config_drive_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive) && piix_config_drive_for_dma(drive))
-			return hwif->ide_dma_on(drive);
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		/* Find best PIO mode. */
 		(void) hwif->speedproc(drive, XFER_PIO_0 +
 				       ide_get_best_pio_mode(drive, 255, 4, NULL));
Index: a/drivers/ide/pci/serverworks.c
===================================================================
--- a.orig/drivers/ide/pci/serverworks.c
+++ a/drivers/ide/pci/serverworks.c
@@ -316,21 +316,13 @@ static int config_chipset_for_dma (ide_d
 static int svwks_config_drive_xfer_rate (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive)) {
-			if (config_chipset_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		config_chipset_for_pio(drive);
 		//	hwif->tuneproc(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
Index: a/drivers/ide/pci/siimage.c
===================================================================
--- a.orig/drivers/ide/pci/siimage.c
+++ a/drivers/ide/pci/siimage.c
@@ -416,19 +416,11 @@ static int config_chipset_for_dma (ide_d
 static int siimage_config_drive_for_dma (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
-	if ((id->capability & 1) != 0 && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive)) {
-			if (config_chipset_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		config_chipset_for_pio(drive, 1);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/sis5513.c
===================================================================
--- a.orig/drivers/ide/pci/sis5513.c
+++ a/drivers/ide/pci/sis5513.c
@@ -670,23 +670,15 @@ static int config_chipset_for_dma (ide_d
 static int sis5513_config_xfer_rate(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	config_art_rwp_pio(drive, 5);
 
 	drive->init_speed = 0;
 
-	if (id && (id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive)) {
-			if (config_chipset_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		sis5513_tune_drive(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/slc90e66.c
===================================================================
--- a.orig/drivers/ide/pci/slc90e66.c
+++ a/drivers/ide/pci/slc90e66.c
@@ -180,19 +180,13 @@ static int slc90e66_config_drive_for_dma
 static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive))
-			return hwif->ide_dma_on(drive);
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		(void) hwif->speedproc(drive, XFER_PIO_0 +
 				       ide_get_best_pio_mode(drive, 255, 4, NULL));
 		return hwif->ide_dma_off_quietly(drive);
Index: a/drivers/ide/pci/tc86c001.c
===================================================================
--- a.orig/drivers/ide/pci/tc86c001.c
+++ a/drivers/ide/pci/tc86c001.c
@@ -186,17 +186,11 @@ static int config_chipset_for_dma(ide_dr
 static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-			return hwif->ide_dma_on(drive);
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		tc86c001_tune_drive(drive, 255);
 		return hwif->ide_dma_off_quietly(drive);
 	}
Index: a/drivers/ide/pci/triflex.c
===================================================================
--- a.orig/drivers/ide/pci/triflex.c
+++ a/drivers/ide/pci/triflex.c
@@ -116,14 +116,9 @@ static int triflex_config_drive_for_dma(
 static int triflex_config_drive_xfer_rate(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
-	if ((id->capability & 1) && drive->autodma) {
-		if (ide_use_dma(drive)) {
-			if (triflex_config_drive_for_dma(drive))
-				return hwif->ide_dma_on(drive);
-		}
-	}
+	if (ide_use_dma(drive) && triflex_config_drive_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
 	hwif->tuneproc(drive, 255);
 	return hwif->ide_dma_off_quietly(drive);
Index: a/include/linux/ide.h
===================================================================
--- a.orig/include/linux/ide.h
+++ a/include/linux/ide.h
@@ -1325,6 +1325,7 @@ extern int ide_dma_enable(ide_drive_t *d
 extern char *ide_xfer_verbose(u8 xfer_rate);
 extern void ide_toggle_bounce(ide_drive_t *drive, int on);
 extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
+int ide_use_fast_pio(ide_drive_t *);
 
 u8 ide_dump_status(ide_drive_t *, const char *, u8);
 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 19/19] ide: use PIO/MMIO operations directly where possible
  2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
                   ` (15 preceding siblings ...)
  2007-01-12  4:28 ` [PATCH 18/19] ide: add ide_use_fast_pio() helper Bartlomiej Zolnierkiewicz
@ 2007-01-12  4:28 ` Bartlomiej Zolnierkiewicz
  2007-01-12 10:06   ` Alan
  2007-06-21 17:16   ` Sergei Shtylyov
  16 siblings, 2 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12  4:28 UTC (permalink / raw)
  To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel

[PATCH] ide: use PIO/MMIO operations directly where possible

This results in smaller/faster/simpler code and allows future optimizations.
Also remove no longer needed ide[_mm]_{inl,outl}() and ide_hwif_t.{INL,OUTL}.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

---
 drivers/ide/h8300/ide-h8300.c  |    2 -
 drivers/ide/ide-dma.c          |    5 ++-
 drivers/ide/ide-iops.c         |   24 --------------
 drivers/ide/ide.c              |    2 -
 drivers/ide/legacy/ht6560b.c   |   14 ++++----
 drivers/ide/pci/aec62xx.c      |    6 +--
 drivers/ide/pci/alim15x3.c     |    4 +-
 drivers/ide/pci/cmd64x.c       |   18 +++++------
 drivers/ide/pci/cs5530.c       |   22 ++++++-------
 drivers/ide/pci/cy82c693.c     |   12 +++----
 drivers/ide/pci/hpt366.c       |    2 -
 drivers/ide/pci/ns87415.c      |   10 +++---
 drivers/ide/pci/opti621.c      |   63 +++++++++++++++++++-------------------
 drivers/ide/pci/pdc202xx_new.c |    8 ++--
 drivers/ide/pci/pdc202xx_old.c |   41 ++++++++++++-------------
 drivers/ide/pci/serverworks.c  |    4 +-
 drivers/ide/pci/sgiioc4.c      |   67 +++++++++++++++++++++--------------------
 drivers/ide/pci/siimage.c      |   24 +++++++-------
 drivers/ide/pci/sl82c105.c     |    6 +--
 drivers/ide/pci/tc86c001.c     |   26 +++++++--------
 drivers/ide/pci/trm290.c       |   38 +++++++++++------------
 include/linux/ide.h            |    2 -
 22 files changed, 188 insertions(+), 212 deletions(-)

Index: a/drivers/ide/h8300/ide-h8300.c
===================================================================
--- a.orig/drivers/ide/h8300/ide-h8300.c
+++ a/drivers/ide/h8300/ide-h8300.c
@@ -81,8 +81,6 @@ static inline void hwif_setup(ide_hwif_t
 	hwif->OUTSW = mm_outsw;
 	hwif->INW   = mm_inw;
 	hwif->INSW  = mm_insw;
-	hwif->OUTL  = NULL;
-	hwif->INL   = NULL;
 	hwif->OUTSL = NULL;
 	hwif->INSL  = NULL;
 }
Index: a/drivers/ide/ide-dma.c
===================================================================
--- a.orig/drivers/ide/ide-dma.c
+++ a/drivers/ide/ide-dma.c
@@ -565,7 +565,10 @@ int ide_dma_setup(ide_drive_t *drive)
 	}
 
 	/* PRD table */
-	hwif->OUTL(hwif->dmatable_dma, hwif->dma_prdtable);
+	if (hwif->mmio == 2)
+		writel(hwif->dmatable_dma, (void __iomem *)hwif->dma_prdtable);
+	else
+		outl(hwif->dmatable_dma, hwif->dma_prdtable);
 
 	/* specify r/w */
 	hwif->OUTB(reading, hwif->dma_command);
Index: a/drivers/ide/ide-iops.c
===================================================================
--- a.orig/drivers/ide/ide-iops.c
+++ a/drivers/ide/ide-iops.c
@@ -49,11 +49,6 @@ static void ide_insw (unsigned long port
 	insw(port, addr, count);
 }
 
-static u32 ide_inl (unsigned long port)
-{
-	return (u32) inl(port);
-}
-
 static void ide_insl (unsigned long port, void *addr, u32 count)
 {
 	insl(port, addr, count);
@@ -79,11 +74,6 @@ static void ide_outsw (unsigned long por
 	outsw(port, addr, count);
 }
 
-static void ide_outl (u32 val, unsigned long port)
-{
-	outl(val, port);
-}
-
 static void ide_outsl (unsigned long port, void *addr, u32 count)
 {
 	outsl(port, addr, count);
@@ -94,12 +84,10 @@ void default_hwif_iops (ide_hwif_t *hwif
 	hwif->OUTB	= ide_outb;
 	hwif->OUTBSYNC	= ide_outbsync;
 	hwif->OUTW	= ide_outw;
-	hwif->OUTL	= ide_outl;
 	hwif->OUTSW	= ide_outsw;
 	hwif->OUTSL	= ide_outsl;
 	hwif->INB	= ide_inb;
 	hwif->INW	= ide_inw;
-	hwif->INL	= ide_inl;
 	hwif->INSW	= ide_insw;
 	hwif->INSL	= ide_insl;
 }
@@ -123,11 +111,6 @@ static void ide_mm_insw (unsigned long p
 	__ide_mm_insw((void __iomem *) port, addr, count);
 }
 
-static u32 ide_mm_inl (unsigned long port)
-{
-	return (u32) readl((void __iomem *) port);
-}
-
 static void ide_mm_insl (unsigned long port, void *addr, u32 count)
 {
 	__ide_mm_insl((void __iomem *) port, addr, count);
@@ -153,11 +136,6 @@ static void ide_mm_outsw (unsigned long 
 	__ide_mm_outsw((void __iomem *) port, addr, count);
 }
 
-static void ide_mm_outl (u32 value, unsigned long port)
-{
-	writel(value, (void __iomem *) port);
-}
-
 static void ide_mm_outsl (unsigned long port, void *addr, u32 count)
 {
 	__ide_mm_outsl((void __iomem *) port, addr, count);
@@ -170,12 +148,10 @@ void default_hwif_mmiops (ide_hwif_t *hw
 	   this one is controller specific! */
 	hwif->OUTBSYNC	= ide_mm_outbsync;
 	hwif->OUTW	= ide_mm_outw;
-	hwif->OUTL	= ide_mm_outl;
 	hwif->OUTSW	= ide_mm_outsw;
 	hwif->OUTSL	= ide_mm_outsl;
 	hwif->INB	= ide_mm_inb;
 	hwif->INW	= ide_mm_inw;
-	hwif->INL	= ide_mm_inl;
 	hwif->INSW	= ide_mm_insw;
 	hwif->INSL	= ide_mm_insl;
 }
Index: a/drivers/ide/ide.c
===================================================================
--- a.orig/drivers/ide/ide.c
+++ a/drivers/ide/ide.c
@@ -511,13 +511,11 @@ static void ide_hwif_restore(ide_hwif_t 
 	hwif->OUTB			= tmp_hwif->OUTB;
 	hwif->OUTBSYNC			= tmp_hwif->OUTBSYNC;
 	hwif->OUTW			= tmp_hwif->OUTW;
-	hwif->OUTL			= tmp_hwif->OUTL;
 	hwif->OUTSW			= tmp_hwif->OUTSW;
 	hwif->OUTSL			= tmp_hwif->OUTSL;
 
 	hwif->INB			= tmp_hwif->INB;
 	hwif->INW			= tmp_hwif->INW;
-	hwif->INL			= tmp_hwif->INL;
 	hwif->INSW			= tmp_hwif->INSW;
 	hwif->INSL			= tmp_hwif->INSL;
 
Index: a/drivers/ide/legacy/ht6560b.c
===================================================================
--- a.orig/drivers/ide/legacy/ht6560b.c
+++ a/drivers/ide/legacy/ht6560b.c
@@ -143,16 +143,16 @@ static void ht6560b_selectproc (ide_driv
 		current_timing = timing;
 		if (drive->media != ide_disk || !drive->present)
 			select |= HT_PREFETCH_MODE;
-		(void) HWIF(drive)->INB(HT_CONFIG_PORT);
-		(void) HWIF(drive)->INB(HT_CONFIG_PORT);
-		(void) HWIF(drive)->INB(HT_CONFIG_PORT);
-		(void) HWIF(drive)->INB(HT_CONFIG_PORT);
-		HWIF(drive)->OUTB(select, HT_CONFIG_PORT);
+		(void)inb(HT_CONFIG_PORT);
+		(void)inb(HT_CONFIG_PORT);
+		(void)inb(HT_CONFIG_PORT);
+		(void)inb(HT_CONFIG_PORT);
+		outb(select, HT_CONFIG_PORT);
 		/*
 		 * Set timing for this drive:
 		 */
-		HWIF(drive)->OUTB(timing, IDE_SELECT_REG);
-		(void) HWIF(drive)->INB(IDE_STATUS_REG);
+		outb(timing, IDE_SELECT_REG);
+		(void)inb(IDE_STATUS_REG);
 #ifdef DEBUG
 		printk("ht6560b: %s: select=%#x timing=%#x\n",
 			drive->name, select, timing);
Index: a/drivers/ide/pci/aec62xx.c
===================================================================
--- a.orig/drivers/ide/pci/aec62xx.c
+++ a/drivers/ide/pci/aec62xx.c
@@ -94,9 +94,9 @@ static u8 aec62xx_ratemask (ide_drive_t 
 	switch(hwif->pci_dev->device) {
 		case PCI_DEVICE_ID_ARTOP_ATP865:
 		case PCI_DEVICE_ID_ARTOP_ATP865R:
-			mode = (hwif->INB(((hwif->channel) ?
-					hwif->mate->dma_status :
-					hwif->dma_status)) & 0x10) ? 4 : 3;
+			mode = (inb(hwif->channel ?
+				    hwif->mate->dma_status :
+				    hwif->dma_status) & 0x10) ? 4 : 3;
 			break;
 		case PCI_DEVICE_ID_ARTOP_ATP860:
 		case PCI_DEVICE_ID_ARTOP_ATP860R:
Index: a/drivers/ide/pci/alim15x3.c
===================================================================
--- a.orig/drivers/ide/pci/alim15x3.c
+++ a/drivers/ide/pci/alim15x3.c
@@ -852,8 +852,8 @@ static void __devinit init_dma_ali15x3 (
 {
 	if (m5229_revision < 0x20)
 		return;
-	if (!(hwif->channel))
-		hwif->OUTB(hwif->INB(dmabase+2) & 0x60, dmabase+2);
+	if (!hwif->channel)
+		outb(inb(dmabase + 2) & 0x60, dmabase + 2);
 	ide_setup_dma(hwif, dmabase, 8);
 }
 
Index: a/drivers/ide/pci/cmd64x.c
===================================================================
--- a.orig/drivers/ide/pci/cmd64x.c
+++ a/drivers/ide/pci/cmd64x.c
@@ -507,13 +507,13 @@ static int cmd64x_ide_dma_end (ide_drive
 
 	drive->waiting_for_dma = 0;
 	/* read DMA command state */
-	dma_cmd = hwif->INB(hwif->dma_command);
+	dma_cmd = inb(hwif->dma_command);
 	/* stop DMA */
-	hwif->OUTB((dma_cmd & ~1), hwif->dma_command);
+	outb(dma_cmd & ~1, hwif->dma_command);
 	/* get DMA status */
-	dma_stat = hwif->INB(hwif->dma_status);
+	dma_stat = inb(hwif->dma_status);
 	/* clear the INTR & ERROR bits */
-	hwif->OUTB(dma_stat|6, hwif->dma_status);
+	outb(dma_stat | 6, hwif->dma_status);
 	if (cmd64x_alt_dma_status(dev)) {
 		u8 dma_intr	= 0;
 		u8 dma_mask	= (hwif->channel) ? ARTTIM23_INTR_CH1 :
@@ -535,7 +535,7 @@ static int cmd64x_ide_dma_test_irq (ide_
 	struct pci_dev *dev		= hwif->pci_dev;
         u8 dma_alt_stat = 0, mask	= (hwif->channel) ? MRDMODE_INTR_CH1 :
 							    MRDMODE_INTR_CH0;
-	u8 dma_stat = hwif->INB(hwif->dma_status);
+	u8 dma_stat = inb(hwif->dma_status);
 
 	(void) pci_read_config_byte(dev, MRDMODE, &dma_alt_stat);
 #ifdef DEBUG
@@ -565,13 +565,13 @@ static int cmd646_1_ide_dma_end (ide_dri
 
 	drive->waiting_for_dma = 0;
 	/* get DMA status */
-	dma_stat = hwif->INB(hwif->dma_status);
+	dma_stat = inb(hwif->dma_status);
 	/* read DMA command state */
-	dma_cmd = hwif->INB(hwif->dma_command);
+	dma_cmd = inb(hwif->dma_command);
 	/* stop DMA */
-	hwif->OUTB((dma_cmd & ~1), hwif->dma_command);
+	outb(dma_cmd & ~1, hwif->dma_command);
 	/* clear the INTR & ERROR bits */
-	hwif->OUTB(dma_stat|6, hwif->dma_status);
+	outb(dma_stat | 6, hwif->dma_status);
 	/* and free any DMA resources */
 	ide_destroy_dmatable(drive);
 	/* verify good DMA status */
Index: a/drivers/ide/pci/cs5530.c
===================================================================
--- a.orig/drivers/ide/pci/cs5530.c
+++ a/drivers/ide/pci/cs5530.c
@@ -81,8 +81,8 @@ static void cs5530_tuneproc (ide_drive_t
 
 	pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
 	if (!cs5530_set_xfer_mode(drive, modes[pio])) {
-		format = (hwif->INL(basereg+4) >> 31) & 1;
-		hwif->OUTL(cs5530_pio_timings[format][pio],
+		format = (inl(basereg + 4) >> 31) & 1;
+		outl(cs5530_pio_timings[format][pio],
 			basereg+(drive->select.b.unit<<3));
 	}
 }
@@ -183,17 +183,17 @@ static int cs5530_config_dma (ide_drive_
 			break;
 	}
 	basereg = CS5530_BASEREG(hwif);
-	reg = hwif->INL(basereg+4);		/* get drive0 config register */
+	reg = inl(basereg + 4);			/* get drive0 config register */
 	timings |= reg & 0x80000000;		/* preserve PIO format bit */
 	if (unit == 0) {			/* are we configuring drive0? */
-		hwif->OUTL(timings, basereg+4);	/* write drive0 config register */
+		outl(timings, basereg + 4);	/* write drive0 config register */
 	} else {
 		if (timings & 0x00100000)
 			reg |=  0x00100000;	/* enable UDMA timings for both drives */
 		else
 			reg &= ~0x00100000;	/* disable UDMA timings for both drives */
-		hwif->OUTL(reg,     basereg+4);	/* write drive0 config register */
-		hwif->OUTL(timings, basereg+12);	/* write drive1 config register */
+		outl(reg, basereg + 4);		/* write drive0 config register */
+		outl(timings, basereg + 12);	/* write drive1 config register */
 	}
 
 	/*
@@ -315,17 +315,17 @@ static void __devinit init_hwif_cs5530 (
 
 	hwif->tuneproc = &cs5530_tuneproc;
 	basereg = CS5530_BASEREG(hwif);
-	d0_timings = hwif->INL(basereg+0);
+	d0_timings = inl(basereg + 0);
 	if (CS5530_BAD_PIO(d0_timings)) {
 		/* PIO timings not initialized? */
-		hwif->OUTL(cs5530_pio_timings[(d0_timings>>31)&1][0], basereg+0);
+		outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0);
 		if (!hwif->drives[0].autotune)
 			hwif->drives[0].autotune = 1;
 			/* needs autotuning later */
 	}
-	if (CS5530_BAD_PIO(hwif->INL(basereg+8))) {
-	/* PIO timings not initialized? */
-		hwif->OUTL(cs5530_pio_timings[(d0_timings>>31)&1][0], basereg+8);
+	if (CS5530_BAD_PIO(inl(basereg + 8))) {
+		/* PIO timings not initialized? */
+		outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8);
 		if (!hwif->drives[1].autotune)
 			hwif->drives[1].autotune = 1;
 			/* needs autotuning later */
Index: a/drivers/ide/pci/cy82c693.c
===================================================================
--- a.orig/drivers/ide/pci/cy82c693.c
+++ a/drivers/ide/pci/cy82c693.c
@@ -197,8 +197,8 @@ static void cy82c693_dma_enable (ide_dri
 #if CY82C693_DEBUG_LOGS
 	/* for debug let's show the previous values */
 
-	HWIF(drive)->OUTB(index, CY82_INDEX_PORT);
-	data = HWIF(drive)->INB(CY82_DATA_PORT);
+	outb(index, CY82_INDEX_PORT);
+	data = inb(CY82_DATA_PORT);
 
 	printk (KERN_INFO "%s (ch=%d, dev=%d): DMA mode is %d (single=%d)\n",
 		drive->name, HWIF(drive)->channel, drive->select.b.unit,
@@ -207,8 +207,8 @@ static void cy82c693_dma_enable (ide_dri
 
 	data = (u8)mode|(u8)(single<<2);
 
-	HWIF(drive)->OUTB(index, CY82_INDEX_PORT);
-	HWIF(drive)->OUTB(data, CY82_DATA_PORT);
+	outb(index, CY82_INDEX_PORT);
+	outb(data, CY82_DATA_PORT);
 
 #if CY82C693_DEBUG_INFO
 	printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n",
@@ -227,8 +227,8 @@ static void cy82c693_dma_enable (ide_dri
 	 */
 
 	data = BUSMASTER_TIMEOUT;
-	HWIF(drive)->OUTB(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT);
-	HWIF(drive)->OUTB(data, CY82_DATA_PORT);
+	outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT);
+	outb(data, CY82_DATA_PORT);
 
 #if CY82C693_DEBUG_INFO	
 	printk (KERN_INFO "%s: Set IDE Bus Master TimeOut Register to 0x%X\n",
Index: a/drivers/ide/pci/hpt366.c
===================================================================
--- a.orig/drivers/ide/pci/hpt366.c
+++ a/drivers/ide/pci/hpt366.c
@@ -836,7 +836,7 @@ static int hpt374_ide_dma_test_irq(ide_d
 		return 0;
 	}
 
-	dma_stat = hwif->INB(hwif->dma_status);
+	dma_stat = inb(hwif->dma_status);
 	/* return 1 if INTR asserted */
 	if (dma_stat & 4)
 		return 1;
Index: a/drivers/ide/pci/ns87415.c
===================================================================
--- a.orig/drivers/ide/pci/ns87415.c
+++ a/drivers/ide/pci/ns87415.c
@@ -166,10 +166,10 @@ static int ns87415_ide_dma_end (ide_driv
 	/* get dma command mode */
 	dma_cmd = hwif->INB(hwif->dma_command);
 	/* stop DMA */
-	hwif->OUTB(dma_cmd & ~1, hwif->dma_command);
+	outb(dma_cmd & ~1, hwif->dma_command);
 	/* from ERRATA: clear the INTR & ERROR bits */
 	dma_cmd = hwif->INB(hwif->dma_command);
-	hwif->OUTB(dma_cmd|6, hwif->dma_command);
+	outb(dma_cmd | 6, hwif->dma_command);
 	/* and free any DMA resources */
 	ide_destroy_dmatable(drive);
 	/* verify good DMA status */
@@ -243,9 +243,9 @@ static void __devinit init_hwif_ns87415 
 		 *      to SELECT_DRIVE() properly during first probe_hwif().
 		 */
 		timeout = 10000;
-		hwif->OUTB(12, hwif->io_ports[IDE_CONTROL_OFFSET]);
+		outb(12, hwif->io_ports[IDE_CONTROL_OFFSET]);
 		udelay(10);
-		hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
+		outb(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
 		do {
 			udelay(50);
 			stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]);
@@ -263,7 +263,7 @@ static void __devinit init_hwif_ns87415 
 	if (!hwif->dma_base)
 		return;
 
-	hwif->OUTB(0x60, hwif->dma_status);
+	outb(0x60, hwif->dma_status);
 	hwif->dma_setup = &ns87415_ide_dma_setup;
 	hwif->ide_dma_check = &ns87415_ide_dma_check;
 	hwif->ide_dma_end = &ns87415_ide_dma_end;
Index: a/drivers/ide/pci/opti621.c
===================================================================
--- a.orig/drivers/ide/pci/opti621.c
+++ a/drivers/ide/pci/opti621.c
@@ -176,34 +176,35 @@ static int cmpt_clk(int time, int bus_sp
 	return ((time*bus_speed+999)/1000);
 }
 
-static void write_reg(ide_hwif_t *hwif, u8 value, int reg)
 /* Write value to register reg, base of register
  * is at reg_base (0x1f0 primary, 0x170 secondary,
  * if not changed by PCI configuration).
  * This is from setupvic.exe program.
  */
+static void write_reg(u8 value, int reg)
 {
-	hwif->INW(reg_base+1);
-	hwif->INW(reg_base+1);
-	hwif->OUTB(3, reg_base+2);
-	hwif->OUTB(value, reg_base+reg);
-	hwif->OUTB(0x83, reg_base+2);
+	inw(reg_base + 1);
+	inw(reg_base + 1);
+	outb(3, reg_base + 2);
+	outb(value, reg_base + reg);
+	outb(0x83, reg_base + 2);
 }
 
-static u8 read_reg(ide_hwif_t *hwif, int reg)
 /* Read value from register reg, base of register
  * is at reg_base (0x1f0 primary, 0x170 secondary,
  * if not changed by PCI configuration).
  * This is from setupvic.exe program.
  */
+static u8 read_reg(int reg)
 {
 	u8 ret = 0;
 
-	hwif->INW(reg_base+1);
-	hwif->INW(reg_base+1);
-	hwif->OUTB(3, reg_base+2);
-	ret = hwif->INB(reg_base+reg);
-	hwif->OUTB(0x83, reg_base+2);
+	inw(reg_base + 1);
+	inw(reg_base + 1);
+	outb(3, reg_base + 2);
+	ret = inb(reg_base + reg);
+	outb(0x83, reg_base + 2);
+
 	return ret;
 }
 
@@ -286,39 +287,39 @@ static void opti621_tune_drive (ide_driv
      	reg_base = hwif->io_ports[IDE_DATA_OFFSET];
 
 	/* allow Register-B */
-	hwif->OUTB(0xc0, reg_base+CNTRL_REG);
+	outb(0xc0, reg_base + CNTRL_REG);
 	/* hmm, setupvic.exe does this ;-) */
-	hwif->OUTB(0xff, reg_base+5);
+	outb(0xff, reg_base + 5);
 	/* if reads 0xff, adapter not exist? */
-	(void) hwif->INB(reg_base+CNTRL_REG);
+	(void)inb(reg_base + CNTRL_REG);
 	/* if reads 0xc0, no interface exist? */
-	read_reg(hwif, CNTRL_REG);
+	read_reg(CNTRL_REG);
 	/* read version, probably 0 */
-	read_reg(hwif, STRAP_REG);
+	read_reg(STRAP_REG);
 
 	/* program primary drive */
-		/* select Index-0 for Register-A */
-	write_reg(hwif, 0,      MISC_REG);
-		/* set read cycle timings */
-	write_reg(hwif, cycle1, READ_REG);
-		/* set write cycle timings */
-	write_reg(hwif, cycle1, WRITE_REG);
+	/* select Index-0 for Register-A */
+	write_reg(0, MISC_REG);
+	/* set read cycle timings */
+	write_reg(cycle1, READ_REG);
+	/* set write cycle timings */
+	write_reg(cycle1, WRITE_REG);
 
 	/* program secondary drive */
-		/* select Index-1 for Register-B */
-	write_reg(hwif, 1,      MISC_REG);
-		/* set read cycle timings */
-	write_reg(hwif, cycle2, READ_REG);
-		/* set write cycle timings */
-	write_reg(hwif, cycle2, WRITE_REG);
+	/* select Index-1 for Register-B */
+	write_reg(1, MISC_REG);
+	/* set read cycle timings */
+	write_reg(cycle2, READ_REG);
+	/* set write cycle timings */
+	write_reg(cycle2, WRITE_REG);
 
 	/* use Register-A for drive 0 */
 	/* use Register-B for drive 1 */
-	write_reg(hwif, 0x85, CNTRL_REG);
+	write_reg(0x85, CNTRL_REG);
 
 	/* set address setup, DRDY timings,   */
 	/*  and read prefetch for both drives */
- 	write_reg(hwif, misc, MISC_REG);
+	write_reg(misc, MISC_REG);
 
 	spin_unlock_irqrestore(&ide_lock, flags);
 }
Index: a/drivers/ide/pci/pdc202xx_new.c
===================================================================
--- a.orig/drivers/ide/pci/pdc202xx_new.c
+++ a/drivers/ide/pci/pdc202xx_new.c
@@ -101,8 +101,8 @@ static u8 get_indexed_reg(ide_hwif_t *hw
 {
 	u8 value;
 
-	hwif->OUTB(index, hwif->dma_vendor1);
-	value = hwif->INB(hwif->dma_vendor3);
+	outb(index, hwif->dma_vendor1);
+	value = inb(hwif->dma_vendor3);
 
 	DBG("index[%02X] value[%02X]\n", index, value);
 	return value;
@@ -115,8 +115,8 @@ static u8 get_indexed_reg(ide_hwif_t *hw
  */
 static void set_indexed_reg(ide_hwif_t *hwif, u8 index, u8 value)
 {
-	hwif->OUTB(index, hwif->dma_vendor1);
-	hwif->OUTB(value, hwif->dma_vendor3);
+	outb(index, hwif->dma_vendor1);
+	outb(value, hwif->dma_vendor3);
 	DBG("index[%02X] value[%02X]\n", index, value);
 }
 
Index: a/drivers/ide/pci/pdc202xx_old.c
===================================================================
--- a.orig/drivers/ide/pci/pdc202xx_old.c
+++ a/drivers/ide/pci/pdc202xx_old.c
@@ -250,17 +250,17 @@ static u8 pdc202xx_old_cable_detect (ide
 static void pdc_old_enable_66MHz_clock(ide_hwif_t *hwif)
 {
 	unsigned long clock_reg = hwif->dma_master + 0x11;
-	u8 clock = hwif->INB(clock_reg);
+	u8 clock = inb(clock_reg);
 
-	hwif->OUTB(clock | (hwif->channel ? 0x08 : 0x02), clock_reg);
+	outb(clock | (hwif->channel ? 0x08 : 0x02), clock_reg);
 }
 
 static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif)
 {
 	unsigned long clock_reg = hwif->dma_master + 0x11;
-	u8 clock = hwif->INB(clock_reg);
+	u8 clock = inb(clock_reg);
 
-	hwif->OUTB(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
+	outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
 }
 
 static int config_chipset_for_dma (ide_drive_t *drive)
@@ -367,14 +367,14 @@ static void pdc202xx_old_ide_dma_start(i
 		unsigned long high_16   = hwif->dma_master;
 		unsigned long atapi_reg	= high_16 + (hwif->channel ? 0x24 : 0x20);
 		u32 word_count	= 0;
-		u8 clock = hwif->INB(high_16 + 0x11);
+		u8 clock = inb(high_16 + 0x11);
 
-		hwif->OUTB(clock|(hwif->channel ? 0x08 : 0x02), high_16+0x11);
+		outb(clock | (hwif->channel ? 0x08 : 0x02), high_16 + 0x11);
 		word_count = (rq->nr_sectors << 8);
 		word_count = (rq_data_dir(rq) == READ) ?
 					word_count | 0x05000000 :
 					word_count | 0x06000000;
-		hwif->OUTL(word_count, atapi_reg);
+		outl(word_count, atapi_reg);
 	}
 	ide_dma_start(drive);
 }
@@ -387,9 +387,9 @@ static int pdc202xx_old_ide_dma_end(ide_
 		unsigned long atapi_reg	= high_16 + (hwif->channel ? 0x24 : 0x20);
 		u8 clock		= 0;
 
-		hwif->OUTL(0, atapi_reg); /* zero out extra */
-		clock = hwif->INB(high_16 + 0x11);
-		hwif->OUTB(clock & ~(hwif->channel ? 0x08:0x02), high_16+0x11);
+		outl(0, atapi_reg); /* zero out extra */
+		clock = inb(high_16 + 0x11);
+		outb(clock & ~(hwif->channel ? 0x08:0x02), high_16 + 0x11);
 	}
 	if (drive->current_speed > XFER_UDMA_2)
 		pdc_old_disable_66MHz_clock(drive->hwif);
@@ -400,8 +400,8 @@ static int pdc202xx_old_ide_dma_test_irq
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	unsigned long high_16	= hwif->dma_master;
-	u8 dma_stat		= hwif->INB(hwif->dma_status);
-	u8 sc1d			= hwif->INB((high_16 + 0x001d));
+	u8 dma_stat		= inb(hwif->dma_status);
+	u8 sc1d			= inb(high_16 + 0x001d);
 
 	if (hwif->channel) {
 		/* bit7: Error, bit6: Interrupting, bit5: FIFO Full, bit4: FIFO Empty */
@@ -437,11 +437,11 @@ static int pdc202xx_ide_dma_timeout(ide_
 static void pdc202xx_reset_host (ide_hwif_t *hwif)
 {
 	unsigned long high_16	= hwif->dma_master;
-	u8 udma_speed_flag	= hwif->INB(high_16|0x001f);
+	u8 udma_speed_flag	= inb(high_16 | 0x001f);
 
-	hwif->OUTB((udma_speed_flag | 0x10), (high_16|0x001f));
+	outb(udma_speed_flag | 0x10, high_16 | 0x001f);
 	mdelay(100);
-	hwif->OUTB((udma_speed_flag & ~0x10), (high_16|0x001f));
+	outb(udma_speed_flag & ~0x10, high_16 | 0x001f);
 	mdelay(2000);	/* 2 seconds ?! */
 
 	printk(KERN_WARNING "PDC202XX: %s channel reset.\n",
@@ -529,9 +529,9 @@ static void __devinit init_dma_pdc202xx(
 		return;
 	}
 
-	udma_speed_flag	= hwif->INB((dmabase|0x1f));
-	primary_mode	= hwif->INB((dmabase|0x1a));
-	secondary_mode	= hwif->INB((dmabase|0x1b));
+	udma_speed_flag	= inb(dmabase | 0x1f);
+	primary_mode	= inb(dmabase | 0x1a);
+	secondary_mode	= inb(dmabase | 0x1b);
 	printk(KERN_INFO "%s: (U)DMA Burst Bit %sABLED " \
 		"Primary %s Mode " \
 		"Secondary %s Mode.\n", hwif->cds->name,
@@ -544,9 +544,8 @@ static void __devinit init_dma_pdc202xx(
 		printk(KERN_INFO "%s: FORCING BURST BIT 0x%02x->0x%02x ",
 			hwif->cds->name, udma_speed_flag,
 			(udma_speed_flag|1));
-		hwif->OUTB(udma_speed_flag|1,(dmabase|0x1f));
-		printk("%sACTIVE\n",
-			(hwif->INB(dmabase|0x1f)&1) ? "":"IN");
+		outb(udma_speed_flag | 1, dmabase | 0x1f);
+		printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN");
 	}
 #endif /* CONFIG_PDC202XX_BURST */
 
Index: a/drivers/ide/pci/serverworks.c
===================================================================
--- a.orig/drivers/ide/pci/serverworks.c
+++ a/drivers/ide/pci/serverworks.c
@@ -160,7 +160,7 @@ static int svwks_tune_chipset (ide_drive
 	if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
 	    (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) {
 		if (!drive->init_speed) {
-			u8 dma_stat = hwif->INB(hwif->dma_status);
+			u8 dma_stat = inb(hwif->dma_status);
 
 dma_pio:
 			if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) &&
@@ -529,7 +529,7 @@ static void __devinit init_hwif_svwks (i
 	if (!noautodma)
 		hwif->autodma = 1;
 
-	dma_stat = hwif->INB(hwif->dma_status);
+	dma_stat = inb(hwif->dma_status);
 	hwif->drives[0].autodma = (dma_stat & 0x20);
 	hwif->drives[1].autodma = (dma_stat & 0x40);
 	hwif->drives[0].autotune = (!(dma_stat & 0x20));
Index: a/drivers/ide/pci/sgiioc4.c
===================================================================
--- a.orig/drivers/ide/pci/sgiioc4.c
+++ a/drivers/ide/pci/sgiioc4.c
@@ -110,24 +110,24 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, 
 static void
 sgiioc4_maskproc(ide_drive_t * drive, int mask)
 {
-	ide_hwif_t *hwif = HWIF(drive);
-	hwif->OUTB(mask ? (drive->ctl | 2) : (drive->ctl & ~2),
-		   IDE_CONTROL_REG);
+	writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2),
+	       (void __iomem *)IDE_CONTROL_REG);
 }
 
 
 static int
 sgiioc4_checkirq(ide_hwif_t * hwif)
 {
-	u8 intr_reg =
-	    hwif->INL(hwif->io_ports[IDE_IRQ_OFFSET] + IOC4_INTR_REG * 4);
+	unsigned long intr_addr =
+		hwif->io_ports[IDE_IRQ_OFFSET] + IOC4_INTR_REG * 4;
 
-	if (intr_reg & 0x03)
+	if ((u8)readl((void __iomem *)intr_addr) & 0x03)
 		return 1;
 
 	return 0;
 }
 
+static u8 sgiioc4_INB(unsigned long);
 
 static int
 sgiioc4_clearirq(ide_drive_t * drive)
@@ -138,21 +138,21 @@ sgiioc4_clearirq(ide_drive_t * drive)
 	    hwif->io_ports[IDE_IRQ_OFFSET] + (IOC4_INTR_REG << 2);
 
 	/* Code to check for PCI error conditions */
-	intr_reg = hwif->INL(other_ir);
+	intr_reg = readl((void __iomem *)other_ir);
 	if (intr_reg & 0x03) { /* Valid IOC4-IDE interrupt */
 		/*
-		 * Using hwif->INB to read the IDE_STATUS_REG has a side effect
+		 * Using sgiioc4_INB to read the IDE_STATUS_REG has a side effect
 		 * of clearing the interrupt.  The first read should clear it
 		 * if it is set.  The second read should return a "clear" status
 		 * if it got cleared.  If not, then spin for a bit trying to
 		 * clear it.
 		 */
-		u8 stat = hwif->INB(IDE_STATUS_REG);
+		u8 stat = sgiioc4_INB(IDE_STATUS_REG);
 		int count = 0;
-		stat = hwif->INB(IDE_STATUS_REG);
+		stat = sgiioc4_INB(IDE_STATUS_REG);
 		while ((stat & 0x80) && (count++ < 100)) {
 			udelay(1);
-			stat = hwif->INB(IDE_STATUS_REG);
+			stat = sgiioc4_INB(IDE_STATUS_REG);
 		}
 
 		if (intr_reg & 0x02) {
@@ -161,9 +161,9 @@ sgiioc4_clearirq(ide_drive_t * drive)
 			    pci_stat_cmd_reg;
 
 			pci_err_addr_low =
-				hwif->INL(hwif->io_ports[IDE_IRQ_OFFSET]);
+				readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]);
 			pci_err_addr_high =
-				hwif->INL(hwif->io_ports[IDE_IRQ_OFFSET] + 4);
+				readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4));
 			pci_read_config_dword(hwif->pci_dev, PCI_COMMAND,
 					      &pci_stat_cmd_reg);
 			printk(KERN_ERR
@@ -180,9 +180,9 @@ sgiioc4_clearirq(ide_drive_t * drive)
 		}
 
 		/* Clear the Interrupt, Error bits on the IOC4 */
-		hwif->OUTL(0x03, other_ir);
+		writel(0x03, (void __iomem *)other_ir);
 
-		intr_reg = hwif->INL(other_ir);
+		intr_reg = readl((void __iomem *)other_ir);
 	}
 
 	return intr_reg & 3;
@@ -191,23 +191,25 @@ sgiioc4_clearirq(ide_drive_t * drive)
 static void sgiioc4_ide_dma_start(ide_drive_t * drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
-	unsigned int reg = hwif->INL(hwif->dma_base + IOC4_DMA_CTRL * 4);
+	unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4;
+	unsigned int reg = readl((void __iomem *)ioc4_dma_addr);
 	unsigned int temp_reg = reg | IOC4_S_DMA_START;
 
-	hwif->OUTL(temp_reg, hwif->dma_base + IOC4_DMA_CTRL * 4);
+	writel(temp_reg, (void __iomem *)ioc4_dma_addr);
 }
 
 static u32
 sgiioc4_ide_dma_stop(ide_hwif_t *hwif, u64 dma_base)
 {
+	unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4;
 	u32	ioc4_dma;
 	int	count;
 
 	count = 0;
-	ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
+	ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
 	while ((ioc4_dma & IOC4_S_DMA_STOP) && (count++ < 200)) {
 		udelay(1);
-		ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
+		ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
 	}
 	return ioc4_dma;
 }
@@ -218,11 +220,11 @@ sgiioc4_ide_dma_end(ide_drive_t * drive)
 {
 	u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0;
 	ide_hwif_t *hwif = HWIF(drive);
-	u64 dma_base = hwif->dma_base;
+	unsigned long dma_base = hwif->dma_base;
 	int dma_stat = 0;
 	unsigned long *ending_dma = ide_get_hwifdata(hwif);
 
-	hwif->OUTL(IOC4_S_DMA_STOP, dma_base + IOC4_DMA_CTRL * 4);
+	writel(IOC4_S_DMA_STOP, (void __iomem *)(dma_base + IOC4_DMA_CTRL * 4));
 
 	ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
 
@@ -254,8 +256,8 @@ sgiioc4_ide_dma_end(ide_drive_t * drive)
 		dma_stat = 1;
 	}
 
-	bc_dev = hwif->INL(dma_base + IOC4_BC_DEV * 4);
-	bc_mem = hwif->INL(dma_base + IOC4_BC_MEM * 4);
+	bc_dev = readl((void __iomem *)(dma_base + IOC4_BC_DEV * 4));
+	bc_mem = readl((void __iomem *)(dma_base + IOC4_BC_MEM * 4));
 
 	if ((bc_dev & 0x01FF) || (bc_mem & 0x1FF)) {
 		if (bc_dev > bc_mem + 8) {
@@ -436,16 +438,17 @@ sgiioc4_configure_for_dma(int dma_direct
 {
 	u32 ioc4_dma;
 	ide_hwif_t *hwif = HWIF(drive);
-	u64 dma_base = hwif->dma_base;
+	unsigned long dma_base = hwif->dma_base;
+	unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4;
 	u32 dma_addr, ending_dma_addr;
 
-	ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
+	ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
 
 	if (ioc4_dma & IOC4_S_DMA_ACTIVE) {
 		printk(KERN_WARNING
 			"%s(%s):Warning!! DMA from previous transfer was still active\n",
 		       __FUNCTION__, drive->name);
-		hwif->OUTL(IOC4_S_DMA_STOP, dma_base + IOC4_DMA_CTRL * 4);
+		writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr);
 		ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
 
 		if (ioc4_dma & IOC4_S_DMA_STOP)
@@ -454,13 +457,13 @@ sgiioc4_configure_for_dma(int dma_direct
 			       __FUNCTION__, drive->name);
 	}
 
-	ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
+	ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
 	if (ioc4_dma & IOC4_S_DMA_ERROR) {
 		printk(KERN_WARNING
 		       "%s(%s) : Warning!! - DMA Error during Previous"
 		       " transfer | status 0x%x\n",
 		       __FUNCTION__, drive->name, ioc4_dma);
-		hwif->OUTL(IOC4_S_DMA_STOP, dma_base + IOC4_DMA_CTRL * 4);
+		writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr);
 		ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
 
 		if (ioc4_dma & IOC4_S_DMA_STOP)
@@ -471,14 +474,14 @@ sgiioc4_configure_for_dma(int dma_direct
 
 	/* Address of the Scatter Gather List */
 	dma_addr = cpu_to_le32(hwif->dmatable_dma);
-	hwif->OUTL(dma_addr, dma_base + IOC4_DMA_PTR_L * 4);
+	writel(dma_addr, (void __iomem *)(dma_base + IOC4_DMA_PTR_L * 4));
 
 	/* Address of the Ending DMA */
 	memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE);
 	ending_dma_addr = cpu_to_le32(hwif->dma_status);
-	hwif->OUTL(ending_dma_addr, dma_base + IOC4_DMA_END_ADDR * 4);
+	writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4));
 
-	hwif->OUTL(dma_direction, dma_base + IOC4_DMA_CTRL * 4);
+	writel(dma_direction, (void __iomem *)ioc4_dma_addr);
 	drive->waiting_for_dma = 1;
 }
 
@@ -688,7 +691,7 @@ sgiioc4_ide_setup_pci_device(struct pci_
 	default_hwif_mmiops(hwif);
 
 	/* Initializing chipset IRQ Registers */
-	hwif->OUTL(0x03, irqport + IOC4_INTR_SET * 4);
+	writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
 
 	ide_init_sgiioc4(hwif);
 
Index: a/drivers/ide/pci/siimage.c
===================================================================
--- a.orig/drivers/ide/pci/siimage.c
+++ a/drivers/ide/pci/siimage.c
@@ -461,11 +461,11 @@ static int siimage_mmio_ide_dma_test_irq
 	unsigned long addr	= siimage_selreg(hwif, 0x1);
 
 	if (SATA_ERROR_REG) {
-		u32 ext_stat = hwif->INL(base + 0x10);
+		u32 ext_stat = readl((void __iomem *)(base + 0x10));
 		u8 watchdog = 0;
 		if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
-			u32 sata_error = hwif->INL(SATA_ERROR_REG);
-			hwif->OUTL(sata_error, SATA_ERROR_REG);
+			u32 sata_error = readl((void __iomem *)SATA_ERROR_REG);
+			writel(sata_error, (void __iomem *)SATA_ERROR_REG);
 			watchdog = (sata_error & 0x00680000) ? 1 : 0;
 			printk(KERN_WARNING "%s: sata_error = 0x%08x, "
 				"watchdog = %d, %s\n",
@@ -482,11 +482,11 @@ static int siimage_mmio_ide_dma_test_irq
 	}
 
 	/* return 1 if INTR asserted */
-	if ((hwif->INB(hwif->dma_status) & 0x04) == 0x04)
+	if ((readb((void __iomem *)hwif->dma_status) & 0x04) == 0x04)
 		return 1;
 
 	/* return 1 if Device INTR asserted */
-	if ((hwif->INB(addr) & 8) == 8)
+	if ((readb((void __iomem *)addr) & 8) == 8)
 		return 0;	//return 1;
 
 	return 0;
@@ -508,9 +508,9 @@ static int siimage_busproc (ide_drive_t 
 	u32 stat_config		= 0;
 	unsigned long addr	= siimage_selreg(hwif, 0);
 
-	if (hwif->mmio) {
-		stat_config = hwif->INL(addr);
-	} else
+	if (hwif->mmio)
+		stat_config = readl((void __iomem *)addr);
+	else
 		pci_read_config_dword(hwif->pci_dev, addr, &stat_config);
 
 	switch (state) {
@@ -546,9 +546,10 @@ static int siimage_reset_poll (ide_drive
 	if (SATA_STATUS_REG) {
 		ide_hwif_t *hwif	= HWIF(drive);
 
-		if ((hwif->INL(SATA_STATUS_REG) & 0x03) != 0x03) {
+		/* SATA_STATUS_REG is valid only when in MMIO mode */
+		if ((readl((void __iomem *)SATA_STATUS_REG) & 0x03) != 0x03) {
 			printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
-				hwif->name, hwif->INL(SATA_STATUS_REG));
+				hwif->name, readl((void __iomem *)SATA_STATUS_REG));
 			HWGROUP(drive)->polling = 0;
 			return ide_started;
 		}
@@ -608,7 +609,8 @@ static void siimage_reset (ide_drive_t *
 	}
 
 	if (SATA_STATUS_REG) {
-		u32 sata_stat = hwif->INL(SATA_STATUS_REG);
+		/* SATA_STATUS_REG is valid only when in MMIO mode */
+		u32 sata_stat = readl((void __iomem *)SATA_STATUS_REG);
 		printk(KERN_WARNING "%s: reset phy, status=0x%08x, %s\n",
 			hwif->name, sata_stat, __FUNCTION__);
 		if (!(sata_stat)) {
Index: a/drivers/ide/pci/sl82c105.c
===================================================================
--- a.orig/drivers/ide/pci/sl82c105.c
+++ a/drivers/ide/pci/sl82c105.c
@@ -215,7 +215,7 @@ static int sl82c105_ide_dma_lost_irq(ide
 	 * Was DMA enabled?  If so, disable it - we're resetting the
 	 * host.  The IDE layer will be handling the drive for us.
 	 */
-	val = hwif->INB(dma_base);
+	val = inb(dma_base);
 	if (val & 1) {
 		outb(val & ~1, dma_base);
 		printk("sl82c105: DMA was enabled\n");
@@ -431,7 +431,7 @@ static void __devinit init_hwif_sl82c105
 	if (!hwif->dma_base)
 		return;
 
-	dma_state = hwif->INB(hwif->dma_base + 2) & ~0x60;
+	dma_state = inb(hwif->dma_base + 2) & ~0x60;
 	rev = sl82c105_bridge_revision(hwif->pci_dev);
 	if (rev <= 5) {
 		/*
@@ -462,7 +462,7 @@ static void __devinit init_hwif_sl82c105
 		if (hwif->mate)
 			hwif->serialized = hwif->mate->serialized = 1;
 	}
-	hwif->OUTB(dma_state, hwif->dma_base + 2);
+	outb(dma_state, hwif->dma_base + 2);
 }
 
 static ide_pci_device_t sl82c105_chipset __devinitdata = {
Index: a/drivers/ide/pci/tc86c001.c
===================================================================
--- a.orig/drivers/ide/pci/tc86c001.c
+++ a/drivers/ide/pci/tc86c001.c
@@ -45,7 +45,7 @@ static int tc86c001_tune_chipset(ide_dri
 
 	scr &= (speed < XFER_MW_DMA_0) ? 0xf8ff : 0xff0f;
 	scr |= mode;
-	hwif->OUTW(scr, scr_port);
+	outw(scr, scr_port);
 
 	return ide_config_drive_speed(drive, speed);
 }
@@ -89,15 +89,15 @@ static int tc86c001_timer_expiry(ide_dri
 		       "attempting recovery...\n", drive->name);
 
 		/* Stop DMA */
-		hwif->OUTB(dma_cmd & ~0x01, hwif->dma_command);
+		outb(dma_cmd & ~0x01, hwif->dma_command);
 
 		/* Setup the dummy DMA transfer */
-		hwif->OUTW(0, sc_base + 0x0a);	/* Sector Count */
-		hwif->OUTW(0, twcr_port);	/* Transfer Word Count 1 or 2 */
+		outw(0, sc_base + 0x0a);	/* Sector Count */
+		outw(0, twcr_port);	/* Transfer Word Count 1 or 2 */
 
 		/* Start the dummy DMA transfer */
-		hwif->OUTB(0x00, hwif->dma_command); /* clear R_OR_WCTR for write */
-		hwif->OUTB(0x01, hwif->dma_command); /* set START_STOPBM */
+		outb(0x00, hwif->dma_command); /* clear R_OR_WCTR for write */
+		outb(0x01, hwif->dma_command); /* set START_STOPBM */
 
 		/*
 		 * If an interrupt was pending, it should come thru shortly.
@@ -128,8 +128,8 @@ static void tc86c001_dma_start(ide_drive
 	 * the appropriate system control registers for DMA to work
 	 * with LBA48 and ATAPI devices...
 	 */
-	hwif->OUTW(nsectors, sc_base + 0x0a);	/* Sector Count */
-	hwif->OUTW(SECTOR_SIZE / 2, twcr_port); /* Transfer Word Count 1/2 */
+	outw(nsectors, sc_base + 0x0a);	/* Sector Count */
+	outw(SECTOR_SIZE / 2, twcr_port); /* Transfer Word Count 1/2 */
 
 	/* Install our timeout expiry hook, saving the current handler... */
 	ide_set_hwifdata(hwif, hwgroup->expiry);
@@ -168,7 +168,7 @@ static int tc86c001_busproc(ide_drive_t 
 	}
 
 	/* System Control 1 Register bit 11 (ATA Hard Reset) write */
-	hwif->OUTW(scr1, sc_base + 0x00);
+	outw(scr1, sc_base + 0x00);
 	return 0;
 }
 
@@ -204,13 +204,13 @@ static void __devinit init_hwif_tc86c001
 	u16 scr1		= hwif->INW(sc_base + 0x00);;
 
 	/* System Control 1 Register bit 15 (Soft Reset) set */
-	hwif->OUTW(scr1 |  0x8000, sc_base + 0x00);
+	outw(scr1 |  0x8000, sc_base + 0x00);
 
 	/* System Control 1 Register bit 14 (FIFO Reset) set */
-	hwif->OUTW(scr1 |  0x4000, sc_base + 0x00);
+	outw(scr1 |  0x4000, sc_base + 0x00);
 
 	/* System Control 1 Register: reset clear */
-	hwif->OUTW(scr1 & ~0xc000, sc_base + 0x00);
+	outw(scr1 & ~0xc000, sc_base + 0x00);
 
 	/* Store the system control register base for convenience... */
 	hwif->config_data = sc_base;
@@ -228,7 +228,7 @@ static void __devinit init_hwif_tc86c001
 	 * Sector Count Control Register bits 0 and 1 set:
 	 * software sets Sector Count Register for master and slave device
 	 */
-	hwif->OUTW(0x0003, sc_base + 0x0c);
+	outw(0x0003, sc_base + 0x0c);
 
 	/* Sector Count Register limit */
 	hwif->rqsize	 = 0xffff;
Index: a/drivers/ide/pci/trm290.c
===================================================================
--- a.orig/drivers/ide/pci/trm290.c
+++ a/drivers/ide/pci/trm290.c
@@ -157,16 +157,16 @@ static void trm290_prepare_drive (ide_dr
 	if (reg != hwif->select_data) {
 		hwif->select_data = reg;
 		/* set PIO/DMA */
-		hwif->OUTB(0x51|(hwif->channel<<3), hwif->config_data+1);
-		hwif->OUTW(reg & 0xff, hwif->config_data);
+		outb(0x51 | (hwif->channel << 3), hwif->config_data + 1);
+		outw(reg & 0xff, hwif->config_data);
 	}
 
 	/* enable IRQ if not probing */
 	if (drive->present) {
-		reg = hwif->INW(hwif->config_data + 3);
+		reg = inw(hwif->config_data + 3);
 		reg &= 0x13;
 		reg &= ~(1 << hwif->channel);
-		hwif->OUTW(reg, hwif->config_data+3);
+		outw(reg, hwif->config_data + 3);
 	}
 
 	local_irq_restore(flags);
@@ -179,12 +179,10 @@ static void trm290_selectproc (ide_drive
 
 static void trm290_ide_dma_exec_cmd(ide_drive_t *drive, u8 command)
 {
-	ide_hwif_t *hwif	= HWIF(drive);
-
 	BUG_ON(HWGROUP(drive)->handler != NULL);	/* paranoia check */
 	ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
 	/* issue cmd to drive */
-	hwif->OUTB(command, IDE_COMMAND_REG);
+	outb(command, IDE_COMMAND_REG);
 }
 
 static int trm290_ide_dma_setup(ide_drive_t *drive)
@@ -210,10 +208,10 @@ static int trm290_ide_dma_setup(ide_driv
 	}
 	/* select DMA xfer */
 	trm290_prepare_drive(drive, 1);
-	hwif->OUTL(hwif->dmatable_dma|rw, hwif->dma_command);
+	outl(hwif->dmatable_dma | rw, hwif->dma_command);
 	drive->waiting_for_dma = 1;
 	/* start DMA */
-	hwif->OUTW((count * 2) - 1, hwif->dma_status);
+	outw((count * 2) - 1, hwif->dma_status);
 	return 0;
 }
 
@@ -229,7 +227,7 @@ static int trm290_ide_dma_end (ide_drive
 	drive->waiting_for_dma = 0;
 	/* purge DMA mappings */
 	ide_destroy_dmatable(drive);
-	status = hwif->INW(hwif->dma_status);
+	status = inw(hwif->dma_status);
 	return (status != 0x00ff);
 }
 
@@ -238,7 +236,7 @@ static int trm290_ide_dma_test_irq (ide_
 	ide_hwif_t *hwif = HWIF(drive);
 	u16 status = 0;
 
-	status = hwif->INW(hwif->dma_status);
+	status = inw(hwif->dma_status);
 	return (status == 0x00ff);
 }
 
@@ -267,15 +265,15 @@ static void __devinit init_hwif_trm290(i
 
 	local_irq_save(flags);
 	/* put config reg into first byte of hwif->select_data */
-	hwif->OUTB(0x51|(hwif->channel<<3), hwif->config_data+1);
+	outb(0x51 | (hwif->channel << 3), hwif->config_data + 1);
 	/* select PIO as default */
 	hwif->select_data = 0x21;
-	hwif->OUTB(hwif->select_data, hwif->config_data);
+	outb(hwif->select_data, hwif->config_data);
 	/* get IRQ info */
-	reg = hwif->INB(hwif->config_data+3);
+	reg = inb(hwif->config_data + 3);
 	/* mask IRQs for both ports */
 	reg = (reg & 0x10) | 0x03;
-	hwif->OUTB(reg, hwif->config_data+3);
+	outb(reg, hwif->config_data + 3);
 	local_irq_restore(flags);
 
 	if ((reg & 0x10))
@@ -308,16 +306,16 @@ static void __devinit init_hwif_trm290(i
 		static u16 next_offset = 0;
 		u8 old_mask;
 
-		hwif->OUTB(0x54|(hwif->channel<<3), hwif->config_data+1);
-		old = hwif->INW(hwif->config_data);
+		outb(0x54 | (hwif->channel << 3), hwif->config_data + 1);
+		old = inw(hwif->config_data);
 		old &= ~1;
-		old_mask = hwif->INB(old+2);
+		old_mask = inb(old + 2);
 		if (old != compat && old_mask == 0xff) {
 			/* leave lower 10 bits untouched */
 			compat += (next_offset += 0x400);
 			hwif->io_ports[IDE_CONTROL_OFFSET] = compat + 2;
-			hwif->OUTW(compat|1, hwif->config_data);
-			new = hwif->INW(hwif->config_data);
+			outw(compat | 1, hwif->config_data);
+			new = inw(hwif->config_data);
 			printk(KERN_INFO "%s: control basereg workaround: "
 				"old=0x%04x, new=0x%04x\n",
 				hwif->name, old, new & ~1);
Index: a/include/linux/ide.h
===================================================================
--- a.orig/include/linux/ide.h
+++ a/include/linux/ide.h
@@ -734,13 +734,11 @@ typedef struct hwif_s {
 	void (*OUTB)(u8 addr, unsigned long port);
 	void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port);
 	void (*OUTW)(u16 addr, unsigned long port);
-	void (*OUTL)(u32 addr, unsigned long port);
 	void (*OUTSW)(unsigned long port, void *addr, u32 count);
 	void (*OUTSL)(unsigned long port, void *addr, u32 count);
 
 	u8  (*INB)(unsigned long port);
 	u16 (*INW)(unsigned long port);
-	u32 (*INL)(unsigned long port);
 	void (*INSW)(unsigned long port, void *addr, u32 count);
 	void (*INSL)(unsigned long port, void *addr, u32 count);
 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 19/19] ide: use PIO/MMIO operations directly where possible
  2007-01-12  4:28 ` [PATCH 19/19] ide: use PIO/MMIO operations directly where possible Bartlomiej Zolnierkiewicz
@ 2007-01-12 10:06   ` Alan
  2007-01-12 14:19     ` Bartlomiej Zolnierkiewicz
  2007-06-21 17:16   ` Sergei Shtylyov
  1 sibling, 1 reply; 28+ messages in thread
From: Alan @ 2007-01-12 10:06 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: linux-ide, Bartlomiej Zolnierkiewicz, linux-kernel

On Fri, 12 Jan 2007 05:28:07 +0100
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:

> [PATCH] ide: use PIO/MMIO operations directly where possible
> 
> This results in smaller/faster/simpler code and allows future optimizations.
> Also remove no longer needed ide[_mm]_{inl,outl}() and ide_hwif_t.{INL,OUTL}.
> 
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

> --- a.orig/drivers/ide/ide-dma.c
> +++ a/drivers/ide/ide-dma.c
> @@ -565,7 +565,10 @@ int ide_dma_setup(ide_drive_t *drive)
>  	}
>  
>  	/* PRD table */
> -	hwif->OUTL(hwif->dmatable_dma, hwif->dma_prdtable);
> +	if (hwif->mmio == 2)
> +		writel(hwif->dmatable_dma, (void __iomem *)hwif->dma_prdtable);
> +	else
> +		outl(hwif->dmatable_dma, hwif->dma_prdtable);


This should simply be if (hwif->mmio)

mmio = 1 is still used by some amiga and other oddments and indicates
mmio in old form. I don't think this causes a bug as they don't use the
DMA layer, but its a bug waiting to happen if the mmio==1 case doesn't
get handled correctly or BUG()

Alan

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ide: add ide_use_fast_pio() helper
  2007-01-12  4:28 ` [PATCH 18/19] ide: add ide_use_fast_pio() helper Bartlomiej Zolnierkiewicz
@ 2007-01-12 10:08   ` Alan
  2007-01-12 14:00     ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 28+ messages in thread
From: Alan @ 2007-01-12 10:08 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: linux-ide, Bartlomiej Zolnierkiewicz, linux-kernel

On Fri, 12 Jan 2007 05:28:00 +0100
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:

> [PATCH] ide: add ide_use_fast_pio() helper
> 
> * add ide_use_fast_pio() helper for use by host drivers
> * add DMA capability and autodma checks to ide_use_dma()
>   - au1xxx-ide/it8213/it821x drivers didn't check for (id->capability & 1)

For the IT8211/2 in SMART this check shouldn't be made.

>   - ide-cris driver didn't set ->autodma

You've changed the behaviour there. Should the default be autodma=0 ?


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ide: add ide_use_fast_pio() helper
  2007-01-12 10:08   ` Alan
@ 2007-01-12 14:00     ` Bartlomiej Zolnierkiewicz
  2007-01-12 14:30       ` Alan
  0 siblings, 1 reply; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12 14:00 UTC (permalink / raw)
  To: Alan; +Cc: linux-ide, linux-kernel

On 1/12/07, Alan <alan@lxorguk.ukuu.org.uk> wrote:
> On Fri, 12 Jan 2007 05:28:00 +0100
> Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:
>
> > [PATCH] ide: add ide_use_fast_pio() helper
> >
> > * add ide_use_fast_pio() helper for use by host drivers
> > * add DMA capability and autodma checks to ide_use_dma()
> >   - au1xxx-ide/it8213/it821x drivers didn't check for (id->capability & 1)
>
> For the IT8211/2 in SMART this check shouldn't be made.

It is OK since in it821x_fixups() we set it explicitly:

		if(strstr(id->model, "Integrated Technology Express")) {
			/* In raid mode the ident block is slightly buggy
			   We need to set the bits so that the IDE layer knows
			   LBA28. LBA48 and DMA ar valid */
			id->capability |= 3;		/* LBA28, DMA */

and we are better off using generic helper if we can
(which may later allow us to use generic tuning code).

> >   - ide-cris driver didn't set ->autodma
>
> You've changed the behaviour there. Should the default be autodma=0 ?

Before my patch hwif->autodma was only checked in the chipset specific
hwif->ide_dma_check implementations.  For ide-cris it is
cris_dma_check()
function so there no behavior change here.

Sorry for not explaining changes in detail in the patch description
(I will update it).

Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 19/19] ide: use PIO/MMIO operations directly where possible
  2007-01-12 10:06   ` Alan
@ 2007-01-12 14:19     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12 14:19 UTC (permalink / raw)
  To: Alan; +Cc: linux-ide, linux-kernel

On 1/12/07, Alan <alan@lxorguk.ukuu.org.uk> wrote:
> On Fri, 12 Jan 2007 05:28:07 +0100
> Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:
>
> > [PATCH] ide: use PIO/MMIO operations directly where possible
> >
> > This results in smaller/faster/simpler code and allows future optimizations.
> > Also remove no longer needed ide[_mm]_{inl,outl}() and ide_hwif_t.{INL,OUTL}.
> >
> > Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
>
> > --- a.orig/drivers/ide/ide-dma.c
> > +++ a/drivers/ide/ide-dma.c
> > @@ -565,7 +565,10 @@ int ide_dma_setup(ide_drive_t *drive)
> >       }
> >
> >       /* PRD table */
> > -     hwif->OUTL(hwif->dmatable_dma, hwif->dma_prdtable);
> > +     if (hwif->mmio == 2)
> > +             writel(hwif->dmatable_dma, (void __iomem *)hwif->dma_prdtable);
> > +     else
> > +             outl(hwif->dmatable_dma, hwif->dma_prdtable);
>
>
> This should simply be if (hwif->mmio)
>
> mmio = 1 is still used by some amiga and other oddments and indicates
> mmio in old form. I don't think this causes a bug as they don't use the
> DMA layer, but its a bug waiting to happen if the mmio==1 case doesn't
> get handled correctly or BUG()

mmio = 1 isn't used in the current IDE code and we have BUG_ON()
for it in ide.c:ide_hwif_request_regions() so the above change is safe.

Anyway thanks for bringing mmio = 1 issue - it can be converted
to flag now (will let us avoid similar confusions in the future).

Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ide: add ide_use_fast_pio() helper
  2007-01-12 14:00     ` Bartlomiej Zolnierkiewicz
@ 2007-01-12 14:30       ` Alan
  2007-01-12 14:43         ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 28+ messages in thread
From: Alan @ 2007-01-12 14:30 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel

> 		if(strstr(id->model, "Integrated Technology Express")) {
> 			/* In raid mode the ident block is slightly buggy
> 			   We need to set the bits so that the IDE layer knows
> 			   LBA28. LBA48 and DMA ar valid */
> 			id->capability |= 3;		/* LBA28, DMA */
> 
> and we are better off using generic helper if we can
> (which may later allow us to use generic tuning code).

IT8212 in smart mode has no tuning at all, the real modes are hidden by
the controller. Some firmware versions don't seem to be like being fed
set features commands either hence the total lack of tuning.

> 
> Before my patch hwif->autodma was only checked in the chipset specific
> hwif->ide_dma_check implementations.  For ide-cris it is
> cris_dma_check()
> function so there no behavior change here.

Ok

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ide: add ide_use_fast_pio() helper
  2007-01-12 14:30       ` Alan
@ 2007-01-12 14:43         ` Bartlomiej Zolnierkiewicz
  2007-01-12 15:16           ` Alan
  0 siblings, 1 reply; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12 14:43 UTC (permalink / raw)
  To: Alan; +Cc: linux-ide, linux-kernel

On 1/12/07, Alan <alan@lxorguk.ukuu.org.uk> wrote:
> >               if(strstr(id->model, "Integrated Technology Express")) {
> >                       /* In raid mode the ident block is slightly buggy
> >                          We need to set the bits so that the IDE layer knows
> >                          LBA28. LBA48 and DMA ar valid */
> >                       id->capability |= 3;            /* LBA28, DMA */
> >
> > and we are better off using generic helper if we can
> > (which may later allow us to use generic tuning code).
>
> IT8212 in smart mode has no tuning at all, the real modes are hidden by
> the controller. Some firmware versions don't seem to be like being fed
> set features commands either hence the total lack of tuning.

[ The discussed "ide: add ide_use_fast_pio() helper" patch doesn't fix it
  but it doesn't break anything either (it doesn't change the current
behavior). ]

It seems that it821x_tune_chipset() is buggy since it sends SET FEATURES
command even when in smart mode.  Shouldn't there be "don't tune" flag
in it812x_fixups() to tell it821x_tune_chipset() to not send SET FEATURES
commands?

Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ide: add ide_use_fast_pio() helper
  2007-01-12 14:43         ` Bartlomiej Zolnierkiewicz
@ 2007-01-12 15:16           ` Alan
  2007-01-12 17:24             ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 28+ messages in thread
From: Alan @ 2007-01-12 15:16 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel

> It seems that it821x_tune_chipset() is buggy since it sends SET FEATURES
> command even when in smart mode.  Shouldn't there be "don't tune" flag
> in it812x_fixups() to tell it821x_tune_chipset() to not send SET FEATURES
> commands?

It's itdev->smart but falls through to ide_config_drive_speed while it
should probably just copy bits of the code from it. Thats all fixed in
the libata driver which allows chip specific mode setup.


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ide: add ide_use_fast_pio() helper
  2007-01-12 15:16           ` Alan
@ 2007-01-12 17:24             ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-01-12 17:24 UTC (permalink / raw)
  To: Alan; +Cc: linux-ide, linux-kernel

On 1/12/07, Alan <alan@lxorguk.ukuu.org.uk> wrote:
> > It seems that it821x_tune_chipset() is buggy since it sends SET FEATURES
> > command even when in smart mode.  Shouldn't there be "don't tune" flag
> > in it812x_fixups() to tell it821x_tune_chipset() to not send SET FEATURES
> > commands?
>
> It's itdev->smart but falls through to ide_config_drive_speed while it
> should probably just copy bits of the code from it. Thats all fixed in
> the libata driver which allows chip specific mode setup.

ide_config_drive_speed() does the following things:
1. disables host DMA
2. sends SET FEATURES command (in polling mode)
3. re-enables host DMA (only if DMA mode was set)
4. updates drive->id->dma_{ultra,mword,1word}
5. updates drive->{current,init}_speed

1. and 2. should really go to higher layers
3. obviously shouldn't be done for itdev->smart
4. also shouldn't be done for itdev>smart
   (we are not changing speed mode)
5. should be done once outside of it821x_tune_chipset()

Therefore current TODO looks like:
* moving DMA fiddling code out of ide_config_drive_speed()
* setting drive->{current,init} speed in it821x_fixups()
* fixing it821x not to call ide_config_drive_speed() for itdev->smart

Fixing user space generated requests requires more work
(i.e. adding ->set_mode method)...

I'll try to cook up some patches later unless somebody beats me to it.

Thanks,
Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 19/19] ide: use PIO/MMIO operations directly where possible
  2007-01-12  4:28 ` [PATCH 19/19] ide: use PIO/MMIO operations directly where possible Bartlomiej Zolnierkiewicz
  2007-01-12 10:06   ` Alan
@ 2007-06-21 17:16   ` Sergei Shtylyov
  2007-06-21 18:19     ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 28+ messages in thread
From: Sergei Shtylyov @ 2007-06-21 17:16 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel

Hello.

Bartlomiej Zolnierkiewicz wrote:
> [PATCH] ide: use PIO/MMIO operations directly where possible

> This results in smaller/faster/simpler code and allows future optimizations.
> Also remove no longer needed ide[_mm]_{inl,outl}() and ide_hwif_t.{INL,OUTL}.

> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

> Index: a/drivers/ide/pci/hpt366.c
> ===================================================================
> --- a.orig/drivers/ide/pci/hpt366.c
> +++ a/drivers/ide/pci/hpt366.c
> @@ -836,7 +836,7 @@ static int hpt374_ide_dma_test_irq(ide_d
>  		return 0;
>  	}
>  
> -	dma_stat = hwif->INB(hwif->dma_status);
> +	dma_stat = inb(hwif->dma_status);
>  	/* return 1 if INTR asserted */
>  	if (dma_stat & 4)
>  		return 1;

    Hmm... this driver *still* has a lot more indirect I/O accessors -- I 
wonder why only this one had been converted then?

MBR, Sergei


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 19/19] ide: use PIO/MMIO operations directly where possible
  2007-06-21 17:16   ` Sergei Shtylyov
@ 2007-06-21 18:19     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 28+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-06-21 18:19 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-ide, linux-kernel


Hi Sergei,

On Thursday 21 June 2007, Sergei Shtylyov wrote:
> Hello.
> 
> Bartlomiej Zolnierkiewicz wrote:
> > [PATCH] ide: use PIO/MMIO operations directly where possible
> 
> > This results in smaller/faster/simpler code and allows future optimizations.
> > Also remove no longer needed ide[_mm]_{inl,outl}() and ide_hwif_t.{INL,OUTL}.
> 
> > Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> 
> > Index: a/drivers/ide/pci/hpt366.c
> > ===================================================================
> > --- a.orig/drivers/ide/pci/hpt366.c
> > +++ a/drivers/ide/pci/hpt366.c
> > @@ -836,7 +836,7 @@ static int hpt374_ide_dma_test_irq(ide_d
> >  		return 0;
> >  	}
> >  
> > -	dma_stat = hwif->INB(hwif->dma_status);
> > +	dma_stat = inb(hwif->dma_status);
> >  	/* return 1 if INTR asserted */
> >  	if (dma_stat & 4)
> >  		return 1;
> 
>     Hmm... this driver *still* has a lot more indirect I/O accessors -- I 
> wonder why only this one had been converted then?

The reason for this is that my patch was done before some of your patches
for HPT IDE driver and I never really got to doing follow-up patch.

IIRC piix.c and and tc86c100.c may also want an update.

Thanks,
Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2007-06-21 18:03 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-12  4:26 [PATCH 2/19] ide: add it8213 driver Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 3/19] ide: it8213 driver update Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 4/19] ia64: add pci_get_legacy_ide_irq() Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 5/19] ide: add missing __init tags to IDE PCI host drivers Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 6/19] pdc202xx_old: remove dead code Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 7/19] au1xxx-ide: " Bartlomiej Zolnierkiewicz
2007-01-12  4:26 ` [PATCH 8/19] ide: remove write-only ide_pio_data_t.blacklisted Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 9/19] ide: remove write-only ide_hwif_t.no_dsc flag Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 10/19] trm290: remove redundant CONFIG_BLK_DEV_IDEDMA Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 11/19] ide: remove ide_pci_device_t tables with only one entry Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 12/19] ide: remove ide_drive_t.usage Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 13/19] hpt366: remove redundant check from init_dma_hpt366() Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 14/19] cs5530: small cleanup Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 15/19] svwks: " Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 16/19] sis5513: sis5513_config_xfer_rate() cleanup Bartlomiej Zolnierkiewicz
2007-01-12  4:27 ` [PATCH 17/19] ide: unexport ide_set_xfer_rate() Bartlomiej Zolnierkiewicz
2007-01-12  4:28 ` [PATCH 18/19] ide: add ide_use_fast_pio() helper Bartlomiej Zolnierkiewicz
2007-01-12 10:08   ` Alan
2007-01-12 14:00     ` Bartlomiej Zolnierkiewicz
2007-01-12 14:30       ` Alan
2007-01-12 14:43         ` Bartlomiej Zolnierkiewicz
2007-01-12 15:16           ` Alan
2007-01-12 17:24             ` Bartlomiej Zolnierkiewicz
2007-01-12  4:28 ` [PATCH 19/19] ide: use PIO/MMIO operations directly where possible Bartlomiej Zolnierkiewicz
2007-01-12 10:06   ` Alan
2007-01-12 14:19     ` Bartlomiej Zolnierkiewicz
2007-06-21 17:16   ` Sergei Shtylyov
2007-06-21 18:19     ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).