Commit 60c904ae authored by Marcelo Feitoza Parisi's avatar Marcelo Feitoza Parisi Committed by Linus Torvalds

[PATCH] drivers/scsi/*: use time_after() and friends

They deal with wrapping correctly and are nicer to read.
Signed-off-by: default avatarMarcelo Feitoza Parisi <marcelo@feitoza.com.br>
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9bae1ff3
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/jiffies.h>
#include <scsi/scsicam.h> #include <scsi/scsicam.h>
#include <asm/dma.h> #include <asm/dma.h>
...@@ -2896,7 +2897,7 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou ...@@ -2896,7 +2897,7 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou
*/ */
if (HostAdapter->ActiveCommands[TargetID] == 0) if (HostAdapter->ActiveCommands[TargetID] == 0)
HostAdapter->LastSequencePoint[TargetID] = jiffies; HostAdapter->LastSequencePoint[TargetID] = jiffies;
else if (jiffies - HostAdapter->LastSequencePoint[TargetID] > 4 * HZ) { else if (time_after(jiffies, HostAdapter->LastSequencePoint[TargetID] + 4 * HZ)) {
HostAdapter->LastSequencePoint[TargetID] = jiffies; HostAdapter->LastSequencePoint[TargetID] = jiffies;
QueueTag = BusLogic_OrderedQueueTag; QueueTag = BusLogic_OrderedQueueTag;
} }
......
...@@ -49,6 +49,7 @@ static const char * osst_version = "0.99.4"; ...@@ -49,6 +49,7 @@ static const char * osst_version = "0.99.4";
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/jiffies.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -856,7 +857,7 @@ static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt ...@@ -856,7 +857,7 @@ static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt
) && result >= 0) ) && result >= 0)
{ {
#if DEBUG #if DEBUG
if (debugging || jiffies - startwait >= 2*HZ/OSST_POLL_PER_SEC) if (debugging || time_after_eq(jiffies, startwait + 2*HZ/OSST_POLL_PER_SEC))
printk (OSST_DEB_MSG printk (OSST_DEB_MSG
"%s:D: Succ wait f fr %i (>%i): %i-%i %i (%i): %3li.%li s\n", "%s:D: Succ wait f fr %i (>%i): %i-%i %i (%i): %3li.%li s\n",
name, curr, curr+minlast, STp->first_frame_position, name, curr, curr+minlast, STp->first_frame_position,
...@@ -867,7 +868,7 @@ static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt ...@@ -867,7 +868,7 @@ static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt
return 0; return 0;
} }
#if DEBUG #if DEBUG
if (jiffies - startwait >= 2*HZ/OSST_POLL_PER_SEC && notyetprinted) if (time_after_eq(jiffies, startwait + 2*HZ/OSST_POLL_PER_SEC) && notyetprinted)
{ {
printk (OSST_DEB_MSG "%s:D: Wait for frame %i (>%i): %i-%i %i (%i)\n", printk (OSST_DEB_MSG "%s:D: Wait for frame %i (>%i): %i-%i %i (%i)\n",
name, curr, curr+minlast, STp->first_frame_position, name, curr, curr+minlast, STp->first_frame_position,
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/parport.h> #include <linux/parport.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/jiffies.h>
#include <asm/io.h> #include <asm/io.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
...@@ -726,7 +727,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) ...@@ -726,7 +727,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
retv--; retv--;
if (retv) { if (retv) {
if ((jiffies - dev->jstart) > (1 * HZ)) { if (time_after(jiffies, dev->jstart + (1 * HZ))) {
printk printk
("ppa: Parallel port cable is unplugged!!\n"); ("ppa: Parallel port cable is unplugged!!\n");
ppa_fail(dev, DID_BUS_BUSY); ppa_fail(dev, DID_BUS_BUSY);
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include <linux/unistd.h> #include <linux/unistd.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include "scsi.h" #include "scsi.h"
...@@ -1325,7 +1326,7 @@ static int isp2x00_queuecommand(Scsi_Cmnd * Cmnd, void (*done) (Scsi_Cmnd *)) ...@@ -1325,7 +1326,7 @@ static int isp2x00_queuecommand(Scsi_Cmnd * Cmnd, void (*done) (Scsi_Cmnd *))
cmd->control_flags = cpu_to_le16(CFLAG_READ); cmd->control_flags = cpu_to_le16(CFLAG_READ);
if (Cmnd->device->tagged_supported) { if (Cmnd->device->tagged_supported) {
if ((jiffies - hostdata->tag_ages[Cmnd->device->id]) > (2 * ISP_TIMEOUT)) { if (time_after(jiffies, hostdata->tag_ages[Cmnd->device->id] + (2 * ISP_TIMEOUT))) {
cmd->control_flags |= cpu_to_le16(CFLAG_ORDERED_TAG); cmd->control_flags |= cpu_to_le16(CFLAG_ORDERED_TAG);
hostdata->tag_ages[Cmnd->device->id] = jiffies; hostdata->tag_ages[Cmnd->device->id] = jiffies;
} else } else
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/jiffies.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
...@@ -1017,7 +1018,7 @@ static inline void cmd_frob(struct Command_Entry *cmd, struct scsi_cmnd *Cmnd, ...@@ -1017,7 +1018,7 @@ static inline void cmd_frob(struct Command_Entry *cmd, struct scsi_cmnd *Cmnd,
if (Cmnd->device->tagged_supported) { if (Cmnd->device->tagged_supported) {
if (qpti->cmd_count[Cmnd->device->id] == 0) if (qpti->cmd_count[Cmnd->device->id] == 0)
qpti->tag_ages[Cmnd->device->id] = jiffies; qpti->tag_ages[Cmnd->device->id] = jiffies;
if ((jiffies - qpti->tag_ages[Cmnd->device->id]) > (5*HZ)) { if (time_after(jiffies, qpti->tag_ages[Cmnd->device->id] + (5*HZ))) {
cmd->control_flags = CFLAG_ORDERED_TAG; cmd->control_flags = CFLAG_ORDERED_TAG;
qpti->tag_ages[Cmnd->device->id] = jiffies; qpti->tag_ages[Cmnd->device->id] = jiffies;
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment