ide: ide_find_best_pio_mode() fixes (take 2)

* Check IORDY bit for PIO modes > 2.

* Some devices claim maximum PIO mode > 2 in id->tPIO, they were punished too
  severly for this by being limited to PIO_SLOW.  Limit them to PIO2 instead.

v2:
* Fix PIO number being returned incorrectly instead of PIO mode
  (Noticed by Sergei).
Acked-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 7dd00083
...@@ -111,16 +111,14 @@ static short ide_find_best_pio_mode(ide_drive_t *drive) ...@@ -111,16 +111,14 @@ static short ide_find_best_pio_mode(ide_drive_t *drive)
struct hd_driveid *id = drive->id; struct hd_driveid *id = drive->id;
short best = 0; short best = 0;
if (id->field_valid & 2) { /* EIDE PIO modes */ /* EIDE PIO modes */
if ((id->field_valid & 2) && (id->capability & 8)) {
if ((best = (drive->id->eide_pio_modes & 4) ? XFER_PIO_5 : if ((best = (drive->id->eide_pio_modes & 4) ? XFER_PIO_5 :
(drive->id->eide_pio_modes & 2) ? XFER_PIO_4 : (drive->id->eide_pio_modes & 2) ? XFER_PIO_4 :
(drive->id->eide_pio_modes & 1) ? XFER_PIO_3 : 0)) return best; (drive->id->eide_pio_modes & 1) ? XFER_PIO_3 : 0)) return best;
} }
return (drive->id->tPIO == 2) ? XFER_PIO_2 : return XFER_PIO_0 + min_t(u8, id->tPIO, 2);
(drive->id->tPIO == 1) ? XFER_PIO_1 :
(drive->id->tPIO == 0) ? XFER_PIO_0 : XFER_PIO_SLOW;
} }
static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT) static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment