--- /dev/null
+
+#ifndef __COMPAT_LINUX_DELAY_H
+#define __COMPAT_LINUX_DELAY_H
+
+#include <linux/version.h>
+#include <linux/time.h>
+
+#include_next <linux/delay.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
+static inline unsigned long msleep_interruptible(unsigned int msecs)
+{
+ unsigned long timeout = msecs_to_jiffies(msecs);
+
+ while (timeout && !signal_pending(current)) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ timeout = schedule_timeout(timeout);
+ }
+ return jiffies_to_msecs(timeout);
+}
+#endif
+
+#endif
+
#include_next <linux/time.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+
+static inline unsigned int jiffies_to_msecs(const unsigned long j)
+{
+#if HZ <= 1000 && !(1000 % HZ)
+ return (1000 / HZ) * j;
+#elif HZ > 1000 && !(HZ % 1000)
+ return (j + (HZ / 1000) - 1)/(HZ / 1000);
+#else
+ return (j * 1000) / HZ;
+#endif
+}
+
static inline unsigned long msecs_to_jiffies(const unsigned int m)
{
#if HZ <= 1000 && !(1000 % HZ)
- return (m + (1000 / HZ) - 1) / (1000 / HZ);
+ return (m + (1000 / HZ) - 1) / (1000 / HZ);
#elif HZ > 1000 && !(HZ % 1000)
- return m * (HZ / 1000);
+ return m * (HZ / 1000);
#else
- return (m * HZ + 999) / 1000;
+ return (m * HZ + 999) / 1000;
#endif
};