aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-lib.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-07-19 19:11:56 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-07-19 19:11:56 -0400
commit7dd00083b1160b560fa2a0a486799b57baa5d035 (patch)
tree22e8cf2c740d55ff9b4fdf57b9593a357d0092b7 /drivers/ide/ide-lib.c
parent31c4df441cce6b9ec541e7f722f50bfbc617dd76 (diff)
ide: add ide_pio_cycle_time() helper (take 2)
* Add ide_pio_cycle_time() helper. * Use it in ali14xx/ht6560b/qd65xx/cmd64{0,x}/sl82c105 and pmac host drivers (previously cycle time given by the device was only used for "pio" == 255). * Remove no longer needed ide_pio_data_t.cycle_time field. v2: * Fix "ata_" prefix (Noticed by Jeff). Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r--drivers/ide/ide-lib.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index d5cc96bb4298..6e85bee0bef7 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -249,6 +249,29 @@ static int ide_scan_pio_blacklist (char *model)
249 return -1; 249 return -1;
250} 250}
251 251
252unsigned int ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
253{
254 struct hd_driveid *id = drive->id;
255 int cycle_time = 0;
256
257 if (id->field_valid & 2) {
258 if (id->capability & 8)
259 cycle_time = id->eide_pio_iordy;
260 else
261 cycle_time = id->eide_pio;
262 }
263
264 /* conservative "downgrade" for all pre-ATA2 drives */
265 if (pio < 3) {
266 if (cycle_time && cycle_time < ide_pio_timings[pio].cycle_time)
267 cycle_time = 0; /* use standard timing */
268 }
269
270 return cycle_time ? cycle_time : ide_pio_timings[pio].cycle_time;
271}
272
273EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
274
252/** 275/**
253 * ide_get_best_pio_mode - get PIO mode from drive 276 * ide_get_best_pio_mode - get PIO mode from drive
254 * @drive: drive to consider 277 * @drive: drive to consider
@@ -266,7 +289,6 @@ static int ide_scan_pio_blacklist (char *model)
266u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d) 289u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d)
267{ 290{
268 int pio_mode; 291 int pio_mode;
269 int cycle_time = 0;
270 struct hd_driveid* id = drive->id; 292 struct hd_driveid* id = drive->id;
271 int overridden = 0; 293 int overridden = 0;
272 294
@@ -284,7 +306,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
284 } 306 }
285 if (id->field_valid & 2) { /* drive implements ATA2? */ 307 if (id->field_valid & 2) { /* drive implements ATA2? */
286 if (id->capability & 8) { /* IORDY supported? */ 308 if (id->capability & 8) { /* IORDY supported? */
287 cycle_time = id->eide_pio_iordy;
288 if (id->eide_pio_modes & 7) { 309 if (id->eide_pio_modes & 7) {
289 overridden = 0; 310 overridden = 0;
290 if (id->eide_pio_modes & 4) 311 if (id->eide_pio_modes & 4)
@@ -294,8 +315,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
294 else 315 else
295 pio_mode = 3; 316 pio_mode = 3;
296 } 317 }
297 } else {
298 cycle_time = id->eide_pio;
299 } 318 }
300 } 319 }
301 320
@@ -310,18 +329,15 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_p
310 pio_mode--; 329 pio_mode--;
311 printk(KERN_INFO "%s: applying conservative " 330 printk(KERN_INFO "%s: applying conservative "
312 "PIO \"downgrade\"\n", drive->name); 331 "PIO \"downgrade\"\n", drive->name);
313 if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time)
314 cycle_time = 0; /* use standard timing */
315 } 332 }
316 } 333 }
317 if (pio_mode > max_mode) { 334
335 if (pio_mode > max_mode)
318 pio_mode = max_mode; 336 pio_mode = max_mode;
319 cycle_time = 0; 337
320 } 338 if (d)
321 if (d) {
322 d->pio_mode = pio_mode; 339 d->pio_mode = pio_mode;
323 d->cycle_time = cycle_time ? cycle_time : ide_pio_timings[pio_mode].cycle_time; 340
324 }
325 return pio_mode; 341 return pio_mode;
326} 342}
327 343