ChangeSet 1.1743, 2004/05/18 15:49:36-07:00, greg@kroah.com Add msleep function to the kernel core to prevent duplication. include/linux/delay.h | 2 ++ kernel/timer.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff -Nru a/include/linux/delay.h b/include/linux/delay.h --- a/include/linux/delay.h Tue May 18 17:06:34 2004 +++ b/include/linux/delay.h Tue May 18 17:06:34 2004 @@ -38,4 +38,6 @@ #define ndelay(x) udelay(((x)+999)/1000) #endif +void msleep(unsigned int msecs); + #endif /* defined(_LINUX_DELAY_H) */ diff -Nru a/kernel/timer.c b/kernel/timer.c --- a/kernel/timer.c Tue May 18 17:06:34 2004 +++ b/kernel/timer.c Tue May 18 17:06:34 2004 @@ -1485,3 +1485,20 @@ spin_unlock(&time_interpolator_lock); } #endif /* CONFIG_TIME_INTERPOLATION */ + +/** + * msleep - sleep safely even with waitqueue interruptions + * @msecs: Time in milliseconds to sleep for + */ +void msleep(unsigned int msecs) +{ + unsigned long timeout = msecs_to_jiffies(msecs); + + while (timeout) { + set_current_state(TASK_UNINTERRUPTIBLE); + timeout = schedule_timeout(timeout); + } +} + +EXPORT_SYMBOL(msleep); +