
Remove the hard-coded bootfile handler and use a callback instead
Signed-off-by: Joe Hershberger joe.hershberger@ni.com --- common/cmd_nvedit.c | 13 ------------- include/env_callback.h | 2 +- net/net.c | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 9e8ea12..ac15a3c 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -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;
@@ -333,16 +330,6 @@ int _do_env_set(int flag, int argc, char * const argv[]) return 1; }
- /* - * Some variables should be updated when the corresponding - * entry in the environment is changed - */ -#if defined(CONFIG_CMD_NET) - if (strcmp(argv[1], "bootfile") == 0) { - copy_filename(BootFile, argv[2], sizeof(BootFile)); - return 0; - } -#endif return 0; }
diff --git a/include/env_callback.h b/include/env_callback.h index 31155e7..42c3d91 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -31,7 +31,7 @@ #endif
#define ENV_CALLBACK_LIST_STATIC ENV_CALLBACK_VAR ":callbacks," \ - "loadaddr:loadaddr," \ + "loadaddr:loadaddr,bootfile:bootfile," \ CONFIG_ENV_CALLBACK_LIST_STATIC
enum env_op { diff --git a/net/net.c b/net/net.c index e8ff066..7d7196f 100644 --- 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,21 @@ static int NetTryCount;
/**********************************************************************/
+static int on_bootfile(const char *name, const char *value, enum env_op op) +{ + 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.