pxe: prepend fdtdir to DTB name irrespective of source

The directory name from an fdtdir directive in a PXE config file should
always be pre-pended to the DTB filename; it shouldn't matter whether
the DTB filename came from the $fdtfile environment variable, or whether
it was constructed dynamically from ${soc}-${board}.dtb. Fix the code to
always prepend the directory name.

Reported-by: Dennis Gilmore <dennis@ausil.us>
Fixes: c61d94d860 ("pxe: implement fdtdir extlinux.conf tag")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Dennis Gilmore <dennis@ausil.us>
Tested-by: Dennis Gilmore <dennis@ausil.us>
This commit is contained in:
Stephen Warren 2014-02-12 14:30:04 -07:00 committed by Tom Rini
parent 102c051fcc
commit e22361af07

View file

@ -700,23 +700,26 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
if (label->fdt) { if (label->fdt) {
fdtfile = label->fdt; fdtfile = label->fdt;
} else if (label->fdtdir) { } else if (label->fdtdir) {
fdtfile = getenv("fdtfile"); char *f1, *f2, *f3, *f4, *slash;
f1 = getenv("fdtfile");
if (f1) {
f2 = "";
f3 = "";
f4 = "";
} else {
/* /*
* For complex cases, it might be worth calling a * For complex cases where this code doesn't
* board- or SoC-provided function here to provide a * generate the correct filename, the board
* better default: * code should set $fdtfile during early boot,
* * or the boot scripts should set $fdtfile
* if (!fdtfile) * before invoking "pxe" or "sysboot".
* fdtfile = gen_fdtfile();
*
* If this is added, be sure to keep the default below,
* or move it to the default weak implementation of
* gen_fdtfile().
*/ */
if (!fdtfile) { f1 = getenv("soc");
char *soc = getenv("soc"); f2 = "-";
char *board = getenv("board"); f3 = getenv("board");
char *slash; f4 = ".dtb";
}
len = strlen(label->fdtdir); len = strlen(label->fdtdir);
if (!len) if (!len)
@ -727,18 +730,18 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
slash = ""; slash = "";
len = strlen(label->fdtdir) + strlen(slash) + len = strlen(label->fdtdir) + strlen(slash) +
strlen(soc) + 1 + strlen(board) + 5; strlen(f1) + strlen(f2) + strlen(f3) +
strlen(f4) + 1;
fdtfilefree = malloc(len); fdtfilefree = malloc(len);
if (!fdtfilefree) { if (!fdtfilefree) {
printf("malloc fail (FDT filename)\n"); printf("malloc fail (FDT filename)\n");
return 1; return 1;
} }
snprintf(fdtfilefree, len, "%s%s%s-%s.dtb", snprintf(fdtfilefree, len, "%s%s%s%s%s%s",
label->fdtdir, slash, soc, board); label->fdtdir, slash, f1, f2, f3, f4);
fdtfile = fdtfilefree; fdtfile = fdtfilefree;
} }
}
if (fdtfile) { if (fdtfile) {
int err = get_relfile_envaddr(cmdtp, fdtfile, "fdt_addr_r"); int err = get_relfile_envaddr(cmdtp, fdtfile, "fdt_addr_r");