pciehp: Event handling rework
[powerpc.git] / drivers / ide / ide-lib.c
index 8237d89..6871931 100644 (file)
@@ -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*.
@@ -330,16 +345,16 @@ static int ide_scan_pio_blacklist (char *model)
 
 /**
  *     ide_get_best_pio_mode   -       get PIO mode from drive
- *     @driver: drive to consider
+ *     @drive: drive to consider
  *     @mode_wanted: preferred mode
- *     @max_mode: highest allowed
- *     @d: pio data
+ *     @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[].
- *     This is used by most chipset support modules when "auto-tuning".
  *
- *     Drive PIO mode auto selection
+ *     Drive PIO mode is auto-selected if 255 is passed as mode_wanted.
+ *     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)
@@ -349,15 +364,14 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
        int use_iordy = 0;
        struct hd_driveid* id = drive->id;
        int overridden  = 0;
-       int blacklisted = 0;
 
        if (mode_wanted != 255) {
                pio_mode = mode_wanted;
+               use_iordy = (pio_mode > 2);
        } else if (!drive->id) {
                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;
@@ -383,19 +397,12 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
                        }
                }
 
-#if 0
-               if (drive->id->major_rev_num & 0x0004) printk("ATA-2 ");
-#endif
-
                /*
                 * Conservative "downgrade" for all pre-ATA2 drives
                 */
                if (pio_mode && pio_mode < 4) {
                        pio_mode--;
                        overridden = 1;
-#if 0
-                       use_iordy = (pio_mode > 2);
-#endif
                        if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time)
                                cycle_time = 0; /* use standard timing */
                }
@@ -409,7 +416,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
                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;
 }
@@ -462,8 +468,6 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
                return -1;
 }
 
-EXPORT_SYMBOL_GPL(ide_set_xfer_rate);
-
 static void ide_dump_opcode(ide_drive_t *drive)
 {
        struct request *rq;