Skip to content

Commit

Permalink
net: Read bootfile from env on netboot_common()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jhershbe committed Jul 26, 2018
1 parent 16cf145 commit f43308f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
6 changes: 6 additions & 0 deletions cmd/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: /*
Expand All @@ -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],
Expand Down
20 changes: 0 additions & 20 deletions net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit f43308f

Please sign in to comment.