Commit d52e8575d9a4244992cd69e717affc97ea6e9b36
Committed by
Tom Rini
1 parent
84a07dbfd8
Exists in
v2017.01-smarct4x
and in
34 other branches
Combine bootm_find_<thing> functions together
bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability. The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables(). I didn't see any other callers entering a bootm_find<thing>, so removing the wrapper, and condensing these together hopefully makes the code a little simpler. Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 3 changed files with 21 additions and 38 deletions Side-by-side Diff
common/bootm.c
... | ... | @@ -206,7 +206,23 @@ |
206 | 206 | return 0; |
207 | 207 | } |
208 | 208 | |
209 | -static int bootm_find_ramdisk(int flag, int argc, char * const argv[]) | |
209 | +/** | |
210 | + * bootm_find_images - wrapper to find and locate various images | |
211 | + * @flag: Ignored Argument | |
212 | + * @argc: command argument count | |
213 | + * @argv: command argument list | |
214 | + * | |
215 | + * boot_find_images() will attempt to load an available ramdisk, | |
216 | + * flattened device tree, as well as specifically marked | |
217 | + * "loadable" images (loadables are FIT only) | |
218 | + * | |
219 | + * Note: bootm_find_images will skip an image if it is not found | |
220 | + * | |
221 | + * @return: | |
222 | + * 0, if all existing images were loaded correctly | |
223 | + * 1, if an image is found but corrupted, or invalid | |
224 | + */ | |
225 | +int bootm_find_images(int flag, int argc, char * const argv[]) | |
210 | 226 | { |
211 | 227 | int ret; |
212 | 228 | |
213 | 229 | |
... | ... | @@ -218,14 +234,7 @@ |
218 | 234 | return 1; |
219 | 235 | } |
220 | 236 | |
221 | - return 0; | |
222 | -} | |
223 | - | |
224 | 237 | #if defined(CONFIG_OF_LIBFDT) |
225 | -static int bootm_find_fdt(int flag, int argc, char * const argv[]) | |
226 | -{ | |
227 | - int ret; | |
228 | - | |
229 | 238 | /* find flattened device tree */ |
230 | 239 | ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images, |
231 | 240 | &images.ft_addr, &images.ft_len); |
232 | 241 | |
233 | 242 | |
... | ... | @@ -233,18 +242,10 @@ |
233 | 242 | puts("Could not find a valid device tree\n"); |
234 | 243 | return 1; |
235 | 244 | } |
236 | - | |
237 | 245 | set_working_fdt_addr((ulong)images.ft_addr); |
238 | - | |
239 | - return 0; | |
240 | -} | |
241 | 246 | #endif |
242 | 247 | |
243 | 248 | #if defined(CONFIG_FIT) |
244 | -static int bootm_find_loadables(int flag, int argc, char * const argv[]) | |
245 | -{ | |
246 | - int ret; | |
247 | - | |
248 | 249 | /* find all of the loadables */ |
249 | 250 | ret = boot_get_loadable(argc, argv, &images, IH_ARCH_DEFAULT, |
250 | 251 | NULL, NULL); |
251 | 252 | |
... | ... | @@ -252,26 +253,8 @@ |
252 | 253 | printf("Loadable(s) is corrupt or invalid\n"); |
253 | 254 | return 1; |
254 | 255 | } |
255 | - | |
256 | - return 0; | |
257 | -} | |
258 | 256 | #endif |
259 | 257 | |
260 | -int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]) | |
261 | -{ | |
262 | - if (bootm_find_ramdisk(flag, argc, argv)) | |
263 | - return 1; | |
264 | - | |
265 | -#if defined(CONFIG_OF_LIBFDT) | |
266 | - if (bootm_find_fdt(flag, argc, argv)) | |
267 | - return 1; | |
268 | -#endif | |
269 | - | |
270 | -#if defined(CONFIG_FIT) | |
271 | - if (bootm_find_loadables(flag, argc, argv)) | |
272 | - return 1; | |
273 | -#endif | |
274 | - | |
275 | 258 | return 0; |
276 | 259 | } |
277 | 260 | |
... | ... | @@ -283,7 +266,7 @@ |
283 | 266 | (images.os.type == IH_TYPE_MULTI)) && |
284 | 267 | (images.os.os == IH_OS_LINUX || |
285 | 268 | images.os.os == IH_OS_VXWORKS)) |
286 | - return bootm_find_ramdisk_fdt(flag, argc, argv); | |
269 | + return bootm_find_images(flag, argc, argv); | |
287 | 270 | |
288 | 271 | return 0; |
289 | 272 | } |
common/cmd_bootm.c
... | ... | @@ -580,7 +580,7 @@ |
580 | 580 | * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not |
581 | 581 | * have a header that provide this informaiton. |
582 | 582 | */ |
583 | - if (bootm_find_ramdisk_fdt(flag, argc, argv)) | |
583 | + if (bootm_find_images(flag, argc, argv)) | |
584 | 584 | return 1; |
585 | 585 | |
586 | 586 | return 0; |
... | ... | @@ -721,7 +721,7 @@ |
721 | 721 | * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not |
722 | 722 | * have a header that provide this informaiton. |
723 | 723 | */ |
724 | - if (bootm_find_ramdisk_fdt(flag, argc, argv)) | |
724 | + if (bootm_find_images(flag, argc, argv)) | |
725 | 725 | return 1; |
726 | 726 | |
727 | 727 | return 0; |
include/bootm.h
... | ... | @@ -49,7 +49,7 @@ |
49 | 49 | ulong bootm_disable_interrupts(void); |
50 | 50 | |
51 | 51 | /* This is a special function used by booti/bootz */ |
52 | -int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]); | |
52 | +int bootm_find_images(int flag, int argc, char * const argv[]); | |
53 | 53 | |
54 | 54 | int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], |
55 | 55 | int states, bootm_headers_t *images, int boot_progress); |