Commit 865c05da authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] ide: use msleep() instead of ide_delay_50ms()

msleep() does msecs to jiffies conversion correctly regardless
of HZ value and sets the current task's state in a safe way.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 06be3254
......@@ -767,7 +767,7 @@ int ide_driveid_update (ide_drive_t *drive)
SELECT_MASK(drive, 1);
if (IDE_CONTROL_REG)
hwif->OUTB(drive->ctl,IDE_CONTROL_REG);
ide_delay_50ms();
msleep(50);
hwif->OUTB(WIN_IDENTIFY, IDE_COMMAND_REG);
timeout = jiffies + WAIT_WORSTCASE;
do {
......@@ -775,9 +775,9 @@ int ide_driveid_update (ide_drive_t *drive)
SELECT_MASK(drive, 0);
return 0; /* drive timed-out */
}
ide_delay_50ms(); /* give drive a breather */
msleep(50); /* give drive a breather */
} while (hwif->INB(IDE_ALTSTATUS_REG) & BUSY_STAT);
ide_delay_50ms(); /* wait for IRQ and DRQ_STAT */
msleep(50); /* wait for IRQ and DRQ_STAT */
if (!OK_STAT(hwif->INB(IDE_STATUS_REG),DRQ_STAT,BAD_R_STAT)) {
SELECT_MASK(drive, 0);
printk("%s: CHECK for good STATUS\n", drive->name);
......@@ -827,7 +827,7 @@ int ide_config_drive_speed (ide_drive_t *drive, u8 speed)
u8 stat;
// while (HWGROUP(drive)->busy)
// ide_delay_50ms();
// msleep(50);
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->ide_dma_check) /* check if host supports DMA */
......
......@@ -283,9 +283,10 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
unsigned long timeout;
u8 s = 0, a = 0;
/* take a deep breath */
msleep(50);
if (IDE_CONTROL_REG) {
/* take a deep breath */
ide_delay_50ms();
a = hwif->INB(IDE_ALTSTATUS_REG);
s = hwif->INB(IDE_STATUS_REG);
if ((a ^ s) & ~INDEX_STAT) {
......@@ -297,10 +298,8 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
/* use non-intrusive polling */
hd_status = IDE_ALTSTATUS_REG;
}
} else {
ide_delay_50ms();
} else
hd_status = IDE_STATUS_REG;
}
/* set features register for atapi
* identify command to be sure of reply
......@@ -324,11 +323,11 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
return 1;
}
/* give drive a breather */
ide_delay_50ms();
msleep(50);
} while ((hwif->INB(hd_status)) & BUSY_STAT);
/* wait for IRQ and DRQ_STAT */
ide_delay_50ms();
msleep(50);
if (OK_STAT((hwif->INB(IDE_STATUS_REG)), DRQ_STAT, BAD_R_STAT)) {
unsigned long flags;
......@@ -457,15 +456,15 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
/* needed for some systems
* (e.g. crw9624 as drive0 with disk as slave)
*/
ide_delay_50ms();
msleep(50);
SELECT_DRIVE(drive);
ide_delay_50ms();
msleep(50);
if (hwif->INB(IDE_SELECT_REG) != drive->select.all && !drive->present) {
if (drive->select.b.unit != 0) {
/* exit with drive0 selected */
SELECT_DRIVE(&hwif->drives[0]);
/* allow BUSY_STAT to assert & clear */
ide_delay_50ms();
msleep(50);
}
/* no i/f present: mmm.. this should be a 4 -ml */
return 3;
......@@ -488,14 +487,14 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
printk("%s: no response (status = 0x%02x), "
"resetting drive\n", drive->name,
hwif->INB(IDE_STATUS_REG));
ide_delay_50ms();
msleep(50);
hwif->OUTB(drive->select.all, IDE_SELECT_REG);
ide_delay_50ms();
msleep(50);
hwif->OUTB(WIN_SRST, IDE_COMMAND_REG);
timeout = jiffies;
while (((hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) &&
time_before(jiffies, timeout + WAIT_WORSTCASE))
ide_delay_50ms();
msleep(50);
rc = try_to_identify(drive, cmd);
}
if (rc == 1)
......@@ -510,7 +509,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
if (drive->select.b.unit != 0) {
/* exit with drive0 selected */
SELECT_DRIVE(&hwif->drives[0]);
ide_delay_50ms();
msleep(50);
/* ensure drive irq is clear */
(void) hwif->INB(IDE_STATUS_REG);
}
......@@ -527,7 +526,7 @@ static void enable_nest (ide_drive_t *drive)
printk("%s: enabling %s -- ", hwif->name, drive->id->model);
SELECT_DRIVE(drive);
ide_delay_50ms();
msleep(50);
hwif->OUTB(EXABYTE_ENABLE_NEST, IDE_COMMAND_REG);
timeout = jiffies + WAIT_WORSTCASE;
do {
......@@ -535,10 +534,10 @@ static void enable_nest (ide_drive_t *drive)
printk("failed (timeout)\n");
return;
}
ide_delay_50ms();
msleep(50);
} while ((hwif->INB(IDE_STATUS_REG)) & BUSY_STAT);
ide_delay_50ms();
msleep(50);
if (!OK_STAT((hwif->INB(IDE_STATUS_REG)), 0, BAD_STAT)) {
printk("failed (status = 0x%02x)\n", hwif->INB(IDE_STATUS_REG));
......@@ -781,7 +780,7 @@ void probe_hwif (ide_hwif_t *hwif)
udelay(10);
hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
do {
ide_delay_50ms();
msleep(50);
stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]);
} while ((stat & BUSY_STAT) && time_after(timeout, jiffies));
......
......@@ -1387,22 +1387,6 @@ void ide_add_generic_settings (ide_drive_t *drive)
ide_add_setting(drive, "ide-scsi", SETTING_RW, -1, HDIO_SET_IDE_SCSI, TYPE_BYTE, 0, 1, 1, 1, &drive->scsi, ide_atapi_to_scsi);
}
/*
* Delay for *at least* 50ms. As we don't know how much time is left
* until the next tick occurs, we wait an extra tick to be safe.
* This is used only during the probing/polling for drives at boot time.
*
* However, its usefullness may be needed in other places, thus we export it now.
* The future may change this to a millisecond setable delay.
*/
void ide_delay_50ms (void)
{
__set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1+HZ/20);
}
EXPORT_SYMBOL(ide_delay_50ms);
int system_bus_clock (void)
{
return((int) ((!system_bus_speed) ? ide_system_bus_speed() : system_bus_speed ));
......
......@@ -282,8 +282,8 @@ int __init detect_pdc4030(ide_hwif_t *hwif)
hwif->OUTB(0xF3, IDE_SECTOR_REG);
hwif->OUTB(0x14, IDE_SELECT_REG);
hwif->OUTB(PROMISE_EXTENDED_COMMAND, IDE_COMMAND_REG);
ide_delay_50ms();
msleep(50);
if (hwif->INB(IDE_ERROR_REG) == 'P' &&
hwif->INB(IDE_NSECTOR_REG) == 'T' &&
......
......@@ -1477,7 +1477,6 @@ int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
extern void ide_delay_50ms(void);
extern int system_bus_clock(void);
extern u8 ide_auto_reduce_xfer(ide_drive_t *);
......
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