linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ne2k-pci jiffies cleanup
@ 2001-11-04  2:27 Andreas Dilger
  0 siblings, 0 replies; only message in thread
From: Andreas Dilger @ 2001-11-04  2:27 UTC (permalink / raw)
  To: torvalds, Alan Cox; +Cc: linux-kernel, becker, p_gortmaker

Some more cleanups of jiffies wrap problems, nothing unusual (includes a
couple of long line reformats, and moving jiffies calcs outside the loop).

Cheers, Andreas
===========================================================================
--- linux.orig/drivers/net/ne2k-pci.c	Thu Oct 25 02:02:09 2001
+++ linux/drivers/net/ne2k-pci.c	Sat Nov  3 19:08:50 2001
@@ -268,17 +268,18 @@
 
 	/* Reset card. Who knows what dain-bramaged state it was left in. */
 	{
-		unsigned long reset_start_time = jiffies;
+		unsigned long reset_end_time = jiffies + 2;
 
 		outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
 
-		/* This looks like a horrible timing loop, but it should never take
-		   more than a few cycles.
-		*/
+		/* This looks like a horrible timing loop, but it should never
+		 * take more than a few cycles.
+		 */
 		while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
-			/* Limit wait: '2' avoids jiffy roll-over. */
-			if (jiffies - reset_start_time > 2) {
-				printk(KERN_ERR PFX "Card failure (no reset ack).\n");
+			/* Limit wait */
+			if (time_after(jiffies, reset_end_time)) {
+				printk(KERN_ERR PFX
+				       "Card failure (no reset ack).\n");
 				goto err_out_free_netdev;
 			}
 
@@ -417,10 +418,10 @@
    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_end_time = jiffies + 2;
 
-	if (debug > 1) printk("%s: Resetting the 8390 t=%ld...",
-						  dev->name, jiffies);
+	if (debug > 1)
+		printk("%s: Resetting the 8390 t=%ld...", dev->name, jiffies);
 
 	outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
 
@@ -429,8 +430,9 @@
 
 	/* This check _should_not_ be necessary, omit eventually. */
 	while ((inb(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
-		if (jiffies - reset_start_time > 2) {
-			printk("%s: ne2k_pci_reset_8390() did not complete.\n", dev->name);
+		if (time_after(jiffies, reset_end_time)) {
+			printk("%s: ne2k_pci_reset_8390() did not complete.\n",
+			       dev->name);
 			break;
 		}
 	outb(ENISR_RESET, NE_BASE + EN0_ISR);	/* Ack intr. */
@@ -524,7 +526,7 @@
 				  const unsigned char *buf, const int start_page)
 {
 	long nic_base = NE_BASE;
-	unsigned long dma_start;
+	unsigned long dma_end;
 
 	/* On little-endian it's always safe to round the count up for
 	   word writes. */
@@ -575,11 +577,12 @@
 		}
 	}
 
-	dma_start = jiffies;
+	dma_end = jiffies + 2;
 
 	while ((inb(nic_base + EN0_ISR) & ENISR_RDC) == 0)
-		if (jiffies - dma_start > 2) {			/* Avoid clock roll-over. */
-			printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
+		if (time_after(jiffies, dma_end)) {
+			printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n",
+			       dev->name);
 			ne2k_pci_reset_8390(dev);
 			NS8390_init(dev,1);
 			break;
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-11-05 16:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-04  2:27 [PATCH] ne2k-pci jiffies cleanup Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).