public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Remy Bohmer <linux@bohmer.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Repair the 'netry=once' option.
Date: Wed, 28 Oct 2009 22:13:39 +0100	[thread overview]
Message-ID: <1256764421-27799-5-git-send-email-linux@bohmer.net> (raw)
In-Reply-To: <1256764421-27799-4-git-send-email-linux@bohmer.net>

'netretry = once' does the same as 'netretry = yes', because it is not stored
when it was tried once.

Signed-off-by: Remy Bohmer <linux@bohmer.net>
---
 net/net.c |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/net/net.c b/net/net.c
index cab4b2d..fd13cd9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -197,6 +197,8 @@ volatile uchar *NetTxPacket = 0;	/* THE transmit packet			*/
 
 static int net_check_prereq (proto_t protocol);
 
+static int NetTryCount;
+
 /**********************************************************************/
 
 IPaddr_t	NetArpWaitPacketIP;
@@ -320,6 +322,7 @@ NetLoop(proto_t protocol)
 	NetArpWaitReplyIP = 0;
 	NetArpWaitTxPacket = NULL;
 	NetTxPacket = NULL;
+	NetTryCount = 1;
 
 	if (!NetTxPacket) {
 		int	i;
@@ -558,17 +561,30 @@ startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
 void NetStartAgain (void)
 {
 	char *nretry;
-	int noretry = 0, once = 0;
+	int retry_forever = 0;
+	unsigned long retrycnt = 0;
+
+	nretry = getenv("netretry");
+	if (nretry) {
+		if (!strcmp(nretry, "yes"))
+			retry_forever = 1;
+		else if (!strcmp(nretry, "no"))
+			retrycnt = 0;
+		else if (!strcmp(nretry, "once"))
+			retrycnt = 1;
+		else
+			retrycnt = simple_strtoul(nretry, NULL, 0);
+	} else
+		retry_forever = 1;
 
-	if ((nretry = getenv ("netretry")) != NULL) {
-		noretry = (strcmp (nretry, "no") == 0);
-		once = (strcmp (nretry, "once") == 0);
-	}
-	if (noretry) {
-		eth_halt ();
+	if ((!retry_forever) && (NetTryCount >= retrycnt)) {
+		eth_halt();
 		NetState = NETLOOP_FAIL;
 		return;
 	}
+
+	NetTryCount++;
+
 #ifndef CONFIG_NET_MULTI
 	NetSetTimeout (10000UL, startAgainTimeout);
 	NetSetHandler (startAgainHandler);
@@ -580,7 +596,7 @@ void NetStartAgain (void)
 	eth_init (gd->bd);
 	if (NetRestartWrap) {
 		NetRestartWrap = 0;
-		if (NetDevExists && !once) {
+		if (NetDevExists) {
 			NetSetTimeout (10000UL, startAgainTimeout);
 			NetSetHandler (startAgainHandler);
 		} else {
-- 
1.6.0.4

  reply	other threads:[~2009-10-28 21:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-28 21:13 [U-Boot] [PATCH] Building of FIT images does not work Remy Bohmer
2009-10-28 21:13 ` [U-Boot] [PATCH] Fix mingw tools build Remy Bohmer
2009-10-28 21:13   ` [U-Boot] [PATCH] Add support for CS2 dataflash for Atmel-SPI Remy Bohmer
2009-10-28 21:13     ` [U-Boot] [PATCH] Make the generic unaligned access code safe for unaligned access Remy Bohmer
2009-10-28 21:13       ` Remy Bohmer [this message]
2009-10-28 21:13         ` [U-Boot] [PATCH] Add error codes/handling for TFTP-server Remy Bohmer
2009-10-28 21:13           ` [U-Boot] [PATCH] Repair build failure in case PPC is not defined and FIT is beng used Remy Bohmer
2009-10-29 10:53             ` Wolfgang Denk
2009-10-29 11:35               ` Remy Bohmer
2009-10-29 12:36                 ` Wolfgang Denk
2009-11-10  6:30           ` [U-Boot] [PATCH] Add error codes/handling for TFTP-server Ben Warren
2009-11-10  6:28         ` [U-Boot] [PATCH] Repair the 'netry=once' option Ben Warren
2009-11-23 22:48           ` Wolfgang Denk
2009-10-29  5:01       ` [U-Boot] [PATCH] Make the generic unaligned access code safe for unaligned access Stefan Roese
2009-10-29 11:24         ` Remy Bohmer
2009-10-29 14:30           ` Tom
2009-10-29 14:34             ` Remy Bohmer
2009-10-29 15:17               ` Tom
2009-10-29 15:34                 ` Remy Bohmer
2009-10-29 15:40                   ` Stefan Roese
2009-10-29 17:51                     ` Tom
2009-11-23 22:46       ` Wolfgang Denk
2009-11-24  4:05         ` Stefan Roese
2009-11-24 10:07           ` Remy Bohmer
2009-11-24 21:41           ` Wolfgang Denk
2009-11-23 22:44     ` [U-Boot] [PATCH] Add support for CS2 dataflash for Atmel-SPI Wolfgang Denk
2009-11-23 22:43   ` [U-Boot] [PATCH] Fix mingw tools build Wolfgang Denk
2009-11-23 22:43 ` [U-Boot] [PATCH] Building of FIT images does not work Wolfgang Denk

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=1256764421-27799-5-git-send-email-linux@bohmer.net \
    --to=linux@bohmer.net \
    --cc=u-boot@lists.denx.de \
    /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