[PATCH 10/14] pxe: Refactor to avoid over-using bootm_argv
Simon Glass
sjg at chromium.org
Mon Dec 4 01:31:34 CET 2023
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 at chromium.org>
---
boot/pxe_utils.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 6fbccadd99e6..a6aee68bb797 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 &&
--
2.43.0.rc2.451.g8631bc7472-goog
More information about the U-Boot
mailing list