Commit f9409775 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] jiffies wrap fixes

Patch from Tim Schmielau <tim@physik3.uni-rostock.de>

Converts many open-coded jiffy comparisons to use time_after/before/etc.
parent b72d7dcb
...@@ -459,7 +459,8 @@ static int etrax_usb_unlink_intr_urb(struct urb *urb) ...@@ -459,7 +459,8 @@ static int etrax_usb_unlink_intr_urb(struct urb *urb)
*R_DMA_CH8_SUB2_CMD = IO_STATE(R_DMA_CH8_SUB2_CMD, cmd, stop); *R_DMA_CH8_SUB2_CMD = IO_STATE(R_DMA_CH8_SUB2_CMD, cmd, stop);
/* Somehow wait for the DMA to finish current activities */ /* Somehow wait for the DMA to finish current activities */
i = jiffies + 100; i = jiffies + 100;
while (jiffies < i); while (time_before(jiffies, i))
;
first_ep = &TxIntrEPList[0]; first_ep = &TxIntrEPList[0];
tmp_ep = first_ep; tmp_ep = first_ep;
......
...@@ -1785,7 +1785,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -1785,7 +1785,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
schedule_timeout(char_time); schedule_timeout(char_time);
if (signal_pending(current)) if (signal_pending(current))
break; break;
if (timeout && ((orig_jiffies + timeout) < jiffies)) if (timeout && time_after(jiffies, orig_jiffies + timeout))
break; break;
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
......
...@@ -2832,7 +2832,7 @@ static void moxadelay(int tick) ...@@ -2832,7 +2832,7 @@ static void moxadelay(int tick)
st = jiffies; st = jiffies;
et = st + tick; et = st + tick;
while (jiffies < et); while (time_before(jiffies, et));
} }
static void moxafunc(unsigned long ofsAddr, int cmd, ushort arg) static void moxafunc(unsigned long ofsAddr, int cmd, ushort arg)
......
...@@ -857,7 +857,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) ...@@ -857,7 +857,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) { while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(5); schedule_timeout(5);
if (jiffies > timeout) if (time_after(jiffies, timeout))
break; break;
} }
} }
......
...@@ -78,7 +78,7 @@ static void iic_ite_setiic(void *data, int ctl, short val) ...@@ -78,7 +78,7 @@ static void iic_ite_setiic(void *data, int ctl, short val)
unsigned long j = jiffies + 10; unsigned long j = jiffies + 10;
DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff)); DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff));
DEB3({while (jiffies < j) schedule();}) DEB3({while (time_before(jiffies, j)) schedule();})
outw(val,ctl); outw(val,ctl);
} }
......
...@@ -84,7 +84,7 @@ MODULE_LICENSE("GPL"); ...@@ -84,7 +84,7 @@ MODULE_LICENSE("GPL");
/* respectively. This makes sure that the algorithm works. Some chips */ /* respectively. This makes sure that the algorithm works. Some chips */
/* might not like this, as they have an internal timeout of some mils */ /* might not like this, as they have an internal timeout of some mils */
/* /*
#define SLO_IO jif=jiffies;while(jiffies<=jif+i2c_table[minor].veryslow)\ #define SLO_IO jif=jiffies;while(time_before_eq(jiffies,jif+i2c_table[minor].veryslow))\
if (need_resched) schedule(); if (need_resched) schedule();
*/ */
......
...@@ -3057,7 +3057,7 @@ eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb) ...@@ -3057,7 +3057,7 @@ eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb)
} }
timeout = jiffies + 50; timeout = jiffies + 50;
while (timeout > jiffies) { while (time_before(jiffies, timeout)) {
if (chan->e.B2Id) break; if (chan->e.B2Id) break;
SLEEP(10); SLEEP(10);
} }
...@@ -3119,7 +3119,7 @@ eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb) ...@@ -3119,7 +3119,7 @@ eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb)
eicon_tx_request(card); eicon_tx_request(card);
timeout = jiffies + 50; timeout = jiffies + 50;
while (timeout > jiffies) { while (time_before(jiffies, timeout)) {
if (chan->fsm_state) break; if (chan->fsm_state) break;
SLEEP(10); SLEEP(10);
} }
......
...@@ -350,7 +350,7 @@ static int fpga_write(int iobase, unsigned char wrd) ...@@ -350,7 +350,7 @@ static int fpga_write(int iobase, unsigned char wrd)
wrd <<= 1; wrd <<= 1;
outb(0xfc, THR(iobase)); outb(0xfc, THR(iobase));
while ((inb(LSR(iobase)) & LSR_TSRE) == 0) while ((inb(LSR(iobase)) & LSR_TSRE) == 0)
if (jiffies > timeout) if (time_after(jiffies, timeout))
return -1; return -1;
} }
......
...@@ -447,7 +447,7 @@ busy_loop(u_long len) ...@@ -447,7 +447,7 @@ busy_loop(u_long len)
u_long flags; u_long flags;
save_flags(flags); save_flags(flags);
sti(); sti();
while (timeout >= jiffies) while (time_before_eq(jiffies, timeout))
; ;
restore_flags(flags); restore_flags(flags);
} else { } else {
......
...@@ -591,7 +591,7 @@ static int __init sis900_mii_probe (struct net_device * net_dev) ...@@ -591,7 +591,7 @@ static int __init sis900_mii_probe (struct net_device * net_dev)
yield(); yield();
poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS) & poll_bit); poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS) & poll_bit);
if (jiffies >= timeout) { if (time_after_eq(jiffies, timeout)) {
printk(KERN_WARNING "%s: reset phy and link down now\n", net_dev->name); printk(KERN_WARNING "%s: reset phy and link down now\n", net_dev->name);
return -ETIME; return -ETIME;
} }
......
...@@ -492,11 +492,11 @@ static int COMX_open(struct net_device *dev) ...@@ -492,11 +492,11 @@ static int COMX_open(struct net_device *dev)
COMX_CMD(dev, COMX_CMD_INIT); COMX_CMD(dev, COMX_CMD_INIT);
jiffs = jiffies; jiffs = jiffies;
while (COMX_readw(dev, OFF_A_L2_LINKUP) != 1 && jiffies < jiffs + HZ) { while (COMX_readw(dev, OFF_A_L2_LINKUP) != 1 && time_before(jiffies, jiffs + HZ)) {
schedule_timeout(1); schedule_timeout(1);
} }
if (jiffies >= jiffs + HZ) { if (time_after_eq(jiffies, jiffs + HZ)) {
printk(KERN_ERR "%s: board timeout on INIT command\n", dev->name); printk(KERN_ERR "%s: board timeout on INIT command\n", dev->name);
ch->HW_release_board(dev, savep); ch->HW_release_board(dev, savep);
retval=-EIO; retval=-EIO;
...@@ -507,11 +507,11 @@ static int COMX_open(struct net_device *dev) ...@@ -507,11 +507,11 @@ static int COMX_open(struct net_device *dev)
COMX_CMD(dev, COMX_CMD_OPEN); COMX_CMD(dev, COMX_CMD_OPEN);
jiffs = jiffies; jiffs = jiffies;
while (COMX_readw(dev, OFF_A_L2_LINKUP) != 3 && jiffies < jiffs + HZ) { while (COMX_readw(dev, OFF_A_L2_LINKUP) != 3 && time_before(jiffies, jiffs + HZ)) {
schedule_timeout(1); schedule_timeout(1);
} }
if (jiffies >= jiffs + HZ) { if (time_after_eq(jiffies, jiffs + HZ)) {
printk(KERN_ERR "%s: board timeout on OPEN command\n", dev->name); printk(KERN_ERR "%s: board timeout on OPEN command\n", dev->name);
ch->HW_release_board(dev, savep); ch->HW_release_board(dev, savep);
retval=-EIO; retval=-EIO;
......
...@@ -104,7 +104,7 @@ static inline void hscx_cmd(struct net_device *dev, int cmd) ...@@ -104,7 +104,7 @@ static inline void hscx_cmd(struct net_device *dev, int cmd)
unsigned delay = 0; unsigned delay = 0;
while ((cec = (rd_hscx(dev, HSCX_STAR) & HSCX_CEC) != 0) && while ((cec = (rd_hscx(dev, HSCX_STAR) & HSCX_CEC) != 0) &&
(jiffs + HZ > jiffies)) { time_before(jiffies, jiffs + HZ)) {
udelay(1); udelay(1);
if (++delay > (100000 / HZ)) break; if (++delay > (100000 / HZ)) break;
} }
......
...@@ -272,7 +272,7 @@ static __inline__ unsigned int sym53c416_read(int base, unsigned char *buffer, u ...@@ -272,7 +272,7 @@ static __inline__ unsigned int sym53c416_read(int base, unsigned char *buffer, u
{ {
i = jiffies + timeout; i = jiffies + timeout;
spin_unlock_irqrestore(&sym53c416_lock, flags); spin_unlock_irqrestore(&sym53c416_lock, flags);
while(jiffies < i && (inb(base + PIO_INT_REG) & EMPTY) && timeout) while(time_before(jiffies, i) && (inb(base + PIO_INT_REG) & EMPTY) && timeout)
if(inb(base + PIO_INT_REG) & SCI) if(inb(base + PIO_INT_REG) & SCI)
timeout = 0; timeout = 0;
spin_lock_irqsave(&sym53c416_lock, flags); spin_lock_irqsave(&sym53c416_lock, flags);
...@@ -316,7 +316,7 @@ static __inline__ unsigned int sym53c416_write(int base, unsigned char *buffer, ...@@ -316,7 +316,7 @@ static __inline__ unsigned int sym53c416_write(int base, unsigned char *buffer,
{ {
i = jiffies + timeout; i = jiffies + timeout;
spin_unlock_irqrestore(&sym53c416_lock, flags); spin_unlock_irqrestore(&sym53c416_lock, flags);
while(jiffies < i && (inb(base + PIO_INT_REG) & FULL) && timeout) while(time_before(jiffies, i) && (inb(base + PIO_INT_REG) & FULL) && timeout)
; ;
spin_lock_irqsave(&sym53c416_lock, flags); spin_lock_irqsave(&sym53c416_lock, flags);
if(inb(base + PIO_INT_REG) & FULL) if(inb(base + PIO_INT_REG) & FULL)
...@@ -552,7 +552,7 @@ static int sym53c416_probeirq(int base, int scsi_id) ...@@ -552,7 +552,7 @@ static int sym53c416_probeirq(int base, int scsi_id)
outb(0x00, base + DEST_BUS_ID); outb(0x00, base + DEST_BUS_ID);
/* Wait for interrupt to occur */ /* Wait for interrupt to occur */
i = jiffies + 20; i = jiffies + 20;
while(i > jiffies && !(inb(base + STATUS_REG) & SCI)) while(time_before(jiffies, i) && !(inb(base + STATUS_REG) & SCI))
barrier(); barrier();
if(time_before_eq(i, jiffies)) /* timed out */ if(time_before_eq(i, jiffies)) /* timed out */
return 0; return 0;
......
...@@ -3260,7 +3260,7 @@ static int __init probe_vwsnd(struct address_info *hw_config) ...@@ -3260,7 +3260,7 @@ static int __init probe_vwsnd(struct address_info *hw_config)
li_writel(&lith, LI_HOST_CONTROLLER, LI_HC_LINK_ENABLE); li_writel(&lith, LI_HOST_CONTROLLER, LI_HC_LINK_ENABLE);
do { do {
w = li_readl(&lith, LI_HOST_CONTROLLER); w = li_readl(&lith, LI_HOST_CONTROLLER);
} while (w == LI_HC_LINK_ENABLE && jiffies < later); } while (w == LI_HC_LINK_ENABLE && time_before(jiffies, later));
li_destroy(&lith); li_destroy(&lith);
......
...@@ -1664,7 +1664,7 @@ static int snd_ensoniq_joy_enable(ensoniq_t *ensoniq) ...@@ -1664,7 +1664,7 @@ static int snd_ensoniq_joy_enable(ensoniq_t *ensoniq)
if (!request_region(ensoniq->gameport.io, 8, "ens137x: gameport")) { if (!request_region(ensoniq->gameport.io, 8, "ens137x: gameport")) {
#define ES___GAMEPORT_LOG_DELAY (30*HZ) #define ES___GAMEPORT_LOG_DELAY (30*HZ)
// avoid log pollution: limit to 2 infos per minute // avoid log pollution: limit to 2 infos per minute
if (jiffies > last_jiffies + ES___GAMEPORT_LOG_DELAY) { if (time_after(jiffies, last_jiffies + ES___GAMEPORT_LOG_DELAY)) {
last_jiffies = jiffies; last_jiffies = jiffies;
snd_printk("gameport io port 0x%03x in use", ensoniq->gameport.io); snd_printk("gameport io port 0x%03x in use", ensoniq->gameport.io);
} }
......
...@@ -598,7 +598,7 @@ static void snd_korg1212_WaitForCardStopAck(korg1212_t *korg1212) ...@@ -598,7 +598,7 @@ static void snd_korg1212_WaitForCardStopAck(korg1212_t *korg1212)
return; return;
if (!korg1212->inIRQ) if (!korg1212->inIRQ)
schedule(); schedule();
} while (jiffies < endtime); } while (time_before(jiffies, endtime));
writel(0, &korg1212->sharedBufferPtr->cardCommand); writel(0, &korg1212->sharedBufferPtr->cardCommand);
} }
......
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