Commit e149ee4c authored by Dave Jones's avatar Dave Jones Committed by Jaroslav Kysela

[PATCH] Jiffies wrap fixes.

parent 2617765b
...@@ -251,7 +251,7 @@ static void ...@@ -251,7 +251,7 @@ static void
fore200e_spin(int msecs) fore200e_spin(int msecs)
{ {
unsigned long timeout = jiffies + MSECS(msecs); unsigned long timeout = jiffies + MSECS(msecs);
while (jiffies < timeout); while (time_before(jiffies, timeout));
} }
...@@ -266,7 +266,7 @@ fore200e_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs) ...@@ -266,7 +266,7 @@ fore200e_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs)
if ((ok = (*addr == val)) || (*addr & STATUS_ERROR)) if ((ok = (*addr == val)) || (*addr & STATUS_ERROR))
break; break;
} while (jiffies < timeout); } while (time_before(jiffies, timeout));
#if 1 #if 1
if (!ok) { if (!ok) {
...@@ -289,7 +289,7 @@ fore200e_io_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int mse ...@@ -289,7 +289,7 @@ fore200e_io_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int mse
if ((ok = (fore200e->bus->read(addr) == val))) if ((ok = (fore200e->bus->read(addr) == val)))
break; break;
} while (jiffies < timeout); } while (time_before(jiffies, timeout));
#if 1 #if 1
if (!ok) { if (!ok) {
...@@ -2416,7 +2416,7 @@ fore200e_monitor_getc(struct fore200e* fore200e) ...@@ -2416,7 +2416,7 @@ fore200e_monitor_getc(struct fore200e* fore200e)
unsigned long timeout = jiffies + MSECS(50); unsigned long timeout = jiffies + MSECS(50);
int c; int c;
while (jiffies < timeout) { while (time_before(jiffies, timeout)) {
c = (int) fore200e->bus->read(&monitor->soft_uart.recv); c = (int) fore200e->bus->read(&monitor->soft_uart.recv);
......
...@@ -3870,8 +3870,11 @@ struct pci_dev *pdev = NULL; ...@@ -3870,8 +3870,11 @@ struct pci_dev *pdev = NULL;
/* Wait for the Link to come up and the login process /* Wait for the Link to come up and the login process
* to complete. * to complete.
*/ */
for(timeout = jiffies + 10*HZ; (timeout > jiffies) && ((fi->g.link_up == FALSE) || (fi->g.port_discovery == TRUE) || (fi->g.explore_fabric == TRUE) || (fi->g.perform_adisc == TRUE));) for(timeout = jiffies + 10*HZ; time_before(jiffies, timeout) && ((fi->g.link_up == FALSE) || (fi->g.port_discovery == TRUE) || (fi->g.explore_fabric == TRUE) || (fi->g.perform_adisc == TRUE));)
{
cpu_relax();
barrier(); barrier();
}
count++; count++;
no_of_hosts++; no_of_hosts++;
......
...@@ -773,7 +773,7 @@ static int rr_init1(struct net_device *dev) ...@@ -773,7 +773,7 @@ static int rr_init1(struct net_device *dev)
* Give the FirmWare time to chew on the `get running' command. * Give the FirmWare time to chew on the `get running' command.
*/ */
myjif = jiffies + 5 * HZ; myjif = jiffies + 5 * HZ;
while ((jiffies < myjif) && !rrpriv->fw_running); while (time_before(jiffies, myjif) && !rrpriv->fw_running);
netif_start_queue(dev); netif_start_queue(dev);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#define DbgDelay(secs) { int wait_time; printk( " DbgDelay %ds ", secs); \ #define DbgDelay(secs) { int wait_time; printk( " DbgDelay %ds ", secs); \
for( wait_time=jiffies + (secs*HZ); \ for( wait_time=jiffies + (secs*HZ); \
wait_time > jiffies ;) ; } time_before(jiffies, wait_time) ;) ; }
#define CPQFCTS_DRIVER_VER(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) #define CPQFCTS_DRIVER_VER(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
// don't forget to also change MODULE_DESCRIPTION in cpqfcTSinit.c // don't forget to also change MODULE_DESCRIPTION in cpqfcTSinit.c
......
...@@ -1464,7 +1464,7 @@ static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout) ...@@ -1464,7 +1464,7 @@ static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout)
timer_table[SCSI_TIMER].expires = jiffies + timeout; timer_table[SCSI_TIMER].expires = jiffies + timeout;
timer_active |= 1 << SCSI_TIMER; timer_active |= 1 << SCSI_TIMER;
} else { } else {
if (jiffies + timeout < timer_table[SCSI_TIMER].expires) if (time_before(jiffies + timeout, timer_table[SCSI_TIMER].expires))
timer_table[SCSI_TIMER].expires = jiffies + timeout; timer_table[SCSI_TIMER].expires = jiffies + timeout;
} }
} }
......
...@@ -271,11 +271,11 @@ static int ql_wai(void) ...@@ -271,11 +271,11 @@ static int ql_wai(void)
int i,k; int i,k;
k = 0; k = 0;
i = jiffies + WATCHDOG; i = jiffies + WATCHDOG;
while ( i > jiffies && !qabort && !((k = inb(qbase + 4)) & 0xe0)) { while (time_before(jiffies, i) && !qabort && !((k = inb(qbase + 4)) & 0xe0)) {
barrier(); barrier();
cpu_relax(); cpu_relax();
} }
if (i <= jiffies) if (time_after_eq(jiffies, i))
return (DID_TIME_OUT); return (DID_TIME_OUT);
if (qabort) if (qabort)
return (qabort == 1 ? DID_ABORT : DID_RESET); return (qabort == 1 ? DID_ABORT : DID_RESET);
...@@ -407,8 +407,8 @@ rtrc(2) ...@@ -407,8 +407,8 @@ rtrc(2)
} }
/*** Enter Status (and Message In) Phase ***/ /*** Enter Status (and Message In) Phase ***/
k = jiffies + WATCHDOG; k = jiffies + WATCHDOG;
while ( k > jiffies && !qabort && !(inb(qbase + 4) & 6)); /* wait for status phase */ while ( time_before(jiffies, k) && !qabort && !(inb(qbase + 4) & 6)); /* wait for status phase */
if ( k <= jiffies ) { if ( time_after_eq(jiffies, k) ) {
ql_zap(); ql_zap();
return (DID_TIME_OUT << 16); return (DID_TIME_OUT << 16);
} }
......
...@@ -802,7 +802,7 @@ int isp2x00_detect(Scsi_Host_Template * tmpt) ...@@ -802,7 +802,7 @@ int isp2x00_detect(Scsi_Host_Template * tmpt)
outw(HCCR_CLEAR_RISC_INTR, host->io_port + HOST_HCCR); outw(HCCR_CLEAR_RISC_INTR, host->io_port + HOST_HCCR);
isp2x00_enable_irqs(host); isp2x00_enable_irqs(host);
/* wait for the loop to come up */ /* wait for the loop to come up */
for (wait_time = jiffies + 10 * HZ; wait_time > jiffies && hostdata->adapter_state == AS_LOOP_DOWN;) { for (wait_time = jiffies + 10 * HZ; time_before(jiffies, wait_time) && hostdata->adapter_state == AS_LOOP_DOWN;) {
barrier(); barrier();
cpu_relax(); cpu_relax();
} }
...@@ -819,7 +819,7 @@ int isp2x00_detect(Scsi_Host_Template * tmpt) ...@@ -819,7 +819,7 @@ int isp2x00_detect(Scsi_Host_Template * tmpt)
some time before recognizing it is attached to a fabric */ some time before recognizing it is attached to a fabric */
#if ISP2x00_FABRIC #if ISP2x00_FABRIC
for (wait_time = jiffies + 5 * HZ; wait_time > jiffies;) { for (wait_time = jiffies + 5 * HZ; time_before(jiffies, wait_time);) {
barrier(); barrier();
cpu_relax(); cpu_relax();
} }
......
...@@ -357,7 +357,7 @@ static void sun3_scsi_reset_boot(struct Scsi_Host *instance) ...@@ -357,7 +357,7 @@ static void sun3_scsi_reset_boot(struct Scsi_Host *instance)
NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE ); NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE );
NCR5380_read( RESET_PARITY_INTERRUPT_REG ); NCR5380_read( RESET_PARITY_INTERRUPT_REG );
for( end = jiffies + AFTER_RESET_DELAY; jiffies < end; ) for( end = jiffies + AFTER_RESET_DELAY; time_before(jiffies, end); )
barrier(); barrier();
/* switch on SCSI IRQ again */ /* switch on SCSI IRQ again */
......
...@@ -732,7 +732,7 @@ count ); ...@@ -732,7 +732,7 @@ count );
while( count > 0 && ret == 0 ) { while( count > 0 && ret == 0 ) {
while( (port->write_urb->status == -EINPROGRESS while( (port->write_urb->status == -EINPROGRESS
|| priv->dp_write_urb_in_use) && jiffies < timeout ) { || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) {
cond_wait_interruptible_timeout_irqrestore( cond_wait_interruptible_timeout_irqrestore(
&port->write_wait, DIGI_RETRY_TIMEOUT, &port->write_wait, DIGI_RETRY_TIMEOUT,
&priv->dp_port_lock, flags ); &priv->dp_port_lock, flags );
...@@ -897,7 +897,7 @@ static int digi_transmit_idle( struct usb_serial_port *port, ...@@ -897,7 +897,7 @@ static int digi_transmit_idle( struct usb_serial_port *port,
spin_lock_irqsave( &priv->dp_port_lock, flags ); spin_lock_irqsave( &priv->dp_port_lock, flags );
while( jiffies < timeout && !priv->dp_transmit_idle ) { while( time_before(jiffies, timeout) && !priv->dp_transmit_idle ) {
cond_wait_interruptible_timeout_irqrestore( cond_wait_interruptible_timeout_irqrestore(
&priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT, &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT,
&priv->dp_port_lock, flags ); &priv->dp_port_lock, flags );
......
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