Skip to contentSkip to conversation

drivers/net/ne2k-pci.c : Use of time_after() macro

PATCH In review Marcelo Feitoza Parisi 3 participants 4 messages Apr 14, 2005 – Jul 18, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/net/ne2k-pci.c : Use of time_after() macro

Added the use of time_after() macro, that is defined at linux/jiffies.h

--- linux/drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300
+++ development/drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000
-0300
@@ -53,6 +53,7 @@
#include <linux/ethtool.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/jiffies.h>

#include <asm/system.h>
#include <asm/io.h>
@@ -271,7 +272,7 @@

     /* Reset card. Who knows what dain-bramaged state it was left in. */
     {

- unsigned long reset_start_time = jiffies;
+ unsigned long reset_start_time = jiffies + 2;

         outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);

@@ -280,7 +281,7 @@

         */
         while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) = 0)
             /* Limit wait: '2' avoids jiffy roll-over. */
-            if (jiffies - reset_start_time > 2) {
+            if (time_after(jiffies, reset_start_time)) {
                 printk(KERN_ERR PFX "Card failure (no reset ack).\n");
                 goto err_out_free_netdev;
             }

@@ -441,7 +442,7 @@
8390 reset command required, but that shouldn't be necessary. */
static void ne2k_pci_reset_8390(struct net_device *dev) {
- unsigned long reset_start_time = jiffies;
+ unsigned long reset_start_time = jiffies + 2;

     if (debug > 1) printk("%s: Resetting the 8390 t=%ld...",
                           dev->name, jiffies);

@@ -453,7 +454,7 @@

     /* This check _should_not_ be necessary, omit eventually. */
     while ((inb(NE_BASE+EN0_ISR) & ENISR_RESET) = 0)
-        if (jiffies - reset_start_time > 2) {
+        if (time_after(jiffies, reset_start_time)) {
             printk("%s: ne2k_pci_reset_8390() did not complete.\n", 
dev->name);
             break;
         }
@@ -607,10 +608,10 @@
         }
     }

- dma_start = jiffies;
+ dma_start = jiffies + 2;

     while ((inb(nic_base + EN0_ISR) & ENISR_RDC) = 0)

- if (jiffies - dma_start > 2) { /* Avoid clock
roll-over. */
+ if (time_after(jiffies, dma_start)) { /* Avoid clock
roll-over. */
printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n",

dev->name);
             ne2k_pci_reset_8390(dev);
             NS8390_init(dev,1);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 16 lines · Marcelo Feitoza Parisi

Added the use of time_after() macro, that is defined at linux/jiffies.h

drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 renamed from drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300 +1 -1
-0300
@@ -53,6 +53,7 @@
 #include <linux/ethtool.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/jiffies.h>
 
 #include <asm/system.h>
 #include <asm/io.h>

drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 line 275

Quoted 5 lines
drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 renamed from drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300 +1 -1
@@ -271,7 +272,7 @@
 
    /* Reset card. Who knows what dain-bramaged state it was left in. */
    {
-        unsigned long reset_start_time = jiffies;
+        unsigned long reset_start_time = jiffies + 2;

A nit pick, but if you add 2 to jiffies, it is no longer the reset start time. Maybe rename the variable reset_timeout or something.

Quoted 13 lines
drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 renamed from drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300 +1 -1
        outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
 
@@ -280,7 +281,7 @@
        */
        while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) = 0)
            /* Limit wait: '2' avoids jiffy roll-over. */
-            if (jiffies - reset_start_time > 2) {
+            if (time_after(jiffies, reset_start_time)) {
                printk(KERN_ERR PFX "Card failure (no reset ack).\n");
                goto err_out_free_netdev;
            }

drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 line 445

Quoted 5 lines
drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 renamed from drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300 +1 -1
@@ -441,7 +442,7 @@
   8390 reset command required, but that shouldn't be necessary. */
 static void ne2k_pci_reset_8390(struct net_device *dev)
 {
-    unsigned long reset_start_time = jiffies;
+    unsigned long reset_start_time = jiffies + 2;

ditto

Quoted 14 lines
drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 renamed from drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300 +1 -1
    if (debug > 1) printk("%s: Resetting the 8390 t=%ld...",
                          dev->name, jiffies);
@@ -453,7 +454,7 @@
 
    /* This check _should_not_ be necessary, omit eventually. */
    while ((inb(NE_BASE+EN0_ISR) & ENISR_RESET) = 0)
-        if (jiffies - reset_start_time > 2) {
+        if (time_after(jiffies, reset_start_time)) {
            printk("%s: ne2k_pci_reset_8390() did not complete.\n", 
 dev->name);
            break;
        }

drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 line 611

Quoted 5 lines
drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 renamed from drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300 +1 -1
@@ -607,10 +608,10 @@
        }
    }
 
-    dma_start = jiffies;
+    dma_start = jiffies + 2;

ditto

Quoted 16 lines
drivers/net/ne2k-pci.c 2005-04-14 20:00:28.000000000 renamed from drivers/net/ne2k-pci.c 2005-04-07 22:25:51.000000000 -0300 +0 -1
    while ((inb(nic_base + EN0_ISR) & ENISR_RDC) = 0)
-        if (jiffies - dma_start > 2) {            /* Avoid clock 

roll-over. */
+ if (time_after(jiffies, dma_start)) { /* Avoid clock
roll-over. */
printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n",

dev->name);
            ne2k_pci_reset_8390(dev);
            NS8390_init(dev,1);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

Signature · 5 lines
Mark Hollomon
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
#2 lore raw

PATCH 1/1 drivers/net/ne2k-pci.c : Use of the time_after() macro

In reply to Marcelo Feitoza Parisi

Use of the time_after() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read.

drivers/net/ne2k-pci.c +3 -3
@@ -280,7 +280,7 @@
 		*/
 		while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
 			/* Limit wait: '2' avoids jiffy roll-over. */
-			if (jiffies - reset_start_time > 2) {
+			if (time_after(jiffies, reset_start_time + 2)) {
 				printk(KERN_ERR PFX "Card failure (no reset ack).\n");
 				goto err_out_free_netdev;
 			}
@@ -453,7 +453,7 @@
 
 	/* This check _should_not_ be necessary, omit eventually. */
 	while ((inb(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
-		if (jiffies - reset_start_time > 2) {
+		if (time_after(jiffies, reset_start_time + 2)) {
 			printk("%s: ne2k_pci_reset_8390() did not complete.\n", dev->name);
 			break;
 		}
@@ -610,7 +610,7 @@
 	dma_start = jiffies;
 
 	while ((inb(nic_base + EN0_ISR) & ENISR_RDC) == 0)
-		if (jiffies - dma_start > 2) {			/* Avoid clock roll-over. */
+		if (time_after(jiffies, dma_start + 2)) {	/* Avoid clock roll-over. */
 			printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
 			ne2k_pci_reset_8390(dev);
 			NS8390_init(dev,1);

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw

Re: [KJ] [PATCH] drivers/net/ne2k-pci.c : Use of the time_after()

In reply to Marcelo Feitoza Parisi

drivers/net/ne2k-pci.c line 282

Quoted 11 lines · Marcelo Feitoza Parisi

Use of the time_after() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read.

drivers/net/ne2k-pci.c +0 -0
@@ -280,7 +280,7 @@
 		*/
 		while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
 			/* Limit wait: '2' avoids jiffy roll-over. */

We can get rid of the comment.

drivers/net/ne2k-pci.c line 284

Quoted 3 lines
drivers/net/ne2k-pci.c +1 -1
-			if (jiffies - reset_start_time > 2) {
 
+			if (time_after(jiffies, reset_start_time + 2)) {

And use just "> 1", as it still guarantees 1 jiffie.

drivers/net/ne2k-pci.c

Quoted 3 lines
drivers/net/ne2k-pci.c +2 -0
+		if (time_after(jiffies, reset_start_time + 2)) {
 
+		if (time_after(jiffies, dma_start + 2)) {	/* Avoid clock roll-over. */

Also, HZ and/or whitespace issues with:
drivers/net/eexpress.c
drivers/net/eth16i.c
drivers/atm/iphase.c

OK, whitespace I can fix quickly, but for HZ figure out what is intended, and resend with that in description. Thanks.

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors