[PATCH] ati_remote.c: use time_after and time_before macros From: Marcelo Feitoza Parisi They deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Alexey Dobriyan Index: linux-kj/drivers/usb/input/ati_remote.c =================================================================== --- linux-kj.orig/drivers/usb/input/ati_remote.c 2005-10-11 18:37:41.000000000 +0400 +++ linux-kj/drivers/usb/input/ati_remote.c 2005-10-11 18:37:54.000000000 +0400 @@ -96,6 +96,7 @@ #include #include #include +#include /* * Module and Version Information, Module Parameters @@ -476,7 +477,8 @@ static void ati_remote_input_report(stru /* 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; @@ -511,16 +513,22 @@ static void ati_remote_input_report(stru * 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);