pxe: Move do_getfile() into the context
Rather than having a global variable, pass the function as part of the
context.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff --git a/cmd/pxe.c b/cmd/pxe.c
index 17ce54f..70dbde3 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -24,7 +24,7 @@
NULL
};
-static int do_get_tftp(struct cmd_tbl *cmdtp, const char *file_path,
+static int do_get_tftp(struct pxe_context *ctx, const char *file_path,
char *file_addr)
{
char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
@@ -32,7 +32,7 @@
tftp_argv[1] = file_addr;
tftp_argv[2] = (void *)file_path;
- if (do_tftpb(cmdtp, 0, 3, tftp_argv))
+ if (do_tftpb(ctx->cmdtp, 0, 3, tftp_argv))
return -ENOENT;
return 1;
@@ -121,8 +121,7 @@
struct pxe_context ctx;
int err, i = 0;
- pxe_setup_ctx(&ctx, cmdtp);
- do_getfile = do_get_tftp;
+ pxe_setup_ctx(&ctx, cmdtp, do_get_tftp);
if (argc != 1)
return CMD_RET_USAGE;
@@ -176,8 +175,7 @@
char *pxefile_addr_str;
struct pxe_context ctx;
- pxe_setup_ctx(&ctx, cmdtp);
- do_getfile = do_get_tftp;
+ pxe_setup_ctx(&ctx, cmdtp, do_get_tftp);
if (argc == 1) {
pxefile_addr_str = from_env("pxefile_addr_r");