summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/cris/ide-cris.c12
-rw-r--r--drivers/ide/ide-dma.c3
-rw-r--r--drivers/ide/ide-lib.c15
-rw-r--r--drivers/ide/pci/aec62xx.c14
-rw-r--r--drivers/ide/pci/atiixp.c14
-rw-r--r--drivers/ide/pci/cmd64x.c14
-rw-r--r--drivers/ide/pci/cs5535.c13
-rw-r--r--drivers/ide/pci/hpt34x.c16
-rw-r--r--drivers/ide/pci/hpt366.c11
-rw-r--r--drivers/ide/pci/pdc202xx_new.c12
-rw-r--r--drivers/ide/pci/pdc202xx_old.c14
-rw-r--r--drivers/ide/pci/piix.c12
-rw-r--r--drivers/ide/pci/serverworks.c14
-rw-r--r--drivers/ide/pci/siimage.c14
-rw-r--r--drivers/ide/pci/sis5513.c14
-rw-r--r--drivers/ide/pci/slc90e66.c12
-rw-r--r--drivers/ide/pci/tc86c001.c12
-rw-r--r--drivers/ide/pci/triflex.c9
-rw-r--r--drivers/ide/ppc/scc_pata.c13
-rw-r--r--include/linux/ide.h1
20 files changed, 73 insertions, 166 deletions
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index 5797e0b5a132..7afb715b86e5 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/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 (ide_drive_t *drive)
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);
}
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 56efed6742d4..941846c21624 100644
--- a/drivers/ide/ide-dma.c
+++ b/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;
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index bea5e13ee361..8afce4ceea31 100644
--- a/drivers/ide/ide-lib.c
+++ b/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*.
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index cac12c38b940..199507391ae8 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -210,19 +210,11 @@ static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)
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);
}
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index 922b315da4a0..dfc738c42228 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -253,22 +253,14 @@ static int atiixp_config_drive_for_dma(ide_drive_t *drive)
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);
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 009fc9168443..b1f9f5f3615e 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -475,19 +475,11 @@ static int config_chipset_for_dma (ide_drive_t *drive)
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);
}
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 5c5aec28e671..e47653f4d1dd 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -196,21 +196,14 @@ static int cs5535_config_drive_for_dma(ide_drive_t *drive)
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);
- }
-
- goto fast_ata_pio;
+ if (ide_use_dma(drive) && cs5535_config_drive_for_dma(drive))
+ return hwif->ide_dma_on(drive);
- } 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);
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 0de3b61cabe3..0830089c77fd 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -110,25 +110,17 @@ static int config_chipset_for_dma (ide_drive_t *drive)
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);
}
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 06dce0999105..d3f6f9da96b2 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -737,18 +737,13 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
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);
-
- goto fast_ata_pio;
+ if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+ return hwif->ide_dma_on(drive);
- } 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);
}
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 236a03144a27..b13a06c5cb2d 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -282,19 +282,13 @@ static int config_chipset_for_dma(ide_drive_t *drive)
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);
-
- goto fast_ata_pio;
+ if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+ return hwif->ide_dma_on(drive);
- } 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);
}
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index 80eb6d271330..a2be3d2fd3f6 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -323,21 +323,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)) {
- if (config_chipset_for_dma(drive))
- return hwif->ide_dma_on(drive);
- }
-
- goto fast_ata_pio;
+ if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+ return hwif->ide_dma_on(drive);
- } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+ if (ide_use_fast_pio(drive)) {
pdc202xx_tune_drive(drive, 255);
return hwif->ide_dma_off_quietly(drive);
}
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 247334473519..85e8a78e10ad 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -387,19 +387,13 @@ static int piix_config_drive_for_dma (ide_drive_t *drive)
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));
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 81a0742c4594..9e92e7ba0227 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -316,21 +316,13 @@ static int config_chipset_for_dma (ide_drive_t *drive)
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);
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index ad98510026a5..367733c8c1de 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -415,19 +415,11 @@ static int config_chipset_for_dma (ide_drive_t *drive)
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);
}
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index e71552e64ae4..4fff663a6432 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -670,23 +670,15 @@ static int config_chipset_for_dma (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) {
+ 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);
}
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index 2663ddbd9b67..4042fd8e2308 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -180,19 +180,13 @@ static int slc90e66_config_drive_for_dma (ide_drive_t *drive)
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);
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index 2ad72bbda342..4e893808f063 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -186,17 +186,11 @@ static int config_chipset_for_dma(ide_drive_t *drive)
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);
}
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index b0d29cd7123a..1f5f6759fef8 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -114,14 +114,9 @@ static int triflex_config_drive_for_dma(ide_drive_t *drive)
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);
diff --git a/drivers/ide/ppc/scc_pata.c b/drivers/ide/ppc/scc_pata.c
index 65ad8ab34598..0ab26ea5a35a 100644
--- a/drivers/ide/ppc/scc_pata.c
+++ b/drivers/ide/ppc/scc_pata.c
@@ -383,16 +383,11 @@ static int scc_config_chipset_for_dma(ide_drive_t *drive)
static int scc_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)) {
- if (scc_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_dma(drive) && scc_config_chipset_for_dma(drive))
+ return hwif->ide_dma_on(drive);
+
+ if (ide_use_fast_pio(drive)) {
hwif->tuneproc(drive, 4);
hwif->ide_dma_off_quietly(drive);
}
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 40b5fa2f2627..9e1a8b9ce182 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1352,6 +1352,7 @@ extern int ide_dma_enable(ide_drive_t *drive);
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);
OpenPOWER on IntegriCloud