ide: add ide_tune_dma() helper
[linux-drm-fsl-dcu.git] / drivers / ide / pci / cs5535.c
index 5c5aec28e6717f3d9e7c81d243bc711ebf8b455b..41925c47ef05968d484107b34b7c22b1e53373c4 100644 (file)
@@ -127,20 +127,6 @@ static void cs5535_set_speed(ide_drive_t *drive, u8 speed)
        }
 }
 
-static u8 cs5535_ratemask(ide_drive_t *drive)
-{
-       /* eighty93 will return 1 if it's 80core and capable of
-       exceeding udma2, 0 otherwise. we need ratemask to set
-       the max speed and if we can > udma2 then we return 2
-       which selects speed_max as udma4 which is the 5535's max
-       speed, and 1 selects udma2 which is the max for 40c */
-       if (!eighty_ninty_three(drive))
-               return 1;
-
-       return 2;
-}
-
-
 /****
  *     cs5535_set_drive         -     Configure the drive to the new speed
  *     @drive: Drive to set up
@@ -151,7 +137,7 @@ static u8 cs5535_ratemask(ide_drive_t *drive)
  */
 static int cs5535_set_drive(ide_drive_t *drive, u8 speed)
 {
-       speed = ide_rate_filter(cs5535_ratemask(drive), speed);
+       speed = ide_rate_filter(drive, speed);
        ide_config_drive_speed(drive, speed);
        cs5535_set_speed(drive, speed);
 
@@ -178,45 +164,21 @@ static void cs5535_tuneproc(ide_drive_t *drive, u8 xferspeed)
        cs5535_set_speed(drive, xferspeed);
 }
 
-static int cs5535_config_drive_for_dma(ide_drive_t *drive)
-{
-       u8 speed;
-
-       speed = ide_dma_speed(drive, cs5535_ratemask(drive));
-
-       /* If no DMA speed was available then let dma_check hit pio */
-       if (!speed) {
-               return 0;
-       }
-
-       cs5535_set_drive(drive, speed);
-       return ide_dma_enable(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_tune_dma(drive))
+               return 0;
 
-       } 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);
        }
-       /* IORDY not supported */
-       return 0;
+
+       return -1;
 }
 
 static u8 __devinit cs5535_cable_detect(struct pci_dev *dev)