diff mbox series

[U-Boot,4/5] net: Read bootfile from env on netboot_common()

Message ID 20180704003643.10133-4-joe.hershberger@ni.com
State Accepted
Commit f43308fa0c7834d9707a2c212591275d1e095e50
Delegated to: Joe Hershberger
Headers show
Series [U-Boot,1/5] net: When checking prerequisites, consider boot_file_name | expand

Commit Message

Joe Hershberger July 4, 2018, 12:36 a.m. UTC
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 |  6 ++++++
 net/net.c | 20 --------------------
 2 files changed, 6 insertions(+), 20 deletions(-)

Comments

Joe Hershberger July 26, 2018, 7:17 p.m. UTC | #1
Hi Joe,

https://patchwork.ozlabs.org/patch/939044/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/cmd/net.c b/cmd/net.c
index eca6dd8918..89721b8f8b 100644
--- 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],
diff --git a/net/net.c b/net/net.c
index 333102ea79..1b6781d358 100644
--- 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)
 {