]> git.hungrycats.org Git - linux/commitdiff
Add msleep function to the kernel core to prevent duplication.
authorGreg Kroah-Hartman <greg@kroah.com>
Tue, 18 May 2004 08:49:36 +0000 (01:49 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 18 May 2004 08:49:36 +0000 (01:49 -0700)
include/linux/delay.h
kernel/timer.c

index 36abaa6b19fdd9c12c6aad88152c95ec867a929d..f5610919dc3e17b09a408fba11a4fd25e1a2143b 100644 (file)
@@ -38,4 +38,6 @@ extern unsigned long loops_per_jiffy;
 #define ndelay(x)      udelay(((x)+999)/1000)
 #endif
 
+void msleep(unsigned int msecs);
+
 #endif /* defined(_LINUX_DELAY_H) */
index d28aecec0be1201cc3b04bce8d1110b0fca6495b..0f2d571dff3a1c440ca41d4c807d5b2d6e435b0a 100644 (file)
@@ -1485,3 +1485,20 @@ unregister_time_interpolator(struct time_interpolator *ti)
        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);
+