Re: [PATCH] drivers: net: wimax: i2400m: i2400m-usb: Use time_after for time comparison

From: Girish Moodalbail
Date: Mon May 08 2017 - 19:27:26 EST


On 5/8/17 2:26 PM, David Miller wrote:
From: Karim Eshapa <karim.eshapa@xxxxxxxxx>
Date: Mon, 8 May 2017 18:58:02 +0200

diff --git a/drivers/net/wimax/i2400m/i2400m-usb.h b/drivers/net/wimax/i2400m/i2400m-usb.h
index 649ecad..6fc941c 100644
--- a/drivers/net/wimax/i2400m/i2400m-usb.h
+++ b/drivers/net/wimax/i2400m/i2400m-usb.h
@@ -131,7 +131,7 @@ static inline int edc_inc(struct edc *edc, u16 max_err, u16 timeframe)
unsigned long now;

now = jiffies;
- if (now - edc->timestart > timeframe) {
+ if (time_after(now - edc->timestart, (unsigned long)timeframe)) {

This is far from correct.

time_after() compares two "jiffies" timestamp values. The second
argument here is not a jiffies timestamp value.


Perhaps, what is needed here is:

+ if (time_after(jiffies, edc->timestart + timeframe)) {

where in 'timeframe' is set in HZ in all the callers I checked (for the most part it is set to EDC_ERROR_TIMEFRAME which is 1HZ).

~Girish