]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
env: Add a bootfile env handler
authorJoe Hershberger <joe.hershberger@ni.com>
Wed, 12 Dec 2012 04:16:26 +0000 (22:16 -0600)
committerTom Rini <trini@ti.com>
Thu, 13 Dec 2012 18:46:55 +0000 (11:46 -0700)
Remove the hard-coded bootfile handler and use a callback instead

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
common/cmd_nvedit.c
include/env_callback.h
net/net.c

index 1e51b9d069cb93573ade96270a891f4403862de5..874baef86529ddcb8aa795f4b1a8e57398534983 100644 (file)
@@ -50,9 +50,6 @@
 #include <serial.h>
 #include <linux/stddef.h>
 #include <asm/byteorder.h>
-#if defined(CONFIG_CMD_NET)
-#include <net.h>
-#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -328,12 +325,6 @@ int env_change_ok(const ENTRY *item, const char *newval, enum env_op op,
                load_addr = simple_strtoul(newval, NULL, 16);
                return 0;
        }
-#if defined(CONFIG_CMD_NET)
-       else if (strcmp(name, "bootfile") == 0) {
-               copy_filename(BootFile, newval, sizeof(BootFile));
-               return 0;
-       }
-#endif
        return 0;
 }
 
index 5a460f3532e68ed9ce243387e886358f45689ad9..bce01362cefba131a9327e1fb37e9fad578d7917 100644 (file)
@@ -39,6 +39,7 @@
  * a new association in the ".callbacks" environment variable.
  */
 #define ENV_CALLBACK_LIST_STATIC ENV_CALLBACK_VAR ":callbacks," \
+       "bootfile:bootfile," \
        CONFIG_ENV_CALLBACK_LIST_STATIC
 
 struct env_clbk_tbl {
index da68a61d63887f32b11e52274b4ab96aecc9a0ae..a40cde1e94e46367d727e30d40187b2630f60f15 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -82,6 +82,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <environment.h>
 #include <net.h>
 #if defined(CONFIG_STATUS_LED)
 #include <miiphy.h>
@@ -208,6 +209,22 @@ static int NetTryCount;
 
 /**********************************************************************/
 
+static int on_bootfile(const char *name, const char *value, enum env_op op,
+       int flags)
+{
+       switch (op) {
+       case env_op_create:
+       case env_op_overwrite:
+               copy_filename(BootFile, value, sizeof(BootFile));
+               break;
+       default:
+               break;
+       }
+
+       return 0;
+}
+U_BOOT_ENV_CALLBACK(bootfile, on_bootfile);
+
 /*
  * Check if autoload is enabled. If so, use either NFS or TFTP to download
  * the boot file.