aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-iops.c15
-rw-r--r--drivers/ide/ide-probe.c30
-rw-r--r--include/linux/ide.h2
3 files changed, 19 insertions, 28 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 004803030f64..a940d127aae3 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -666,7 +666,7 @@ int ide_driveid_update(ide_drive_t *drive)
666 ide_hwif_t *hwif = drive->hwif; 666 ide_hwif_t *hwif = drive->hwif;
667 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 667 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
668 u16 *id; 668 u16 *id;
669 unsigned long timeout, flags; 669 unsigned long flags;
670 u8 stat; 670 u8 stat;
671 671
672 /* 672 /*
@@ -678,16 +678,11 @@ int ide_driveid_update(ide_drive_t *drive)
678 tp_ops->set_irq(hwif, 0); 678 tp_ops->set_irq(hwif, 0);
679 msleep(50); 679 msleep(50);
680 tp_ops->exec_command(hwif, ATA_CMD_ID_ATA); 680 tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
681 timeout = jiffies + WAIT_WORSTCASE;
682 do {
683 if (time_after(jiffies, timeout)) {
684 SELECT_MASK(drive, 0);
685 return 0; /* drive timed-out */
686 }
687 681
688 msleep(50); /* give drive a breather */ 682 if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) {
689 stat = tp_ops->read_altstatus(hwif); 683 SELECT_MASK(drive, 0);
690 } while (stat & ATA_BUSY); 684 return 0;
685 }
691 686
692 msleep(50); /* wait for IRQ and ATA_DRQ */ 687 msleep(50); /* wait for IRQ and ATA_DRQ */
693 stat = tp_ops->read_status(hwif); 688 stat = tp_ops->read_status(hwif);
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
386static int ide_busy_sleep(ide_hwif_t *hwif) 378int 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
401static u8 ide_read_device(ide_drive_t *drive) 395static 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 }
diff --git a/include/linux/ide.h b/include/linux/ide.h
index ca0b132de1ae..2ad8548135d2 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -923,6 +923,8 @@ void ide_fix_driveid(u16 *);
923 923
924extern void ide_fixstring(u8 *, const int, const int); 924extern void ide_fixstring(u8 *, const int, const int);
925 925
926int ide_busy_sleep(ide_hwif_t *, unsigned long, int);
927
926int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 928int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
927 929
928extern ide_startstop_t ide_do_reset (ide_drive_t *); 930extern ide_startstop_t ide_do_reset (ide_drive_t *);