提交 cd8749b4 编写于 作者: M Marcelo Feitoza Parisi 提交者: Jeff Garzik

[PATCH] Use time_before in hamradio drivers

Use of time_before() macro, defined at linux/jiffies.h, which deal with
wrapping correctly and are nicer to read.
Signed-off-by: NMarcelo Feitoza Parisi <marcelo@feitoza.com.br>
Signed-off-by: NDomen Puncer <domen@coderock.org>
Signed-off-by: NRalf Baechle DL5RB <ralf@linux-mips.org>

 baycom_epp.c     |    3 ++-
 baycom_par.c     |    3 ++-
 baycom_ser_fdx.c |    3 ++-
 baycom_ser_hdx.c |    3 ++-
 mkiss.c          |    3 ++-
 5 files changed, 10 insertions(+), 5 deletions(-)
Signed-off-by: NJeff Garzik <jgarzik@pobox.com>
上级 6b9b97ce
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/hdlcdrv.h> #include <linux/hdlcdrv.h>
#include <linux/baycom.h> #include <linux/baycom.h>
#include <linux/jiffies.h>
#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
/* prototypes for ax25_encapsulate and ax25_rebuild_header */ /* prototypes for ax25_encapsulate and ax25_rebuild_header */
#include <net/ax25.h> #include <net/ax25.h>
...@@ -287,7 +288,7 @@ static inline void baycom_int_freq(struct baycom_state *bc) ...@@ -287,7 +288,7 @@ static inline void baycom_int_freq(struct baycom_state *bc)
* measure the interrupt frequency * measure the interrupt frequency
*/ */
bc->debug_vals.cur_intcnt++; bc->debug_vals.cur_intcnt++;
if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
bc->debug_vals.last_jiffies = cur_jiffies; bc->debug_vals.last_jiffies = cur_jiffies;
bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
bc->debug_vals.cur_intcnt = 0; bc->debug_vals.cur_intcnt = 0;
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
#include <linux/baycom.h> #include <linux/baycom.h>
#include <linux/parport.h> #include <linux/parport.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/jiffies.h>
#include <asm/bug.h> #include <asm/bug.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -165,7 +166,7 @@ static void __inline__ baycom_int_freq(struct baycom_state *bc) ...@@ -165,7 +166,7 @@ static void __inline__ baycom_int_freq(struct baycom_state *bc)
* measure the interrupt frequency * measure the interrupt frequency
*/ */
bc->debug_vals.cur_intcnt++; bc->debug_vals.cur_intcnt++;
if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
bc->debug_vals.last_jiffies = cur_jiffies; bc->debug_vals.last_jiffies = cur_jiffies;
bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
bc->debug_vals.cur_intcnt = 0; bc->debug_vals.cur_intcnt = 0;
......
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <linux/hdlcdrv.h> #include <linux/hdlcdrv.h>
#include <linux/baycom.h> #include <linux/baycom.h>
#include <linux/jiffies.h>
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
...@@ -159,7 +160,7 @@ static inline void baycom_int_freq(struct baycom_state *bc) ...@@ -159,7 +160,7 @@ static inline void baycom_int_freq(struct baycom_state *bc)
* measure the interrupt frequency * measure the interrupt frequency
*/ */
bc->debug_vals.cur_intcnt++; bc->debug_vals.cur_intcnt++;
if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
bc->debug_vals.last_jiffies = cur_jiffies; bc->debug_vals.last_jiffies = cur_jiffies;
bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
bc->debug_vals.cur_intcnt = 0; bc->debug_vals.cur_intcnt = 0;
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <linux/hdlcdrv.h> #include <linux/hdlcdrv.h>
#include <linux/baycom.h> #include <linux/baycom.h>
#include <linux/jiffies.h>
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
...@@ -150,7 +151,7 @@ static inline void baycom_int_freq(struct baycom_state *bc) ...@@ -150,7 +151,7 @@ static inline void baycom_int_freq(struct baycom_state *bc)
* measure the interrupt frequency * measure the interrupt frequency
*/ */
bc->debug_vals.cur_intcnt++; bc->debug_vals.cur_intcnt++;
if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) {
bc->debug_vals.last_jiffies = cur_jiffies; bc->debug_vals.last_jiffies = cur_jiffies;
bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt;
bc->debug_vals.cur_intcnt = 0; bc->debug_vals.cur_intcnt = 0;
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/jiffies.h>
#include <net/ax25.h> #include <net/ax25.h>
...@@ -429,7 +430,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -429,7 +430,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
* May be we must check transmitter timeout here ? * May be we must check transmitter timeout here ?
* 14 Oct 1994 Dmitry Gorodchanin. * 14 Oct 1994 Dmitry Gorodchanin.
*/ */
if (jiffies - dev->trans_start < 20 * HZ) { if (time_before(jiffies, dev->trans_start + 20 * HZ)) {
/* 20 sec timeout not reached */ /* 20 sec timeout not reached */
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册