All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Feitoza Parisi <marcelo@feitoza.com.br>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] [PATCH] drivers/net/cs89x0.c : Use of time_after(),
Date: Sat, 16 Jul 2005 07:05:58 +0000	[thread overview]
Message-ID: <42D8B1D6.2090302@feitoza.com.br> (raw)

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



[-- Attachment #2: cs89x0.patch --]
[-- Type: text/x-patch, Size: 4134 bytes --]

Use of time_after(), time_after_eq() and time_before() macros, define at
linux/jiffies.h, which deal with wrapping correctly and are nicer to read.

Signed-off-by: Marcelo Feitoza Parisi <marcelo@feitoza.com.br>

--- linux/drivers/net/cs89x0.c	2005-07-13 17:52:18.000000000 -0300
+++ linux-kj/drivers/net/cs89x0.c	2005-07-15 21:55:17.376267208 -0300
@@ -93,6 +93,7 @@
    or override something. */
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/jiffies.h>
 
 /*
  * Set this to zero to disable DMA code
@@ -363,12 +364,12 @@
 static int __init
 wait_eeprom_ready(struct net_device *dev)
 {
-	int timeout = jiffies;
+	unsigned long timeout = jiffies;
 	/* check to see if the EEPROM is ready, a timeout is used -
 	   just in case EEPROM is ready when SI_BUSY in the
 	   PP_SelfST is clear */
 	while(readreg(dev, PP_SelfST) & SI_BUSY)
-		if (jiffies - timeout >= 40)
+		if (time_after_eq(jiffies, timeout + 40))
 			return -1;
 	return 0;
 }
@@ -936,7 +937,7 @@
 	struct net_local *lp = netdev_priv(dev);
 	int ioaddr = dev->base_addr;
 #endif
-	int reset_start_time;
+	unsigned long reset_start_time;
 
 	writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
 
@@ -958,7 +959,8 @@
 
 	/* Wait until the chip is reset */
 	reset_start_time = jiffies;
-	while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2)
+	while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 &&
+		       time_before(jiffies, reset_start_time + 2))
 		;
 }
 
@@ -968,7 +970,7 @@
 {
 	struct net_local *lp = netdev_priv(dev);
 	unsigned int selfcontrol;
-	int timenow = jiffies;
+	unsigned long timenow = jiffies;
 	/* control the DC to DC convertor in the SelfControl register.  
 	   Note: This is hooked up to a general purpose pin, might not
 	   always be a DC to DC convertor. */
@@ -981,7 +983,7 @@
 	writereg(dev, PP_SelfCTL, selfcontrol);
 
 	/* Wait for the DC/DC converter to power up - 500ms */
-	while (jiffies - timenow < HZ)
+	while (time_before(jiffies, timenow + HZ))
 		;
 }
 
@@ -995,7 +997,7 @@
 detect_tp(struct net_device *dev)
 {
 	struct net_local *lp = netdev_priv(dev);
-	int timenow = jiffies;
+	unsigned long timenow = jiffies;
 	int fdx;
 
 	if (net_debug > 1) printk("%s: Attempting TP\n", dev->name);
@@ -1009,7 +1011,7 @@
 	control_dc_dc(dev, 0);
 
         /* Delay for the hardware to work out if the TP cable is present - 150ms */
-	for (timenow = jiffies; jiffies - timenow < 15; )
+	for (timenow = jiffies; time_before(jiffies, timenow + 15); )
                 ;
 	if ((readreg(dev, PP_LineST) & LINK_OK) == 0)
 		return DETECTED_NONE;
@@ -1051,7 +1053,7 @@
 		if ((lp->auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) {
 			printk(KERN_INFO "%s: negotiating duplex...\n",dev->name);
 			while (readreg(dev, PP_AutoNegST) & AUTO_NEG_BUSY) {
-				if (jiffies - timenow > 4000) {
+				if (time_after(jiffies, timenow + 4000)) {
 					printk(KERN_ERR "**** Full / half duplex auto-negotiation timed out ****\n");
 					break;
 				}
@@ -1073,7 +1075,7 @@
 				 0, 46, /* A 46 in network order */
 				 0, 0, /* DSAP=0 & SSAP=0 fields */
 				 0xf3, 0 /* Control (Test Req + P bit set) */ };
-	long timenow = jiffies;
+	unsigned long timenow = jiffies;
 
 	writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_TX_ON);
 
@@ -1084,10 +1086,10 @@
         writeword(dev, TX_LEN_PORT, ETH_ZLEN);
 
 	/* Test to see if the chip has allocated memory for the packet */
-	while (jiffies - timenow < 5)
+	while (time_before(jiffies, timenow + 5))
 		if (readreg(dev, PP_BusST) & READY_FOR_TX_NOW)
 			break;
-	if (jiffies - timenow >= 5)
+	if (time_after_eq(jiffies, timenow + 5))
 		return 0;	/* this shouldn't happen */
 
 	/* Write the contents of the packet */
@@ -1095,7 +1097,7 @@
 
 	if (net_debug > 1) printk("Sending test packet ");
 	/* wait a couple of jiffies for packet to be received */
-	for (timenow = jiffies; jiffies - timenow < 3; )
+	for (timenow = jiffies; time_before(jiffies, timenow + 3); )
                 ;
         if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
                 if (net_debug > 1) printk("succeeded\n");

[-- Attachment #3: Type: text/plain, Size: 168 bytes --]

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

             reply	other threads:[~2005-07-16  7:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-16  7:05 Marcelo Feitoza Parisi [this message]
2005-07-18 14:05 ` [KJ] [PATCH] drivers/net/cs89x0.c : Use of time_after(), Domen Puncer

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=42D8B1D6.2090302@feitoza.com.br \
    --to=marcelo@feitoza.com.br \
    --cc=kernel-janitors@vger.kernel.org \
    /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 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.