* [KJ] [PATCH] drivers/net/cs89x0.c : Use of time_after(),
@ 2005-07-16 7:05 Marcelo Feitoza Parisi
2005-07-18 14:05 ` Domen Puncer
0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Feitoza Parisi @ 2005-07-16 7:05 UTC (permalink / raw)
To: kernel-janitors
[-- 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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [KJ] [PATCH] drivers/net/cs89x0.c : Use of time_after(),
2005-07-16 7:05 [KJ] [PATCH] drivers/net/cs89x0.c : Use of time_after(), Marcelo Feitoza Parisi
@ 2005-07-18 14:05 ` Domen Puncer
0 siblings, 0 replies; 2+ messages in thread
From: Domen Puncer @ 2005-07-18 14:05 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1563 bytes --]
On 16/07/05 04:05 -0300, Marcelo Feitoza Parisi wrote:
>
> 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))
linux.bkbits.net tells me:
2002/02/05 torvalds | if (jiffies - timeout >= 40)
And since this is a i386 driver (cs89x0.txt), HZ was 100 back then.
So... change this to msecs_to_jiffies(400) to make it right?
Same goes for the rest of patch.
> @@ -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 &&
while ((...
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-07-18 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-16 7:05 [KJ] [PATCH] drivers/net/cs89x0.c : Use of time_after(), Marcelo Feitoza Parisi
2005-07-18 14:05 ` Domen Puncer
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.