diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:23 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:23 -0400 |
commit | b163f46d5ecf48d883ce156e5e5a21a1a9a125c7 (patch) | |
tree | 5ee79c2c30d959bc21607d4c45faecbdf2481c4f /drivers/ide/ide-probe.c | |
parent | c36a7e98846a7a4a1c09b7f148395089bce512d8 (diff) |
ide: enhance ide_busy_sleep()
* Make ide_busy_sleep() take timeout value as a parameter
and also allow use of AltStatus Register if requested with
altstatus parameter. Update existing users accordingly.
* Convert ide_driveid_update() and actual_try_to_identify()
to use ide_busy_sleep().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r-- | drivers/ide/ide-probe.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index e78cfde5bd6d..ef773384aaa9 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -291,17 +291,9 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
291 | tp_ops->exec_command(hwif, cmd); | 291 | tp_ops->exec_command(hwif, cmd); |
292 | 292 | ||
293 | timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 293 | timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
294 | timeout += jiffies; | 294 | |
295 | do { | 295 | if (ide_busy_sleep(hwif, timeout, use_altstatus)) |
296 | if (time_after(jiffies, timeout)) { | 296 | return 1; |
297 | /* drive timed-out */ | ||
298 | return 1; | ||
299 | } | ||
300 | /* give drive a breather */ | ||
301 | msleep(50); | ||
302 | s = use_altstatus ? tp_ops->read_altstatus(hwif) | ||
303 | : tp_ops->read_status(hwif); | ||
304 | } while (s & ATA_BUSY); | ||
305 | 297 | ||
306 | /* wait for IRQ and ATA_DRQ */ | 298 | /* wait for IRQ and ATA_DRQ */ |
307 | msleep(50); | 299 | msleep(50); |
@@ -383,19 +375,21 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) | |||
383 | return retval; | 375 | return retval; |
384 | } | 376 | } |
385 | 377 | ||
386 | static int ide_busy_sleep(ide_hwif_t *hwif) | 378 | int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) |
387 | { | 379 | { |
388 | unsigned long timeout = jiffies + WAIT_WORSTCASE; | ||
389 | u8 stat; | 380 | u8 stat; |
390 | 381 | ||
382 | timeout += jiffies; | ||
383 | |||
391 | do { | 384 | do { |
392 | msleep(50); | 385 | msleep(50); /* give drive a breather */ |
393 | stat = hwif->tp_ops->read_status(hwif); | 386 | stat = altstatus ? hwif->tp_ops->read_altstatus(hwif) |
387 | : hwif->tp_ops->read_status(hwif); | ||
394 | if ((stat & ATA_BUSY) == 0) | 388 | if ((stat & ATA_BUSY) == 0) |
395 | return 0; | 389 | return 0; |
396 | } while (time_before(jiffies, timeout)); | 390 | } while (time_before(jiffies, timeout)); |
397 | 391 | ||
398 | return 1; | 392 | return 1; /* drive timed-out */ |
399 | } | 393 | } |
400 | 394 | ||
401 | static u8 ide_read_device(ide_drive_t *drive) | 395 | static u8 ide_read_device(ide_drive_t *drive) |
@@ -489,7 +483,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
489 | SELECT_DRIVE(drive); | 483 | SELECT_DRIVE(drive); |
490 | msleep(50); | 484 | msleep(50); |
491 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); | 485 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); |
492 | (void)ide_busy_sleep(hwif); | 486 | (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); |
493 | rc = try_to_identify(drive, cmd); | 487 | rc = try_to_identify(drive, cmd); |
494 | } | 488 | } |
495 | 489 | ||
@@ -529,7 +523,7 @@ static void enable_nest (ide_drive_t *drive) | |||
529 | msleep(50); | 523 | msleep(50); |
530 | tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST); | 524 | tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST); |
531 | 525 | ||
532 | if (ide_busy_sleep(hwif)) { | 526 | if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) { |
533 | printk(KERN_CONT "failed (timeout)\n"); | 527 | printk(KERN_CONT "failed (timeout)\n"); |
534 | return; | 528 | return; |
535 | } | 529 | } |