Skip to contentSkip to conversation

e1000: fix time comparison

PATCH In review Asaf Vertz 2 participants 2 messages Jan 7, 2015

Subsystems (3)
lore
Share & tools
lore

Asaf Vertz

author
#0 lore raw

PATCH 1/1 e1000: fix time comparison

To be future-proof and for better readability the time comparisons are modified to use time_after_eq() instead of plain, error-prone math.

---
 drivers/net/ethernet/intel/e1000/e1000_ethtool.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +2 -1
index b691eb4..4270ad2 100644
@@ -24,6 +24,7 @@
 /* ethtool support for e1000 */
 
 #include "e1000.h"
+#include <linux/jiffies.h>
 #include <linux/uaccess.h>
 
 enum {NETDEV_STATS, E1000_STATS};
@@ -1460,7 +1461,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
 			ret_val = 13; /* ret_val is the same as mis-compare */
 			break;
 		}
-		if (jiffies >= (time + 2)) {
+		if (time_after_eq(jiffies, time + 2)) {
 			ret_val = 14; /* error code for time out error */
 			break;
 		}
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 7 lines · Asaf Vertz

To be future-proof and for better readability the time comparisons are modified to use time_after_eq() instead of plain, error-prone math.

---
 drivers/net/ethernet/intel/e1000/e1000_ethtool.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Thanks Asaf, I will add your patch to my queue.