ide: ide_get_best_pio_mode() returns incorrect IORDY setting (take 2)

The function ide_get_best_pio_mode() fails to return the correct IORDY setting
for the explicitly specified modes -- fix this along with the heading comment,
and also remove the long commented out code.

Also, while at it, correct the misliading comment about the PIO cycle time in
<linux/ide.h> -- it actually consists of only the active and recovery periods,
with only some chips also including the address setup time into equation...

[ bart: sl82c105 seems to be currently the only driver affected by this fix ]

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

authored by Sergei Shtylyov and committed by Bartlomiej Zolnierkiewicz 81d368e0 07af4276

+8 -13
+6 -12
drivers/ide/ide-lib.c
··· 345 345 346 346 /** 347 347 * ide_get_best_pio_mode - get PIO mode from drive 348 - * @driver: drive to consider 348 + * @drive: drive to consider 349 349 * @mode_wanted: preferred mode 350 - * @max_mode: highest allowed 351 - * @d: pio data 350 + * @max_mode: highest allowed mode 351 + * @d: PIO data 352 352 * 353 353 * This routine returns the recommended PIO settings for a given drive, 354 354 * based on the drive->id information and the ide_pio_blacklist[]. 355 - * This is used by most chipset support modules when "auto-tuning". 356 355 * 357 - * Drive PIO mode auto selection 356 + * Drive PIO mode is auto-selected if 255 is passed as mode_wanted. 357 + * This is used by most chipset support modules when "auto-tuning". 358 358 */ 359 359 360 360 u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d) ··· 367 367 368 368 if (mode_wanted != 255) { 369 369 pio_mode = mode_wanted; 370 + use_iordy = (pio_mode > 2); 370 371 } else if (!drive->id) { 371 372 pio_mode = 0; 372 373 } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) { ··· 397 396 } 398 397 } 399 398 400 - #if 0 401 - if (drive->id->major_rev_num & 0x0004) printk("ATA-2 "); 402 - #endif 403 - 404 399 /* 405 400 * Conservative "downgrade" for all pre-ATA2 drives 406 401 */ 407 402 if (pio_mode && pio_mode < 4) { 408 403 pio_mode--; 409 404 overridden = 1; 410 - #if 0 411 - use_iordy = (pio_mode > 2); 412 - #endif 413 405 if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time) 414 406 cycle_time = 0; /* use standard timing */ 415 407 }
+2 -1
include/linux/ide.h
··· 1359 1359 typedef struct ide_pio_timings_s { 1360 1360 int setup_time; /* Address setup (ns) minimum */ 1361 1361 int active_time; /* Active pulse (ns) minimum */ 1362 - int cycle_time; /* Cycle time (ns) minimum = (setup + active + recovery) */ 1362 + int cycle_time; /* Cycle time (ns) minimum = */ 1363 + /* active + recovery (+ setup for some chips) */ 1363 1364 } ide_pio_timings_t; 1364 1365 1365 1366 typedef struct ide_pio_data_s {