ide-cris: fix ->set_pio_mode method to set transfer mode on the device
[safe/jmp/linux-2.6] / drivers / ide / ide-lib.c
index 6e85bee..92a6c7b 100644 (file)
@@ -277,7 +277,6 @@ EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
  *     @drive: drive to consider
  *     @mode_wanted: preferred mode
  *     @max_mode: highest allowed mode
- *     @d: PIO data
  *
  *     This routine returns the recommended PIO settings for a given drive,
  *     based on the drive->id information and the ide_pio_blacklist[].
@@ -286,17 +285,17 @@ EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
  *     This is used by most chipset support modules when "auto-tuning".
  */
 
-u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d)
+u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
 {
        int pio_mode;
        struct hd_driveid* id = drive->id;
        int overridden  = 0;
 
-       if (mode_wanted != 255) {
-               pio_mode = mode_wanted;
-       } else if (!drive->id) {
-               pio_mode = 0;
-       } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
+       if (mode_wanted != 255)
+               return min_t(u8, mode_wanted, max_mode);
+
+       if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0 &&
+           (pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
                printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
        } else {
                pio_mode = id->tPIO;
@@ -325,7 +324,8 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
                /*
                 * Conservative "downgrade" for all pre-ATA2 drives
                 */
-               if (pio_mode && pio_mode < 4) {
+               if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_DOWNGRADE) == 0 &&
+                   pio_mode && pio_mode < 4) {
                        pio_mode--;
                        printk(KERN_INFO "%s: applying conservative "
                                         "PIO \"downgrade\"\n", drive->name);
@@ -335,9 +335,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
        if (pio_mode > max_mode)
                pio_mode = max_mode;
 
-       if (d)
-               d->pio_mode = pio_mode;
-
        return pio_mode;
 }