[PATCH] rsxx: fix time comparison

From: Asaf Vertz
Date: Wed Jan 07 2015 - 02:38:43 EST


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

Signed-off-by: Asaf Vertz <asaf.vertz@xxxxxxxxxxx>
---
drivers/block/rsxx/core.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index d8b2488..ea527e8 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -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;
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/