Skip to contentSkip to conversation

rsxx: fix time comparison

PATCH New Asaf Vertz 1 participant 1 message Jan 7, 2015 Block layer

lore
Share & tools
lore

Asaf Vertz

author
#0 lore raw

PATCH 1/1 rsxx: fix time comparison

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

---
 drivers/block/rsxx/core.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/block/rsxx/core.c +5 -4
index d8b2488..ea527e8 100644
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/jiffies.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/reboot.h>
@@ -513,8 +514,8 @@ static void card_event_handler(struct work_struct *work)
 static int card_shutdown(struct rsxx_cardinfo *card)
 {
 	unsigned int state;
-	signed long start;
-	const int timeout = msecs_to_jiffies(120000);
+	unsigned long start;
+	const unsigned long timeout = msecs_to_jiffies(120000);
 	int st;
 
 	/* We can't issue a shutdown if the card is in a transition state */
@@ -524,7 +525,7 @@ static int card_shutdown(struct rsxx_cardinfo *card)
 		if (st)
 			return st;
 	} while (state == CARD_STATE_STARTING &&
-		 (jiffies - start < timeout));
+		 time_before(jiffies, start + timeout));
 
 	if (state == CARD_STATE_STARTING)
 		return -ETIMEDOUT;
@@ -543,7 +544,7 @@ static int card_shutdown(struct rsxx_cardinfo *card)
 		if (st)
 			return st;
 	} while (state != CARD_STATE_SHUTDOWN &&
-		 (jiffies - start < timeout));
+		 time_before(jiffies, start + timeout));
 
 	if (state != CARD_STATE_SHUTDOWN)
 		return -ETIMEDOUT;
Signature · 1 line
1.7.0.4