Commit f0b80fbf authored by Marcelo Feitoza Parisi's avatar Marcelo Feitoza Parisi Committed by Greg Kroah-Hartman

[PATCH] USB: ati_remote: use time_before() and friends

They deal with wrapping correctly and are nicer to read.
Signed-off-by: default avatarMarcelo Feitoza Parisi <marcelo@feitoza.com.br>
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 95f209f9
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb_input.h> #include <linux/usb_input.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/jiffies.h>
/* /*
* Module and Version Information, Module Parameters * Module and Version Information, Module Parameters
...@@ -471,7 +472,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) ...@@ -471,7 +472,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
/* Filter duplicate events which happen "too close" together. */ /* Filter duplicate events which happen "too close" together. */
if ((ati_remote->old_data[0] == data[1]) && if ((ati_remote->old_data[0] == data[1]) &&
(ati_remote->old_data[1] == data[2]) && (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++; ati_remote->repeat_count++;
} else { } else {
ati_remote->repeat_count = 0; ati_remote->repeat_count = 0;
...@@ -506,16 +507,16 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) ...@@ -506,16 +507,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 * pad down, so we increase acceleration, ramping up over two seconds to
* a maximum speed. The acceleration curve is #defined above. * 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; acc = 1;
ati_remote->acc_jiffies = jiffies; ati_remote->acc_jiffies = jiffies;
} }
else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 3)) acc = accel[0]; else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 3))) acc = accel[0];
else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 2)) acc = accel[1]; else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 2))) acc = accel[1];
else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 1)) acc = accel[2]; else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 1))) acc = accel[2];
else if ((jiffies - ati_remote->acc_jiffies) < HZ ) acc = accel[3]; else if (time_before(jiffies, ati_remote->acc_jiffies + HZ)) acc = accel[3];
else if ((jiffies - ati_remote->acc_jiffies) < HZ+(HZ>>1)) acc = accel[4]; else if (time_before(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 << 1))) acc = accel[5];
else acc = accel[6]; else acc = accel[6];
input_regs(dev, regs); input_regs(dev, regs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment