linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@turbolabs.com>
To: torvalds@transmeta.com, Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, becker@scyld.com, p_gortmaker@yahoo.com
Subject: [PATCH] ne2k-pci jiffies cleanup
Date: Sat, 3 Nov 2001 19:27:42 -0700	[thread overview]
Message-ID: <20011103192741.G12523@lynx.no> (raw)

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/


                 reply	other threads:[~2001-11-05 16:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011103192741.G12523@lynx.no \
    --to=adilger@turbolabs.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=becker@scyld.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p_gortmaker@yahoo.com \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).