Commit a8178345 authored by Marcelo Feitoza Parisi's avatar Marcelo Feitoza Parisi Committed by David S. Miller

[WAN]: drivers/net/wan/: use of time_after macro

From: Marcelo Feitoza Parisi <marcelo@feitoza.com.br>

Use of the time_after() macro, defined at linux/jiffies.h, which deal
with wrapping correctly and are nicer to read.
Signed-off-by: default avatarMarcelo Feitoza Parisi <marcelo@feitoza.com.br>
Signed-off-by: default avatarDomen Puncer <domen@coderock.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9d853c37
...@@ -152,6 +152,7 @@ ...@@ -152,6 +152,7 @@
#include <asm/io.h> /* for inb(), outb(), etc. */ #include <asm/io.h> /* for inb(), outb(), etc. */
#include <linux/time.h> /* for do_gettimeofday */ #include <linux/time.h> /* for do_gettimeofday */
#include <linux/in.h> /* sockaddr_in */ #include <linux/in.h> /* sockaddr_in */
#include <linux/jiffies.h> /* time_after() macro */
#include <asm/errno.h> #include <asm/errno.h>
#include <linux/ip.h> #include <linux/ip.h>
...@@ -773,7 +774,7 @@ static int update(struct wan_device* wandev) ...@@ -773,7 +774,7 @@ static int update(struct wan_device* wandev)
for(;;) { for(;;) {
if(card->u.f.update_comms_stats == 0) if(card->u.f.update_comms_stats == 0)
break; break;
if ((jiffies - timeout) > (1 * HZ)){ if (time_after(jiffies, timeout + 1 * HZ)){
card->u.f.update_comms_stats = 0; card->u.f.update_comms_stats = 0;
return -EAGAIN; return -EAGAIN;
} }
...@@ -4799,7 +4800,7 @@ static void trigger_unconfig_fr(struct net_device *dev) ...@@ -4799,7 +4800,7 @@ static void trigger_unconfig_fr(struct net_device *dev)
{ {
fr_channel_t *chan = dev->priv; fr_channel_t *chan = dev->priv;
volatile sdla_t *card = chan->card; volatile sdla_t *card = chan->card;
u32 timeout; unsigned long timeout;
fr508_flags_t* flags = card->flags; fr508_flags_t* flags = card->flags;
int reset_critical=0; int reset_critical=0;
...@@ -4821,7 +4822,7 @@ static void trigger_unconfig_fr(struct net_device *dev) ...@@ -4821,7 +4822,7 @@ static void trigger_unconfig_fr(struct net_device *dev)
if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG)) if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG))
break; break;
if ((jiffies - timeout) > (1 * HZ)){ if (time_after(jiffies, timeout + 1 * HZ)){
card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG; card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG;
printk(KERN_INFO "%s: Failed to delete DLCI %i\n", printk(KERN_INFO "%s: Failed to delete DLCI %i\n",
card->devname,chan->dlci); card->devname,chan->dlci);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/wanrouter.h> /* WAN router definitions */ #include <linux/wanrouter.h> /* WAN router definitions */
#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ #include <linux/wanpipe.h> /* WANPIPE common user API definitions */
#include <linux/if_arp.h> /* ARPHRD_* defines */ #include <linux/if_arp.h> /* ARPHRD_* defines */
#include <linux/jiffies.h> /* time_after() macro */
#include <linux/inetdevice.h> #include <linux/inetdevice.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -164,7 +165,7 @@ int wpft1_init (sdla_t* card, wandev_conf_t* conf) ...@@ -164,7 +165,7 @@ int wpft1_init (sdla_t* card, wandev_conf_t* conf)
timeout = jiffies; timeout = jiffies;
while (mb->return_code != 'I') /* Wait 1s for board to initialize */ while (mb->return_code != 'I') /* Wait 1s for board to initialize */
if ((jiffies - timeout) > 1*HZ) break; if (time_after(jiffies, timeout + 1*HZ)) break;
if (mb->return_code != 'I') { if (mb->return_code != 'I') {
printk(KERN_INFO printk(KERN_INFO
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
#include <linux/if_arp.h> /* ARPHRD_* defines */ #include <linux/if_arp.h> /* ARPHRD_* defines */
#include <asm/byteorder.h> /* htons(), etc. */ #include <asm/byteorder.h> /* htons(), etc. */
#include <linux/in.h> /* sockaddr_in */ #include <linux/in.h> /* sockaddr_in */
#include <linux/jiffies.h> /* time_after() macro */
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -482,7 +483,7 @@ static int update(struct wan_device *wandev) ...@@ -482,7 +483,7 @@ static int update(struct wan_device *wandev)
if(ppp_priv_area->update_comms_stats == 0){ if(ppp_priv_area->update_comms_stats == 0){
break; break;
} }
if ((jiffies - timeout) > (1 * HZ)){ if (time_after(jiffies, timeout + 1 * HZ)){
ppp_priv_area->update_comms_stats = 0; ppp_priv_area->update_comms_stats = 0;
ppp_priv_area->timer_int_enabled &= ppp_priv_area->timer_int_enabled &=
~TMR_INT_ENABLED_UPDATE; ~TMR_INT_ENABLED_UPDATE;
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
#include <linux/wanrouter.h> /* WAN router definitions */ #include <linux/wanrouter.h> /* WAN router definitions */
#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ #include <linux/wanpipe.h> /* WANPIPE common user API definitions */
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/jiffies.h> /* time_after() macro */
#include <asm/byteorder.h> /* htons(), etc. */ #include <asm/byteorder.h> /* htons(), etc. */
#include <asm/atomic.h> #include <asm/atomic.h>
#include <linux/delay.h> /* Experimental delay */ #include <linux/delay.h> /* Experimental delay */
...@@ -867,7 +868,7 @@ static int update(struct wan_device* wandev) ...@@ -867,7 +868,7 @@ static int update(struct wan_device* wandev)
if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){ if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){
break; break;
} }
if ((jiffies-timeout) > 1*HZ){ if (time_after(jiffies, timeout + 1*HZ)){
card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE; card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE;
return -EAGAIN; return -EAGAIN;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/wanrouter.h> /* WAN router definitions */ #include <linux/wanrouter.h> /* WAN router definitions */
#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ #include <linux/wanpipe.h> /* WANPIPE common user API definitions */
#include <linux/if_arp.h> /* ARPHRD_* defines */ #include <linux/if_arp.h> /* ARPHRD_* defines */
#include <linux/jiffies.h> /* time_after() macro */
#include <linux/in.h> /* sockaddr_in */ #include <linux/in.h> /* sockaddr_in */
#include <linux/inet.h> #include <linux/inet.h>
...@@ -270,9 +271,9 @@ int wsppp_init (sdla_t* card, wandev_conf_t* conf) ...@@ -270,9 +271,9 @@ int wsppp_init (sdla_t* card, wandev_conf_t* conf)
ready to accept commands. We expect this to be completed in less ready to accept commands. We expect this to be completed in less
than 1 second. */ than 1 second. */
timeout = jiffies; timeout = jiffies + 1 * HZ;
while (mb->return_code != 'I') /* Wait 1s for board to initialize */ while (mb->return_code != 'I') /* Wait 1s for board to initialize */
if ((jiffies - timeout) > 1*HZ) break; if (time_after(jiffies, timeout)) break;
if (mb->return_code != 'I') { if (mb->return_code != 'I') {
printk(KERN_INFO printk(KERN_INFO
...@@ -493,11 +494,11 @@ static int update(struct wan_device* wandev) ...@@ -493,11 +494,11 @@ static int update(struct wan_device* wandev)
chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE; chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE;
/* wait a maximum of 1 second for the statistics to be updated */ /* wait a maximum of 1 second for the statistics to be updated */
timeout = jiffies; timeout = jiffies + 1 * HZ;
for(;;) { for(;;) {
if(chdlc_priv_area->update_comms_stats == 0) if(chdlc_priv_area->update_comms_stats == 0)
break; break;
if ((jiffies - timeout) > (1 * HZ)){ if (time_after(jiffies, timeout)){
chdlc_priv_area->update_comms_stats = 0; chdlc_priv_area->update_comms_stats = 0;
chdlc_priv_area->timer_int_enabled &= chdlc_priv_area->timer_int_enabled &=
~TMR_INT_ENABLED_UPDATE; ~TMR_INT_ENABLED_UPDATE;
......
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