diff options
author | Trent Piepho <tpiepho@freescale.com> | 2008-09-22 13:03:56 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-09-24 20:48:56 -0400 |
commit | baac03d9bb7b8aa3c33a2dbf5f459ea6ce8abaf4 (patch) | |
tree | 018e47dc43acfff4a63d3974c981340ba729cac2 /drivers/net/gianfar_mii.c | |
parent | 2e2e8d53c3f34684af7a7475098b7524a6b854c2 (diff) |
gianfar: Fix error in mdio reset timeout
The loop with the timeout used "while (... && timeout--)", which means
than when the timeout occurs, "timeout" will be -1 after the loop has
exited. The code that checks if the looped exited because of a timeout
used "if (timeout <= 0)". Seems ok, except timeout is unsigned, and
(unsigned)-1 isn't less than zero!
Using "--timeout" in the loop fixes this problem, as now "timeout" will be
0 when the loop times out.
This also fixes a bug in the existing code, where it will erroneously think
a timeout occurred if the condition the loop was waiting for is satisfied
on the final iteration before a timeout.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/gianfar_mii.c')
-rw-r--r-- | drivers/net/gianfar_mii.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c index ebcfb27a904e..906aba2757e7 100644 --- a/drivers/net/gianfar_mii.c +++ b/drivers/net/gianfar_mii.c | |||
@@ -136,12 +136,12 @@ static int gfar_mdio_reset(struct mii_bus *bus) | |||
136 | 136 | ||
137 | /* Wait until the bus is free */ | 137 | /* Wait until the bus is free */ |
138 | while ((gfar_read(®s->miimind) & MIIMIND_BUSY) && | 138 | while ((gfar_read(®s->miimind) & MIIMIND_BUSY) && |
139 | timeout--) | 139 | --timeout) |
140 | cpu_relax(); | 140 | cpu_relax(); |
141 | 141 | ||
142 | mutex_unlock(&bus->mdio_lock); | 142 | mutex_unlock(&bus->mdio_lock); |
143 | 143 | ||
144 | if(timeout <= 0) { | 144 | if(timeout == 0) { |
145 | printk(KERN_ERR "%s: The MII Bus is stuck!\n", | 145 | printk(KERN_ERR "%s: The MII Bus is stuck!\n", |
146 | bus->name); | 146 | bus->name); |
147 | return -EBUSY; | 147 | return -EBUSY; |