]> git.sur5r.net Git - u-boot/blobdiff - net/net.c
x86: cherryhill: Fix DTC warning
[u-boot] / net / net.c
index 2268890ab54e7bd6ac0ef104212570f4b45b3402..b4563a4cab1fbfbccf595ee40a5e865514d79884 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *     Copied from Linux Monitor (LiMon) - Networking.
  *
@@ -6,7 +7,6 @@
  *     Copyright 2000 Roland Borde
  *     Copyright 2000 Paolo Scaffardi
  *     Copyright 2000-2002 Wolfgang Denk, wd@denx.de
- *     SPDX-License-Identifier:        GPL-2.0
  */
 
 /*
@@ -87,6 +87,7 @@
 #include <environment.h>
 #include <errno.h>
 #include <net.h>
+#include <net/fastboot.h>
 #include <net/tftp.h>
 #if defined(CONFIG_LED_STATUS)
 #include <miiphy.h>
 #include "sntp.h"
 #endif
 
-DECLARE_GLOBAL_DATA_PTR;
-
 /** BOOTP EXTENTIONS **/
 
 /* Our subnet mask (0=unknown) */
@@ -319,7 +318,7 @@ U_BOOT_ENV_CALLBACK(dnsip, on_dnsip);
 void net_auto_load(void)
 {
 #if defined(CONFIG_CMD_NFS)
-       const char *s = getenv("autoload");
+       const char *s = env_get("autoload");
 
        if (s != NULL && strcmp(s, "NFS") == 0) {
                /*
@@ -329,7 +328,7 @@ void net_auto_load(void)
                return;
        }
 #endif
-       if (getenv_yesno("autoload") == 0) {
+       if (env_get_yesno("autoload") == 0) {
                /*
                 * Just use BOOTP/RARP to configure system;
                 * Do not use TFTP to load the bootfile.
@@ -394,6 +393,7 @@ void net_init(void)
 int net_loop(enum proto_t protocol)
 {
        int ret = -EINVAL;
+       enum net_loop_state prev_net_state = net_state;
 
        net_restarted = 0;
        net_dev_exists = 0;
@@ -431,6 +431,7 @@ restart:
        case 1:
                /* network not configured */
                eth_halt();
+               net_set_state(prev_net_state);
                return -ENODEV;
 
        case 2:
@@ -453,6 +454,11 @@ restart:
                        tftp_start_server();
                        break;
 #endif
+#ifdef CONFIG_UDP_FUNCTION_FASTBOOT
+               case FASTBOOT:
+                       fastboot_start_server();
+                       break;
+#endif
 #if defined(CONFIG_CMD_DHCP)
                case DHCP:
                        bootp_reset();
@@ -616,8 +622,8 @@ restart:
                        if (net_boot_file_size > 0) {
                                printf("Bytes transferred = %d (%x hex)\n",
                                       net_boot_file_size, net_boot_file_size);
-                               setenv_hex("filesize", net_boot_file_size);
-                               setenv_hex("fileaddr", load_addr);
+                               env_set_hex("filesize", net_boot_file_size);
+                               env_set_hex("fileaddr", load_addr);
                        }
                        if (protocol != NETCONS)
                                eth_halt();
@@ -651,6 +657,7 @@ done:
        net_set_udp_handler(NULL);
        net_set_icmp_handler(NULL);
 #endif
+       net_set_state(prev_net_state);
        return ret;
 }
 
@@ -668,7 +675,7 @@ int net_start_again(void)
        unsigned long retrycnt = 0;
        int ret;
 
-       nretry = getenv("netretry");
+       nretry = env_get("netretry");
        if (nretry) {
                if (!strcmp(nretry, "yes"))
                        retry_forever = 1;
@@ -683,7 +690,7 @@ int net_start_again(void)
                retry_forever = 0;
        }
 
-       if ((!retry_forever) && (net_try_count >= retrycnt)) {
+       if ((!retry_forever) && (net_try_count > retrycnt)) {
                eth_halt();
                net_set_state(NETLOOP_FAIL);
                /*
@@ -1324,6 +1331,7 @@ common:
                /* Fall through */
 
        case NETCONS:
+       case FASTBOOT:
        case TFTPSRV:
                if (net_ip.s_addr == 0) {
                        puts("*** ERROR: `ipaddr' not set\n");
@@ -1536,7 +1544,7 @@ ushort string_to_vlan(const char *s)
        return htons(id);
 }
 
-ushort getenv_vlan(char *var)
+ushort env_get_vlan(char *var)
 {
-       return string_to_vlan(getenv(var));
+       return string_to_vlan(env_get(var));
 }