aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-02-16 20:40:25 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-02-16 20:40:25 -0500
commit7569e8dc2213ecc47024ea5edbadc8736487d926 (patch)
tree44c47e85b5e87c75972c077da31f198c4f597688
parent056a697b7388844a1341e92e277bff8e5bf61ec9 (diff)
ide: add ide_use_fast_pio() helper (v3)
* add ide_use_fast_pio() helper for use by host drivers * add DMA capability and hwif->autodma checks to ide_use_dma() - au1xxx-ide/it8213/it821x drivers didn't check for (id->capability & 1) [ for the IT8211/2 in SMART mode this check shouldn't be made but since in it821x_fixups() we set DMA bit 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 */ we are better off using generic helper if we can ] - ide-cris driver didn't set ->autodma [ before the 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 ] v2: * updated patch description (thanks to Alan Cox for the feedback) v3: * updated for scc_pata driver Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-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)
821 hwif->ultra_mask = cris_ultra_mask; 821 hwif->ultra_mask = cris_ultra_mask;
822 hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */ 822 hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
823 hwif->swdma_mask = 0x07; /* Singleword DMA 0-2 */ 823 hwif->swdma_mask = 0x07; /* Singleword DMA 0-2 */
824 hwif->autodma = 1;
825 hwif->drives[0].autodma = 1;
826 hwif->drives[1].autodma = 1;
824 } 827 }
825 828
826 /* Reset pulse */ 829 /* Reset pulse */
@@ -1046,14 +1049,9 @@ static ide_startstop_t cris_dma_intr (ide_drive_t *drive)
1046static int cris_dma_check(ide_drive_t *drive) 1049static int cris_dma_check(ide_drive_t *drive)
1047{ 1050{
1048 ide_hwif_t *hwif = drive->hwif; 1051 ide_hwif_t *hwif = drive->hwif;
1049 struct hd_driveid* id = drive->id;
1050 1052
1051 if (id && (id->capability & 1)) { 1053 if (ide_use_dma(drive) && cris_config_drive_for_dma(drive))
1052 if (ide_use_dma(drive)) { 1054 return hwif->ide_dma_on(drive);
1053 if (cris_config_drive_for_dma(drive))
1054 return hwif->ide_dma_on(drive);
1055 }
1056 }
1057 1055
1058 return hwif->ide_dma_off_quietly(drive); 1056 return hwif->ide_dma_off_quietly(drive);
1059} 1057}
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)
680 struct hd_driveid *id = drive->id; 680 struct hd_driveid *id = drive->id;
681 ide_hwif_t *hwif = drive->hwif; 681 ide_hwif_t *hwif = drive->hwif;
682 682
683 if ((id->capability & 1) == 0 || drive->autodma == 0)
684 return 0;
685
683 /* consult the list of known "bad" drives */ 686 /* consult the list of known "bad" drives */
684 if (__ide_dma_bad_drive(drive)) 687 if (__ide_dma_bad_drive(drive))
685 return 0; 688 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)
205 205
206EXPORT_SYMBOL(ide_dma_enable); 206EXPORT_SYMBOL(ide_dma_enable);
207 207
208int ide_use_fast_pio(ide_drive_t *drive)
209{
210 struct hd_driveid *id = drive->id;
211
212 if ((id->capability & 1) && drive->autodma)
213 return 1;
214
215 if ((id->capability & 8) || (id->field_valid & 2))
216 return 1;
217
218 return 0;
219}
220
221EXPORT_SYMBOL_GPL(ide_use_fast_pio);
222
208/* 223/*
209 * Standard (generic) timings for PIO modes, from ATA2 specification. 224 * Standard (generic) timings for PIO modes, from ATA2 specification.
210 * These timings are for access to the IDE data port register *only*. 225 * 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)
210static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive) 210static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
211{ 211{
212 ide_hwif_t *hwif = HWIF(drive); 212 ide_hwif_t *hwif = HWIF(drive);
213 struct hd_driveid *id = drive->id;
214 213
215 if ((id->capability & 1) && drive->autodma) { 214 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
215 return hwif->ide_dma_on(drive);
216 216
217 if (ide_use_dma(drive)) { 217 if (ide_use_fast_pio(drive)) {
218 if (config_chipset_for_dma(drive))
219 return hwif->ide_dma_on(drive);
220 }
221
222 goto fast_ata_pio;
223
224 } else if ((id->capability & 8) || (id->field_valid & 2)) {
225fast_ata_pio:
226 aec62xx_tune_drive(drive, 5); 218 aec62xx_tune_drive(drive, 5);
227 return hwif->ide_dma_off_quietly(drive); 219 return hwif->ide_dma_off_quietly(drive);
228 } 220 }
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)
253static int atiixp_dma_check(ide_drive_t *drive) 253static int atiixp_dma_check(ide_drive_t *drive)
254{ 254{
255 ide_hwif_t *hwif = HWIF(drive); 255 ide_hwif_t *hwif = HWIF(drive);
256 struct hd_driveid *id = drive->id;
257 u8 tspeed, speed; 256 u8 tspeed, speed;
258 257
259 drive->init_speed = 0; 258 drive->init_speed = 0;
260 259
261 if ((id->capability & 1) && drive->autodma) { 260 if (ide_use_dma(drive) && atiixp_config_drive_for_dma(drive))
261 return hwif->ide_dma_on(drive);
262 262
263 if (ide_use_dma(drive)) { 263 if (ide_use_fast_pio(drive)) {
264 if (atiixp_config_drive_for_dma(drive))
265 return hwif->ide_dma_on(drive);
266 }
267
268 goto fast_ata_pio;
269
270 } else if ((id->capability & 8) || (id->field_valid & 2)) {
271fast_ata_pio:
272 tspeed = ide_get_best_pio_mode(drive, 255, 5, NULL); 264 tspeed = ide_get_best_pio_mode(drive, 255, 5, NULL);
273 speed = atiixp_dma_2_pio(XFER_PIO_0 + tspeed) + XFER_PIO_0; 265 speed = atiixp_dma_2_pio(XFER_PIO_0 + tspeed) + XFER_PIO_0;
274 hwif->speedproc(drive, speed); 266 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)
475static int cmd64x_config_drive_for_dma (ide_drive_t *drive) 475static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
476{ 476{
477 ide_hwif_t *hwif = HWIF(drive); 477 ide_hwif_t *hwif = HWIF(drive);
478 struct hd_driveid *id = drive->id;
479 478
480 if ((id != NULL) && ((id->capability & 1) != 0) && drive->autodma) { 479 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
480 return hwif->ide_dma_on(drive);
481 481
482 if (ide_use_dma(drive)) { 482 if (ide_use_fast_pio(drive)) {
483 if (config_chipset_for_dma(drive))
484 return hwif->ide_dma_on(drive);
485 }
486
487 goto fast_ata_pio;
488
489 } else if ((id->capability & 8) || (id->field_valid & 2)) {
490fast_ata_pio:
491 config_chipset_for_pio(drive, 1); 483 config_chipset_for_pio(drive, 1);
492 return hwif->ide_dma_off_quietly(drive); 484 return hwif->ide_dma_off_quietly(drive);
493 } 485 }
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)
196static int cs5535_dma_check(ide_drive_t *drive) 196static int cs5535_dma_check(ide_drive_t *drive)
197{ 197{
198 ide_hwif_t *hwif = drive->hwif; 198 ide_hwif_t *hwif = drive->hwif;
199 struct hd_driveid *id = drive->id;
200 u8 speed; 199 u8 speed;
201 200
202 drive->init_speed = 0; 201 drive->init_speed = 0;
203 202
204 if ((id->capability & 1) && drive->autodma) { 203 if (ide_use_dma(drive) && cs5535_config_drive_for_dma(drive))
205 if (ide_use_dma(drive)) { 204 return hwif->ide_dma_on(drive);
206 if (cs5535_config_drive_for_dma(drive))
207 return hwif->ide_dma_on(drive);
208 }
209
210 goto fast_ata_pio;
211 205
212 } else if ((id->capability & 8) || (id->field_valid & 2)) { 206 if (ide_use_fast_pio(drive)) {
213fast_ata_pio:
214 speed = ide_get_best_pio_mode(drive, 255, 4, NULL); 207 speed = ide_get_best_pio_mode(drive, 255, 4, NULL);
215 cs5535_set_drive(drive, speed); 208 cs5535_set_drive(drive, speed);
216 return hwif->ide_dma_off_quietly(drive); 209 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)
110static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive) 110static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
111{ 111{
112 ide_hwif_t *hwif = HWIF(drive); 112 ide_hwif_t *hwif = HWIF(drive);
113 struct hd_driveid *id = drive->id;
114 113
115 drive->init_speed = 0; 114 drive->init_speed = 0;
116 115
117 if (id && (id->capability & 1) && drive->autodma) { 116 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
118
119 if (ide_use_dma(drive)) {
120 if (config_chipset_for_dma(drive))
121#ifndef CONFIG_HPT34X_AUTODMA 117#ifndef CONFIG_HPT34X_AUTODMA
122 return hwif->ide_dma_off_quietly(drive); 118 return hwif->ide_dma_off_quietly(drive);
123#else 119#else
124 return hwif->ide_dma_on(drive); 120 return hwif->ide_dma_on(drive);
125#endif 121#endif
126 }
127
128 goto fast_ata_pio;
129 122
130 } else if ((id->capability & 8) || (id->field_valid & 2)) { 123 if (ide_use_fast_pio(drive)) {
131fast_ata_pio:
132 hpt34x_tune_drive(drive, 255); 124 hpt34x_tune_drive(drive, 255);
133 return hwif->ide_dma_off_quietly(drive); 125 return hwif->ide_dma_off_quietly(drive);
134 } 126 }
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)
737static int hpt366_config_drive_xfer_rate(ide_drive_t *drive) 737static int hpt366_config_drive_xfer_rate(ide_drive_t *drive)
738{ 738{
739 ide_hwif_t *hwif = HWIF(drive); 739 ide_hwif_t *hwif = HWIF(drive);
740 struct hd_driveid *id = drive->id;
741 740
742 drive->init_speed = 0; 741 drive->init_speed = 0;
743 742
744 if ((id->capability & 1) && drive->autodma) { 743 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
745 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 744 return hwif->ide_dma_on(drive);
746 return hwif->ide_dma_on(drive);
747
748 goto fast_ata_pio;
749 745
750 } else if ((id->capability & 8) || (id->field_valid & 2)) { 746 if (ide_use_fast_pio(drive)) {
751fast_ata_pio:
752 hpt3xx_tune_drive(drive, 255); 747 hpt3xx_tune_drive(drive, 255);
753 return hwif->ide_dma_off_quietly(drive); 748 return hwif->ide_dma_off_quietly(drive);
754 } 749 }
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)
282static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive) 282static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
283{ 283{
284 ide_hwif_t *hwif = HWIF(drive); 284 ide_hwif_t *hwif = HWIF(drive);
285 struct hd_driveid *id = drive->id;
286 285
287 drive->init_speed = 0; 286 drive->init_speed = 0;
288 287
289 if ((id->capability & 1) && drive->autodma) { 288 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
290 289 return hwif->ide_dma_on(drive);
291 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
292 return hwif->ide_dma_on(drive);
293
294 goto fast_ata_pio;
295 290
296 } else if ((id->capability & 8) || (id->field_valid & 2)) { 291 if (ide_use_fast_pio(drive)) {
297fast_ata_pio:
298 hwif->tuneproc(drive, 255); 292 hwif->tuneproc(drive, 255);
299 return hwif->ide_dma_off_quietly(drive); 293 return hwif->ide_dma_off_quietly(drive);
300 } 294 }
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:
323static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive) 323static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive)
324{ 324{
325 ide_hwif_t *hwif = HWIF(drive); 325 ide_hwif_t *hwif = HWIF(drive);
326 struct hd_driveid *id = drive->id;
327 326
328 drive->init_speed = 0; 327 drive->init_speed = 0;
329 328
330 if (id && (id->capability & 1) && drive->autodma) { 329 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
331 330 return hwif->ide_dma_on(drive);
332 if (ide_use_dma(drive)) {
333 if (config_chipset_for_dma(drive))
334 return hwif->ide_dma_on(drive);
335 }
336
337 goto fast_ata_pio;
338 331
339 } else if ((id->capability & 8) || (id->field_valid & 2)) { 332 if (ide_use_fast_pio(drive)) {
340fast_ata_pio:
341 pdc202xx_tune_drive(drive, 255); 333 pdc202xx_tune_drive(drive, 255);
342 return hwif->ide_dma_off_quietly(drive); 334 return hwif->ide_dma_off_quietly(drive);
343 } 335 }
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)
387static int piix_config_drive_xfer_rate (ide_drive_t *drive) 387static int piix_config_drive_xfer_rate (ide_drive_t *drive)
388{ 388{
389 ide_hwif_t *hwif = HWIF(drive); 389 ide_hwif_t *hwif = HWIF(drive);
390 struct hd_driveid *id = drive->id;
391 390
392 drive->init_speed = 0; 391 drive->init_speed = 0;
393 392
394 if ((id->capability & 1) && drive->autodma) { 393 if (ide_use_dma(drive) && piix_config_drive_for_dma(drive))
394 return hwif->ide_dma_on(drive);
395 395
396 if (ide_use_dma(drive) && piix_config_drive_for_dma(drive)) 396 if (ide_use_fast_pio(drive)) {
397 return hwif->ide_dma_on(drive);
398
399 goto fast_ata_pio;
400
401 } else if ((id->capability & 8) || (id->field_valid & 2)) {
402fast_ata_pio:
403 /* Find best PIO mode. */ 397 /* Find best PIO mode. */
404 (void) hwif->speedproc(drive, XFER_PIO_0 + 398 (void) hwif->speedproc(drive, XFER_PIO_0 +
405 ide_get_best_pio_mode(drive, 255, 4, NULL)); 399 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)
316static int svwks_config_drive_xfer_rate (ide_drive_t *drive) 316static int svwks_config_drive_xfer_rate (ide_drive_t *drive)
317{ 317{
318 ide_hwif_t *hwif = HWIF(drive); 318 ide_hwif_t *hwif = HWIF(drive);
319 struct hd_driveid *id = drive->id;
320 319
321 drive->init_speed = 0; 320 drive->init_speed = 0;
322 321
323 if ((id->capability & 1) && drive->autodma) { 322 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
323 return hwif->ide_dma_on(drive);
324 324
325 if (ide_use_dma(drive)) { 325 if (ide_use_fast_pio(drive)) {
326 if (config_chipset_for_dma(drive))
327 return hwif->ide_dma_on(drive);
328 }
329
330 goto fast_ata_pio;
331
332 } else if ((id->capability & 8) || (id->field_valid & 2)) {
333fast_ata_pio:
334 config_chipset_for_pio(drive); 326 config_chipset_for_pio(drive);
335 // hwif->tuneproc(drive, 5); 327 // hwif->tuneproc(drive, 5);
336 return hwif->ide_dma_off_quietly(drive); 328 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)
415static int siimage_config_drive_for_dma (ide_drive_t *drive) 415static int siimage_config_drive_for_dma (ide_drive_t *drive)
416{ 416{
417 ide_hwif_t *hwif = HWIF(drive); 417 ide_hwif_t *hwif = HWIF(drive);
418 struct hd_driveid *id = drive->id;
419 418
420 if ((id->capability & 1) != 0 && drive->autodma) { 419 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
420 return hwif->ide_dma_on(drive);
421 421
422 if (ide_use_dma(drive)) { 422 if (ide_use_fast_pio(drive)) {
423 if (config_chipset_for_dma(drive))
424 return hwif->ide_dma_on(drive);
425 }
426
427 goto fast_ata_pio;
428
429 } else if ((id->capability & 8) || (id->field_valid & 2)) {
430fast_ata_pio:
431 config_chipset_for_pio(drive, 1); 423 config_chipset_for_pio(drive, 1);
432 return hwif->ide_dma_off_quietly(drive); 424 return hwif->ide_dma_off_quietly(drive);
433 } 425 }
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)
670static int sis5513_config_xfer_rate(ide_drive_t *drive) 670static int sis5513_config_xfer_rate(ide_drive_t *drive)
671{ 671{
672 ide_hwif_t *hwif = HWIF(drive); 672 ide_hwif_t *hwif = HWIF(drive);
673 struct hd_driveid *id = drive->id;
674 673
675 config_art_rwp_pio(drive, 5); 674 config_art_rwp_pio(drive, 5);
676 675
677 drive->init_speed = 0; 676 drive->init_speed = 0;
678 677
679 if (id && (id->capability & 1) && drive->autodma) { 678 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
679 return hwif->ide_dma_on(drive);
680 680
681 if (ide_use_dma(drive)) { 681 if (ide_use_fast_pio(drive)) {
682 if (config_chipset_for_dma(drive))
683 return hwif->ide_dma_on(drive);
684 }
685
686 goto fast_ata_pio;
687
688 } else if ((id->capability & 8) || (id->field_valid & 2)) {
689fast_ata_pio:
690 sis5513_tune_drive(drive, 5); 682 sis5513_tune_drive(drive, 5);
691 return hwif->ide_dma_off_quietly(drive); 683 return hwif->ide_dma_off_quietly(drive);
692 } 684 }
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)
180static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive) 180static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive)
181{ 181{
182 ide_hwif_t *hwif = HWIF(drive); 182 ide_hwif_t *hwif = HWIF(drive);
183 struct hd_driveid *id = drive->id;
184 183
185 drive->init_speed = 0; 184 drive->init_speed = 0;
186 185
187 if ((id->capability & 1) && drive->autodma) { 186 if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive))
187 return hwif->ide_dma_on(drive);
188 188
189 if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive)) 189 if (ide_use_fast_pio(drive)) {
190 return hwif->ide_dma_on(drive);
191
192 goto fast_ata_pio;
193
194 } else if ((id->capability & 8) || (id->field_valid & 2)) {
195fast_ata_pio:
196 (void) hwif->speedproc(drive, XFER_PIO_0 + 190 (void) hwif->speedproc(drive, XFER_PIO_0 +
197 ide_get_best_pio_mode(drive, 255, 4, NULL)); 191 ide_get_best_pio_mode(drive, 255, 4, NULL));
198 return hwif->ide_dma_off_quietly(drive); 192 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)
186static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive) 186static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive)
187{ 187{
188 ide_hwif_t *hwif = HWIF(drive); 188 ide_hwif_t *hwif = HWIF(drive);
189 struct hd_driveid *id = drive->id;
190 189
191 if ((id->capability & 1) && drive->autodma) { 190 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
191 return hwif->ide_dma_on(drive);
192 192
193 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 193 if (ide_use_fast_pio(drive)) {
194 return hwif->ide_dma_on(drive);
195
196 goto fast_ata_pio;
197
198 } else if ((id->capability & 8) || (id->field_valid & 2)) {
199fast_ata_pio:
200 tc86c001_tune_drive(drive, 255); 194 tc86c001_tune_drive(drive, 255);
201 return hwif->ide_dma_off_quietly(drive); 195 return hwif->ide_dma_off_quietly(drive);
202 } 196 }
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)
114static int triflex_config_drive_xfer_rate(ide_drive_t *drive) 114static int triflex_config_drive_xfer_rate(ide_drive_t *drive)
115{ 115{
116 ide_hwif_t *hwif = HWIF(drive); 116 ide_hwif_t *hwif = HWIF(drive);
117 struct hd_driveid *id = drive->id;
118 117
119 if ((id->capability & 1) && drive->autodma) { 118 if (ide_use_dma(drive) && triflex_config_drive_for_dma(drive))
120 if (ide_use_dma(drive)) { 119 return hwif->ide_dma_on(drive);
121 if (triflex_config_drive_for_dma(drive))
122 return hwif->ide_dma_on(drive);
123 }
124 }
125 120
126 hwif->tuneproc(drive, 255); 121 hwif->tuneproc(drive, 255);
127 return hwif->ide_dma_off_quietly(drive); 122 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)
383static int scc_config_drive_for_dma(ide_drive_t *drive) 383static int scc_config_drive_for_dma(ide_drive_t *drive)
384{ 384{
385 ide_hwif_t *hwif = HWIF(drive); 385 ide_hwif_t *hwif = HWIF(drive);
386 struct hd_driveid *id = drive->id;
387 386
388 if ((id->capability & 1) != 0 && drive->autodma) { 387 if (ide_use_dma(drive) && scc_config_chipset_for_dma(drive))
389 if (ide_use_dma(drive)) { 388 return hwif->ide_dma_on(drive);
390 if (scc_config_chipset_for_dma(drive)) 389
391 return hwif->ide_dma_on(drive); 390 if (ide_use_fast_pio(drive)) {
392 }
393 goto fast_ata_pio;
394 } else if ((id->capability & 8) || (id->field_valid & 2)) {
395 fast_ata_pio:
396 hwif->tuneproc(drive, 4); 391 hwif->tuneproc(drive, 4);
397 hwif->ide_dma_off_quietly(drive); 392 hwif->ide_dma_off_quietly(drive);
398 } 393 }
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);
1352extern char *ide_xfer_verbose(u8 xfer_rate); 1352extern char *ide_xfer_verbose(u8 xfer_rate);
1353extern void ide_toggle_bounce(ide_drive_t *drive, int on); 1353extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1354extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); 1354extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
1355int ide_use_fast_pio(ide_drive_t *);
1355 1356
1356u8 ide_dump_status(ide_drive_t *, const char *, u8); 1357u8 ide_dump_status(ide_drive_t *, const char *, u8);
1357 1358