Patchwork [U-Boot] smc911x: fix the timeout detection

login
register
mail settings
Submitter Masahiro Yamada
Date May 9, 2013, 7:42 a.m.
Message ID <1368085364-32488-1-git-send-email-yamada.m@jp.panasonic.com>
Download mbox | patch
Permalink /patch/242728/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Masahiro Yamada - May 9, 2013, 7:42 a.m.
If timeout is occurred at the while loop above,
the value of 'timeout' is -1, not 0.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---
 drivers/net/smc911x.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Tom Rini - May 15, 2013, 12:49 p.m.
On Wed, May 08, 2013 at 09:42:44PM -0000, Masahiro Yamada wrote:

> If timeout is occurred at the while loop above,
> the value of 'timeout' is -1, not 0.
> 
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>

Applied to u-boot/master, thanks!

Patch

diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index a290073..f63a069 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -484,7 +484,7 @@  static void smc911x_reset(struct eth_device *dev)
 		while (timeout-- &&
 			!(smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY))
 			udelay(10);
-		if (!timeout) {
+		if (timeout < 0) {
 			printf(DRIVERNAME
 				": timeout waiting for PM restore\n");
 			return;
@@ -500,7 +500,7 @@  static void smc911x_reset(struct eth_device *dev)
 	while (timeout-- && smc911x_reg_read(dev, E2P_CMD) & E2P_CMD_EPC_BUSY)
 		udelay(10);
 
-	if (!timeout) {
+	if (timeout < 0) {
 		printf(DRIVERNAME ": reset timeout\n");
 		return;
 	}