From: Marcelo Feitoza Parisi Subject: Re: [KJ] [PATCH] drivers/net/3c523.c : Use of time_after macro Use of the time_after() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi --- 3c523.c | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-) Index: quilt/drivers/net/3c523.c =================================================================== --- quilt.orig/drivers/net/3c523.c +++ quilt/drivers/net/3c523.c @@ -105,6 +105,7 @@ #include #include #include +#include #include #include @@ -619,7 +620,7 @@ out: static int init586(struct net_device *dev) { void *ptr; - unsigned long s; + unsigned long stop; int i, result = 0; struct priv *p = (struct priv *) dev->priv; volatile struct configure_cmd_struct *cfg_cmd; @@ -656,9 +657,9 @@ static int init586(struct net_device *de p->scb->cmd = CUC_START; /* cmd.-unit start */ elmc_id_attn586(); - s = jiffies; /* warning: only active with interrupts on !! */ + stop = jiffies + msecs_to_jiffies(300); /* warning: only active with interrupts on !! */ while (!(cfg_cmd->cmd_status & STAT_COMPL)) { - if (jiffies - s > 30*HZ/100) + if (time_after(jiffies, stop)) break; } @@ -682,9 +683,9 @@ static int init586(struct net_device *de p->scb->cmd = CUC_START; /* cmd.-unit start */ elmc_id_attn586(); - s = jiffies; + stop = jiffies + msecs_to_jiffies(300); while (!(ias_cmd->cmd_status & STAT_COMPL)) { - if (jiffies - s > 30*HZ/100) + if (time_after(jiffies, stop)) break; } @@ -707,9 +708,9 @@ static int init586(struct net_device *de p->scb->cmd = CUC_START; /* cmd.-unit start */ elmc_attn586(); - s = jiffies; + stop = jiffies + msecs_to_jiffies(300); while (!(tdr_cmd->cmd_status & STAT_COMPL)) { - if (jiffies - s > 30*HZ/100) { + if (time_after(jiffies, stop)) { printk(KERN_WARNING "%s: %d Problems while running the TDR.\n", dev->name, __LINE__); result = 1; break; @@ -796,9 +797,9 @@ static int init586(struct net_device *de p->scb->cbl_offset = make16(mc_cmd); p->scb->cmd = CUC_START; elmc_id_attn586(); - s = jiffies; + stop = jiffies + msecs_to_jiffies(300); while (!(mc_cmd->cmd_status & STAT_COMPL)) { - if (jiffies - s > 30*HZ/100) + if (time_after(jiffies, stop)) break; } if (!(mc_cmd->cmd_status & STAT_COMPL)) {