[PATCH] USB: convert a bunch of USB semaphores to mutexes
[linux-2.6-block.git] / drivers / usb / input / ati_remote.c
index 9a2a47db9494d62e595865ac02038e6ce9a04320..99f986cb6e955d29ea817e2f6f571303b3aac1da 100644 (file)
@@ -96,6 +96,7 @@
 #include <linux/usb.h>
 #include <linux/usb_input.h>
 #include <linux/wait.h>
+#include <linux/jiffies.h>
 
 /*
  * Module and Version Information, Module Parameters
@@ -146,7 +147,7 @@ static char init1[] = { 0x01, 0x00, 0x20, 0x14 };
 static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 };
 
 /* Acceleration curve for directional control pad */
-static char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
+static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
 
 /* Duplicate event filtering time.
  * Sequential, identical KIND_FILTERED inputs with less than
@@ -158,8 +159,6 @@ static char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
  */
 #define FILTER_TIME (HZ / 20)
 
-static DECLARE_MUTEX(disconnect_sem);
-
 struct ati_remote {
        struct input_dev *idev;
        struct usb_device *udev;
@@ -197,7 +196,7 @@ struct ati_remote {
 #define KIND_ACCEL      7   /* Directional keypad - left, right, up, down.*/
 
 /* Translation table from hardware messages to input events. */
-static struct {
+static const struct {
        short kind;
        unsigned char data1, data2;
        int type;
@@ -295,7 +294,6 @@ static void ati_remote_disconnect   (struct usb_interface *interface);
 
 /* usb specific object to register with the usb subsystem */
 static struct usb_driver ati_remote_driver = {
-       .owner        = THIS_MODULE,
        .name         = "ati_remote",
        .probe        = ati_remote_probe,
        .disconnect   = ati_remote_disconnect,
@@ -472,7 +470,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
                /* Filter duplicate events which happen "too close" together. */
                if ((ati_remote->old_data[0] == data[1]) &&
                        (ati_remote->old_data[1] == data[2]) &&
-                       ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) {
+                       time_before(jiffies, ati_remote->old_jiffies + FILTER_TIME)) {
                        ati_remote->repeat_count++;
                } else {
                        ati_remote->repeat_count = 0;
@@ -507,16 +505,16 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
         * pad down, so we increase acceleration, ramping up over two seconds to
         * a maximum speed.  The acceleration curve is #defined above.
         */
-       if ((jiffies - ati_remote->old_jiffies) > (HZ >> 2)) {
+       if (time_after(jiffies, ati_remote->old_jiffies + (HZ >> 2))) {
                acc = 1;
                ati_remote->acc_jiffies = jiffies;
        }
-       else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 3))  acc = accel[0];
-       else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 2))  acc = accel[1];
-       else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 1))  acc = accel[2];
-       else if ((jiffies - ati_remote->acc_jiffies) < HZ )        acc = accel[3];
-       else if ((jiffies - ati_remote->acc_jiffies) < HZ+(HZ>>1)) acc = accel[4];
-       else if ((jiffies - ati_remote->acc_jiffies) < (HZ << 1))  acc = accel[5];
+       else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 3)))  acc = accel[0];
+       else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 2)))  acc = accel[1];
+       else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 1)))  acc = accel[2];
+       else if (time_before(jiffies, ati_remote->acc_jiffies + HZ))         acc = accel[3];
+       else if (time_before(jiffies, ati_remote->acc_jiffies + HZ+(HZ>>1))) acc = accel[4];
+       else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ << 1)))  acc = accel[5];
        else acc = accel[6];
 
        input_regs(dev, regs);