Skip to contentSkip to conversation

usb: host: max3421-hcd: use time_after()

PATCH In review Asaf Vertz 2 participants 2 messages Dec 15, 2014 USB

lore
Share & tools
lore

Asaf Vertz

author
#0 lore raw

PATCH 1/1 usb: host: max3421-hcd: use time_after()

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

---
 drivers/usb/host/max3421-hcd.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/host/max3421-hcd.c +2 -1
index 6234c75..aaaff94 100644
@@ -55,6 +55,7 @@
  * single thread (max3421_spi_thread).
  */
 
+#include <linux/jiffies.h>
 #include <linux/module.h>
 #include <linux/spi/spi.h>
 #include <linux/usb.h>
@@ -1291,7 +1292,7 @@ max3421_handle_irqs(struct usb_hcd *hcd)
 		char sbuf[16 * 16], *dp, *end;
 		int i;
 
-		if (jiffies - last_time > 5*HZ) {
+		if (time_after(jiffies, last_time + 5*HZ)) {
 			dp = sbuf;
 			end = sbuf + sizeof(sbuf);
 			*dp = '\0';
Signature · 1 line
1.7.0.4
Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines · Asaf Vertz

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

---
 drivers/usb/host/max3421-hcd.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/host/max3421-hcd.c +2 -2
index 6234c75..aaaff94 100644
@@ -55,6 +55,7 @@
  * single thread (max3421_spi_thread).
  */
 
+#include <linux/jiffies.h>
 #include <linux/module.h>
 #include <linux/spi/spi.h>
 #include <linux/usb.h>
@@ -1291,7 +1292,7 @@ max3421_handle_irqs(struct usb_hcd *hcd)
                char sbuf[16 * 16], *dp, *end;
                int i;
 
-               if (jiffies - last_time > 5*HZ) {
+               if (time_after(jiffies, last_time + 5*HZ)) {
                        dp = sbuf;
                        end = sbuf + sizeof(sbuf);
                        *dp = '\0';
--

1.7.0.4

Signature · 1 line
eGauge Systems LLC, http://egauge.net/, 1.877-EGAUGE1, fax 720.545.9768