All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [PATCH] time_after : drivers/net/apne.c
@ 2005-06-24 10:45 Christophe Lucas
  2005-06-24 13:23 ` Mark Hollomon
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Lucas @ 2005-06-24 10:45 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]

Description:
Replace if(jiffies - a>x) by if(time_after(jiffies,a+x))

Long description:
Some drivers do:
if ((jiffies - data->last_updated > HZ * 2) ||
    (jiffies < data->last_updated))

Should be:

#include <linux/jiffies.h>
if (time_after(jiffies, data->last_updated + HZ * 2))

Have a patch for drivers/i2c/chips/*.

Signed-off-by: Christophe Lucas <clucas@rotomalug.org>


				    
diff -urpN -X dontdiff 2.6.12-orig/drivers/net/apne.c 2.6.12/drivers/net/apne.c
--- 2.6.12-orig/drivers/net/apne.c	2005-06-17 21:48:29.000000000 +0200
+++ 2.6.12/drivers/net/apne.c	2005-06-24 12:27:56.447191048 +0200
@@ -36,6 +36,7 @@
 #include <linux/delay.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/jiffies.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -216,7 +217,7 @@ static int __init apne_probe1(struct net
 	outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
 
 	while ((inb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0)
-		if (jiffies - reset_start_time > 2*HZ/100) {
+		if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
 			printk(" not found (no reset ack).\n");
 			return -ENODEV;
 		}
@@ -382,7 +383,7 @@ apne_reset_8390(struct net_device *dev)
 
     /* This check _should_not_ be necessary, omit eventually. */
     while ((inb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0)
-	if (jiffies - reset_start_time > 2*HZ/100) {
+    	if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
 	    printk("%s: ne_reset_8390() did not complete.\n", dev->name);
 	    break;
 	}
@@ -530,7 +531,7 @@ apne_block_output(struct net_device *dev
     dma_start = jiffies;
 
     while ((inb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0)
-	if (jiffies - dma_start > 2*HZ/100) {		/* 20ms */
+    	if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
 		printk("%s: timeout waiting for Tx RDC.\n", dev->name);
 		apne_reset_8390(dev);
 		NS8390_init(dev,1);

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [KJ] [PATCH] time_after : drivers/net/apne.c
  2005-06-24 10:45 [KJ] [PATCH] time_after : drivers/net/apne.c Christophe Lucas
@ 2005-06-24 13:23 ` Mark Hollomon
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Hollomon @ 2005-06-24 13:23 UTC (permalink / raw)
  To: kernel-janitors

Christophe Lucas wrote:
>
> @@ -216,7 +217,7 @@ static int __init apne_probe1(struct net
>  	outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
>  
>  	while ((inb(ioaddr + NE_EN0_ISR) & ENISR_RESET) = 0)
> -		if (jiffies - reset_start_time > 2*HZ/100) {
> +		if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
>  			printk(" not found (no reset ack).\n");
>  			return -ENODEV;
>  		}

Wouldn't it be better to use msecs_to_jiffies(20) rather than explicit math on HZ?


-- 
Mark Hollomon
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-24 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-24 10:45 [KJ] [PATCH] time_after : drivers/net/apne.c Christophe Lucas
2005-06-24 13:23 ` Mark Hollomon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.