diff options
author | Simon Glass | 2023-12-14 21:19:10 -0700 |
---|---|---|
committer | Tom Rini | 2024-04-10 17:04:25 -0600 |
commit | 03a4a6d5bc9823576571bba5826d85f3b3c3a523 (patch) | |
tree | 89330879ef961506a112ff73853890fa430a4710 /boot | |
parent | 39ee4a14a940bc5ffa2168dd729eb7018dbe19cd (diff) |
pxe: Refactor to avoid over-using bootm_argv
The bootm_argv[3] expression is used in many places. It is the FDT
address, so use that name throughout.
Assign it to bootm_argv[3] only at the end, when all the conditions are
resolved.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot')
-rw-r--r-- | boot/pxe_utils.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 6fbccadd99e..a6aee68bb79 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -506,18 +506,19 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, { char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; char *zboot_argv[] = { "zboot", NULL, "0", NULL, NULL }; + const char *fdt_addr; ulong kernel_addr_r; int bootm_argc = 2; int zboot_argc = 3; void *buf; - bootm_argv[3] = env_get("fdt_addr_r"); + fdt_addr = env_get("fdt_addr_r"); /* For FIT, the label can be identical to kernel one */ if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { - bootm_argv[3] = kernel_addr; + fdt_addr = kernel_addr; /* if fdt label is defined then get fdt from server */ - } else if (bootm_argv[3]) { + } else if (fdt_addr) { char *fdtfile = NULL; char *fdtfilefree = NULL; @@ -582,7 +583,7 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, free(fdtfilefree); if (err < 0) { - bootm_argv[3] = NULL; + fdt_addr = NULL; if (label->fdt) { printf("Skipping %s for failure retrieving FDT\n", @@ -599,7 +600,7 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, label_boot_fdtoverlay(ctx, label); #endif } else { - bootm_argv[3] = NULL; + fdt_addr = NULL; } } @@ -615,20 +616,21 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, zboot_argc = 5; } - if (!bootm_argv[3]) - bootm_argv[3] = env_get("fdt_addr"); + if (!fdt_addr) + fdt_addr = env_get("fdt_addr"); kernel_addr_r = genimg_get_kernel_addr(kernel_addr); buf = map_sysmem(kernel_addr_r, 0); - if (!bootm_argv[3] && genimg_get_format(buf) != IMAGE_FORMAT_FIT) - bootm_argv[3] = env_get("fdtcontroladdr"); + if (!fdt_addr && genimg_get_format(buf) != IMAGE_FORMAT_FIT) + fdt_addr = env_get("fdtcontroladdr"); - if (bootm_argv[3]) { + if (fdt_addr) { if (!bootm_argv[2]) bootm_argv[2] = "-"; bootm_argc = 4; } + bootm_argv[3] = (char *)fdt_addr; /* Try bootm for legacy and FIT format image */ if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID && |