提交 50297cbf 编写于 作者: M Marcelo Feitoza Parisi 提交者: Linus Torvalds

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

They deal with wrapping correctly and are nicer to read.
Signed-off-by: NMarcelo Feitoza Parisi <marcelo@feitoza.com.br>
Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 f45e4656
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/random.h> #include <linux/random.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -3654,8 +3655,8 @@ static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command) ...@@ -3654,8 +3655,8 @@ static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
(NewEnquiry->EventLogSequenceNumber != (NewEnquiry->EventLogSequenceNumber !=
OldEnquiry->EventLogSequenceNumber) || OldEnquiry->EventLogSequenceNumber) ||
Controller->MonitoringTimerCount == 0 || Controller->MonitoringTimerCount == 0 ||
(jiffies - Controller->SecondaryMonitoringTime time_after_eq(jiffies, Controller->SecondaryMonitoringTime
>= DAC960_SecondaryMonitoringInterval)) + DAC960_SecondaryMonitoringInterval))
{ {
Controller->V1.NeedLogicalDriveInformation = true; Controller->V1.NeedLogicalDriveInformation = true;
Controller->V1.NewEventLogSequenceNumber = Controller->V1.NewEventLogSequenceNumber =
...@@ -5640,8 +5641,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData) ...@@ -5640,8 +5641,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
unsigned int StatusChangeCounter = unsigned int StatusChangeCounter =
Controller->V2.HealthStatusBuffer->StatusChangeCounter; Controller->V2.HealthStatusBuffer->StatusChangeCounter;
boolean ForceMonitoringCommand = false; boolean ForceMonitoringCommand = false;
if (jiffies - Controller->SecondaryMonitoringTime if (time_after(jiffies, Controller->SecondaryMonitoringTime
> DAC960_SecondaryMonitoringInterval) + DAC960_SecondaryMonitoringInterval))
{ {
int LogicalDriveNumber; int LogicalDriveNumber;
for (LogicalDriveNumber = 0; for (LogicalDriveNumber = 0;
...@@ -5669,8 +5670,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData) ...@@ -5669,8 +5670,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
ControllerInfo->ConsistencyChecksActive + ControllerInfo->ConsistencyChecksActive +
ControllerInfo->RebuildsActive + ControllerInfo->RebuildsActive +
ControllerInfo->OnlineExpansionsActive == 0 || ControllerInfo->OnlineExpansionsActive == 0 ||
jiffies - Controller->PrimaryMonitoringTime time_before(jiffies, Controller->PrimaryMonitoringTime
< DAC960_MonitoringTimerInterval) && + DAC960_MonitoringTimerInterval)) &&
!ForceMonitoringCommand) !ForceMonitoringCommand)
{ {
Controller->MonitoringTimer.expires = Controller->MonitoringTimer.expires =
...@@ -5807,8 +5808,8 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel, ...@@ -5807,8 +5808,8 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
Controller->ProgressBufferLength = Length; Controller->ProgressBufferLength = Length;
if (Controller->EphemeralProgressMessage) if (Controller->EphemeralProgressMessage)
{ {
if (jiffies - Controller->LastProgressReportTime if (time_after_eq(jiffies, Controller->LastProgressReportTime
>= DAC960_ProgressReportingInterval) + DAC960_ProgressReportingInterval))
{ {
printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel], printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
Controller->ControllerNumber, Buffer); Controller->ControllerNumber, Buffer);
......
...@@ -170,6 +170,7 @@ static int print_unex = 1; ...@@ -170,6 +170,7 @@ static int print_unex = 1;
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/jiffies.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mc146818rtc.h> /* CMOS defines */ #include <linux/mc146818rtc.h> /* CMOS defines */
...@@ -747,7 +748,7 @@ static int disk_change(int drive) ...@@ -747,7 +748,7 @@ static int disk_change(int drive)
{ {
int fdc = FDC(drive); int fdc = FDC(drive);
#ifdef FLOPPY_SANITY_CHECK #ifdef FLOPPY_SANITY_CHECK
if (jiffies - UDRS->select_date < UDP->select_delay) if (time_before(jiffies, UDRS->select_date + UDP->select_delay))
DPRINT("WARNING disk change called early\n"); DPRINT("WARNING disk change called early\n");
if (!(FDCS->dor & (0x10 << UNIT(drive))) || if (!(FDCS->dor & (0x10 << UNIT(drive))) ||
(FDCS->dor & 3) != UNIT(drive) || fdc != FDC(drive)) { (FDCS->dor & 3) != UNIT(drive) || fdc != FDC(drive)) {
...@@ -1075,7 +1076,7 @@ static int fd_wait_for_completion(unsigned long delay, timeout_fn function) ...@@ -1075,7 +1076,7 @@ static int fd_wait_for_completion(unsigned long delay, timeout_fn function)
return 1; return 1;
} }
if ((signed)(jiffies - delay) < 0) { if (time_before(jiffies, delay)) {
del_timer(&fd_timer); del_timer(&fd_timer);
fd_timer.function = function; fd_timer.function = function;
fd_timer.expires = delay; fd_timer.expires = delay;
...@@ -1535,7 +1536,7 @@ static void setup_rw_floppy(void) ...@@ -1535,7 +1536,7 @@ static void setup_rw_floppy(void)
* again just before spinup completion. Beware that * again just before spinup completion. Beware that
* after scandrives, we must again wait for selection. * after scandrives, we must again wait for selection.
*/ */
if ((signed)(ready_date - jiffies) > DP->select_delay) { if (time_after(ready_date, jiffies + DP->select_delay)) {
ready_date -= DP->select_delay; ready_date -= DP->select_delay;
function = (timeout_fn) floppy_start; function = (timeout_fn) floppy_start;
} else } else
...@@ -3823,7 +3824,7 @@ static int check_floppy_change(struct gendisk *disk) ...@@ -3823,7 +3824,7 @@ static int check_floppy_change(struct gendisk *disk)
if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY)) if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY))
return 1; return 1;
if (UDP->checkfreq < (int)(jiffies - UDRS->last_checked)) { if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
if (floppy_grab_irq_and_dma()) { if (floppy_grab_irq_and_dma()) {
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册