From: Frank Mori Hess Date: Sat, 28 May 2005 19:02:24 +0000 (+0000) Subject: added jiffies_to_msecs() and msleep_interruptible() to compatibility X-Git-Tag: branch-0_7-end~57 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=3ffab58232a24c121b021f624c13ee9b0dd3d1c5;p=comedi.git added jiffies_to_msecs() and msleep_interruptible() to compatibility headers --- diff --git a/include/linux/delay.h b/include/linux/delay.h new file mode 100644 index 00000000..4ef87686 --- /dev/null +++ b/include/linux/delay.h @@ -0,0 +1,24 @@ + +#ifndef __COMPAT_LINUX_DELAY_H +#define __COMPAT_LINUX_DELAY_H + +#include +#include + +#include_next + +#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 + diff --git a/include/linux/time.h b/include/linux/time.h index 306b80fb..48345ccf 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -7,14 +7,26 @@ #include_next #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 };