The previous calculation is wrong for jiffy wraps, because the result would be LONG_MAX/2 - (start - end), which is about LONG_MAX/2 for values near the wrap (e.g. start=LONG_MAX-1, end=1), though they should be very small. Calculating the difference with signed values works also if there was a wrap. Signed-off-by: Reiner Herrmann <reiner@xxxxxxxxxxx> --- drivers/net/wireless/ipw2x00/libipw_wx.c | 8 ++------ net/wireless/core.h | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ipw2x00/libipw_wx.c b/drivers/net/wireless/ipw2x00/libipw_wx.c index 54aba47..1c61cfc 100644 --- a/drivers/net/wireless/ipw2x00/libipw_wx.c +++ b/drivers/net/wireless/ipw2x00/libipw_wx.c @@ -47,12 +47,8 @@ static const char *libipw_modes[] = { static inline unsigned int elapsed_jiffies_msecs(unsigned long start) { - unsigned long end = jiffies; - - if (end >= start) - return jiffies_to_msecs(end - start); - - return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1); + unsigned long diff = (long)jiffies - (long)start; + return jiffies_to_msecs(diff); } #define MAX_CUSTOM_LEN 64 diff --git a/net/wireless/core.h b/net/wireless/core.h index 5b1fdca..930fbbe 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -432,12 +432,8 @@ cfg80211_can_use_chan(struct cfg80211_registered_device *rdev, static inline unsigned int elapsed_jiffies_msecs(unsigned long start) { - unsigned long end = jiffies; - - if (end >= start) - return jiffies_to_msecs(end - start); - - return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1); + unsigned long diff = (long)jiffies - (long)start; + return jiffies_to_msecs(diff); } void -- 2.0.0.rc0 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html