image: Track when ramdisk processing is completed

The current switch default is tricky since it relies on #ifdefs to work.
Use a bool instead.

Also fix the comment on @select, since it has a dual purpose.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2022-08-28 12:32:47 -06:00 committed by Tom Rini
parent 1ce8e10f3b
commit 4f2d94129d

View File

@ -314,7 +314,7 @@ int genimg_has_config(bootm_headers_t *images)
* select_ramdisk() - Select and locate the ramdisk to use * select_ramdisk() - Select and locate the ramdisk to use
* *
* @images: pointer to the bootm images structure * @images: pointer to the bootm images structure
* @select: name of ramdisk to select, or NULL for any * @select: name of ramdisk to select, or hex address, NULL for any
* @arch: expected ramdisk architecture * @arch: expected ramdisk architecture
* @rd_datap: pointer to a ulong variable, will hold ramdisk pointer * @rd_datap: pointer to a ulong variable, will hold ramdisk pointer
* @rd_lenp: pointer to a ulong variable, will hold ramdisk length * @rd_lenp: pointer to a ulong variable, will hold ramdisk length
@ -324,6 +324,7 @@ int genimg_has_config(bootm_headers_t *images)
static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch, static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
ulong *rd_datap, ulong *rd_lenp) ulong *rd_datap, ulong *rd_lenp)
{ {
bool done = false;
ulong rd_addr; ulong rd_addr;
char *buf; char *buf;
@ -401,6 +402,7 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
*rd_datap = image_get_data(rd_hdr); *rd_datap = image_get_data(rd_hdr);
*rd_lenp = image_get_data_size(rd_hdr); *rd_lenp = image_get_data_size(rd_hdr);
done = true;
break; break;
} }
#endif #endif
@ -419,6 +421,7 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
images->fit_hdr_rd = map_sysmem(rd_addr, 0); images->fit_hdr_rd = map_sysmem(rd_addr, 0);
images->fit_uname_rd = fit_uname_ramdisk; images->fit_uname_rd = fit_uname_ramdisk;
images->fit_noffset_rd = rd_noffset; images->fit_noffset_rd = rd_noffset;
done = true;
break; break;
#endif #endif
case IMAGE_FORMAT_ANDROID: case IMAGE_FORMAT_ANDROID:
@ -431,10 +434,12 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
unmap_sysmem(ptr); unmap_sysmem(ptr);
if (ret) if (ret)
return ret; return ret;
done = true;
}
break; break;
} }
fallthrough;
default: if (!done) {
if (IS_ENABLED(CONFIG_SUPPORT_RAW_INITRD)) { if (IS_ENABLED(CONFIG_SUPPORT_RAW_INITRD)) {
char *end = NULL; char *end = NULL;
@ -443,12 +448,15 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
if (end) { if (end) {
*rd_lenp = hextoul(++end, NULL); *rd_lenp = hextoul(++end, NULL);
*rd_datap = rd_addr; *rd_datap = rd_addr;
break; done = true;
} }
} }
if (!done) {
puts("Wrong Ramdisk Image Format\n"); puts("Wrong Ramdisk Image Format\n");
return -EINVAL; return -EINVAL;
} }
}
return 0; return 0;
} }