aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input
diff options
context:
space:
mode:
authorMarcelo Feitoza Parisi <marcelo@feitoza.com.br>2005-11-30 16:50:39 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 16:51:41 -0500
commitf0b80fbf294bc4f6ec179b09fd5b63df25188259 (patch)
treea3eb4af3ce641bc99dd89bc01aca2917aaba060a /drivers/usb/input
parent95f209f93663103db2a8fb989e226ac68a98b036 (diff)
[PATCH] USB: ati_remote: use time_before() and friends
They deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi <marcelo@feitoza.com.br> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/input')
-rw-r--r--drivers/usb/input/ati_remote.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index b78a4d81b0a3..f7bdc506e613 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -96,6 +96,7 @@
96#include <linux/usb.h> 96#include <linux/usb.h>
97#include <linux/usb_input.h> 97#include <linux/usb_input.h>
98#include <linux/wait.h> 98#include <linux/wait.h>
99#include <linux/jiffies.h>
99 100
100/* 101/*
101 * Module and Version Information, Module Parameters 102 * Module and Version Information, Module Parameters
@@ -471,7 +472,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
471 /* Filter duplicate events which happen "too close" together. */ 472 /* Filter duplicate events which happen "too close" together. */
472 if ((ati_remote->old_data[0] == data[1]) && 473 if ((ati_remote->old_data[0] == data[1]) &&
473 (ati_remote->old_data[1] == data[2]) && 474 (ati_remote->old_data[1] == data[2]) &&
474 ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) { 475 time_before(jiffies, ati_remote->old_jiffies + FILTER_TIME)) {
475 ati_remote->repeat_count++; 476 ati_remote->repeat_count++;
476 } else { 477 } else {
477 ati_remote->repeat_count = 0; 478 ati_remote->repeat_count = 0;
@@ -506,16 +507,16 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
506 * pad down, so we increase acceleration, ramping up over two seconds to 507 * pad down, so we increase acceleration, ramping up over two seconds to
507 * a maximum speed. The acceleration curve is #defined above. 508 * a maximum speed. The acceleration curve is #defined above.
508 */ 509 */
509 if ((jiffies - ati_remote->old_jiffies) > (HZ >> 2)) { 510 if (time_after(jiffies, ati_remote->old_jiffies + (HZ >> 2))) {
510 acc = 1; 511 acc = 1;
511 ati_remote->acc_jiffies = jiffies; 512 ati_remote->acc_jiffies = jiffies;
512 } 513 }
513 else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 3)) acc = accel[0]; 514 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 3))) acc = accel[0];
514 else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 2)) acc = accel[1]; 515 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 2))) acc = accel[1];
515 else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 1)) acc = accel[2]; 516 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 1))) acc = accel[2];
516 else if ((jiffies - ati_remote->acc_jiffies) < HZ ) acc = accel[3]; 517 else if (time_before(jiffies, ati_remote->acc_jiffies + HZ)) acc = accel[3];
517 else if ((jiffies - ati_remote->acc_jiffies) < HZ+(HZ>>1)) acc = accel[4]; 518 else if (time_before(jiffies, ati_remote->acc_jiffies + HZ+(HZ>>1))) acc = accel[4];
518 else if ((jiffies - ati_remote->acc_jiffies) < (HZ << 1)) acc = accel[5]; 519 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ << 1))) acc = accel[5];
519 else acc = accel[6]; 520 else acc = accel[6];
520 521
521 input_regs(dev, regs); 522 input_regs(dev, regs);