* include/linux/delay.h: Added msleep_interruptible()
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 28 May 2005 19:10:32 +0000 (19:10 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 28 May 2005 19:10:32 +0000 (19:10 +0000)
* include/linux/time.h:i Added msecs_to_jiffies() and jiffies_to_msecs()
* include/linux/usb.h: Added USB_CONTROL_MSG() and USB_BULK_MSG()

ChangeLog
include/linux/delay.h [new file with mode: 0644]
include/linux/time.h [new file with mode: 0644]
include/linux/usb.h

index d0127947ff8d3341e13566dc0bd0c2a6db1f84f2..419f8b0042e137a521a3d6a4e4f14ecacda555b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-05-28  Frank Hess,,,  <fmhess@users.sourceforge.net>
+
+       * include/linux/delay.h: Added msleep_interruptible() 
+       * include/linux/time.h:i Added msecs_to_jiffies() and jiffies_to_msecs()
+       * include/linux/usb.h: Added USB_CONTROL_MSG() and USB_BULK_MSG()
+
 2005-04-20  David Schleef  <ds@schleef.org>
 
        Remove the debian directory, since it's not maintained here.
diff --git a/include/linux/delay.h b/include/linux/delay.h
new file mode 100644 (file)
index 0000000..4ef8768
--- /dev/null
@@ -0,0 +1,24 @@
+
+#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
+
diff --git a/include/linux/time.h b/include/linux/time.h
new file mode 100644 (file)
index 0000000..48345cc
--- /dev/null
@@ -0,0 +1,36 @@
+
+#ifndef __COMPAT_LINUX_TIME_H
+#define __COMPAT_LINUX_TIME_H
+
+#include <linux/version.h>
+
+#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);
+#elif HZ > 1000 && !(HZ % 1000)
+       return m * (HZ / 1000);
+#else
+       return (m * HZ + 999) / 1000;
+#endif
+};
+
+#endif
+
+#endif
+
index 331c2b25309ae9b99257ac8ee49135dd9c55c02e..18f6575652afeeb1229dcc1fc4dccb3c65925a85 100644 (file)
@@ -24,6 +24,7 @@
 #define __COMPAT_LINUX_USB_H_
 
 #include <linux/version.h>
+#include <linux/time.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 #define USB_ALLOC_URB(x) usb_alloc_urb(x)
 
 #include_next <linux/usb.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
+static inline int USB_CONTROL_MSG(struct usb_device *dev, unsigned int pipe,
+       __u8 request, __u8 requesttype, __u16 value, __u16 index,
+       void *data, __u16 size, int millisec_timeout)
+{
+       return usb_control_msg(dev, pipe, request, requesttype, value, index,
+               data, size, msecs_to_jiffies(millisec_timeout));
+}
+static inline int USB_BULK_MSG(struct usb_device *usb_dev, unsigned int pipe,
+       void *data, int len, int *actual_length,
+       int millisec_timeout)
+{
+       return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, msecs_to_jiffies(millisec_timeout));
+}
+#else
+#define USB_CONTROL_MSG usb_control_msg
+#define USB_BULK_MSG usb_bulk_msg
+#endif
+
 #endif