]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: Read bootfile from env on netboot_common()
authorJoe Hershberger <joe.hershberger@ni.com>
Wed, 4 Jul 2018 00:36:42 +0000 (19:36 -0500)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 26 Jul 2018 19:08:20 +0000 (14:08 -0500)
Instead of depending on a env callback for bootfile, read it explicitly.

We do this because the bootfile can be specified on the command line and
if it is, we will overwrite the internal variable. If a netboot_common()
is called again with no bootfile parameter, we want to use the one in
the environment.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
cmd/net.c
net/net.c

index eca6dd8918ec07c49111b6b278e3b7547359df63..89721b8f8be9aa4f26c3485558440e1311f9737f 100644 (file)
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -192,6 +192,9 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 
        switch (argc) {
        case 1:
+               /* refresh bootfile name from env */
+               copy_filename(net_boot_file_name, env_get("bootfile"),
+                             sizeof(net_boot_file_name));
                break;
 
        case 2: /*
@@ -203,6 +206,9 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
                addr = simple_strtoul(argv[1], &end, 16);
                if (end == (argv[1] + strlen(argv[1]))) {
                        load_addr = addr;
+                       /* refresh bootfile name from env */
+                       copy_filename(net_boot_file_name, env_get("bootfile"),
+                                     sizeof(net_boot_file_name));
                } else {
                        net_boot_file_name_explicit = true;
                        copy_filename(net_boot_file_name, argv[1],
index 333102ea79ee39bcd86cf2937e080a30efb4549d..1b6781d358f04fdc5d286f43776ae70023b737c5 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -216,26 +216,6 @@ int __maybe_unused net_busy_flag;
 
 /**********************************************************************/
 
-static int on_bootfile(const char *name, const char *value, enum env_op op,
-       int flags)
-{
-       if (flags & H_PROGRAMMATIC)
-               return 0;
-
-       switch (op) {
-       case env_op_create:
-       case env_op_overwrite:
-               copy_filename(net_boot_file_name, value,
-                             sizeof(net_boot_file_name));
-               break;
-       default:
-               break;
-       }
-
-       return 0;
-}
-U_BOOT_ENV_CALLBACK(bootfile, on_bootfile);
-
 static int on_ipaddr(const char *name, const char *value, enum env_op op,
        int flags)
 {