]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Repair the 'netretry=once' option.
authorRemy Bohmer <linux@bohmer.net>
Wed, 28 Oct 2009 21:13:39 +0000 (22:13 +0100)
committerBen Warren <biggerbadderben@gmail.com>
Tue, 24 Nov 2009 22:04:11 +0000 (14:04 -0800)
'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>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
net/net.c

index cab4b2dd885cde6b952a6ba8737e2f1913ca073f..fd13cd93f444394650c0a1953e2f33b5f6d2f405 100644 (file)
--- 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 {