]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Combine bootm_find_<thing> functions together
authorKarl Apsite <Karl.Apsite@dornerworks.com>
Thu, 21 May 2015 13:52:49 +0000 (09:52 -0400)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 20:47:08 +0000 (22:47 +0200)
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>
common/bootm.c
common/cmd_bootm.c
include/bootm.h

index 07ae0f56ee68054f0f36f1c7f1c7ec3a3e5abc31..667c93471be5fdb8984c5f6da5a0e033e70de1b5 100644 (file)
@@ -206,7 +206,23 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
        return 0;
 }
 
-static int bootm_find_ramdisk(int flag, int argc, char * const argv[])
+/**
+ * bootm_find_images - wrapper to find and locate various images
+ * @flag: Ignored Argument
+ * @argc: command argument count
+ * @argv: command argument list
+ *
+ * boot_find_images() will attempt to load an available ramdisk,
+ * flattened device tree, as well as specifically marked
+ * "loadable" images (loadables are FIT only)
+ *
+ * Note: bootm_find_images will skip an image if it is not found
+ *
+ * @return:
+ *     0, if all existing images were loaded correctly
+ *     1, if an image is found but corrupted, or invalid
+ */
+int bootm_find_images(int flag, int argc, char * const argv[])
 {
        int ret;
 
@@ -218,14 +234,7 @@ static int bootm_find_ramdisk(int flag, int argc, char * const argv[])
                return 1;
        }
 
-       return 0;
-}
-
 #if defined(CONFIG_OF_LIBFDT)
-static int bootm_find_fdt(int flag, int argc, char * const argv[])
-{
-       int ret;
-
        /* find flattened device tree */
        ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
                           &images.ft_addr, &images.ft_len);
@@ -233,18 +242,10 @@ static int bootm_find_fdt(int flag, int argc, char * const argv[])
                puts("Could not find a valid device tree\n");
                return 1;
        }
-
        set_working_fdt_addr((ulong)images.ft_addr);
-
-       return 0;
-}
 #endif
 
 #if defined(CONFIG_FIT)
-static int bootm_find_loadables(int flag, int argc, char * const argv[])
-{
-       int ret;
-
        /* find all of the loadables */
        ret = boot_get_loadable(argc, argv, &images, IH_ARCH_DEFAULT,
                               NULL, NULL);
@@ -252,24 +253,6 @@ static int bootm_find_loadables(int flag, int argc, char * const argv[])
                printf("Loadable(s) is corrupt or invalid\n");
                return 1;
        }
-
-       return 0;
-}
-#endif
-
-int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[])
-{
-       if (bootm_find_ramdisk(flag, argc, argv))
-               return 1;
-
-#if defined(CONFIG_OF_LIBFDT)
-       if (bootm_find_fdt(flag, argc, argv))
-               return 1;
-#endif
-
-#if defined(CONFIG_FIT)
-       if (bootm_find_loadables(flag, argc, argv))
-               return 1;
 #endif
 
        return 0;
@@ -283,7 +266,7 @@ static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
             (images.os.type == IH_TYPE_MULTI)) &&
            (images.os.os == IH_OS_LINUX ||
                 images.os.os == IH_OS_VXWORKS))
-               return bootm_find_ramdisk_fdt(flag, argc, argv);
+               return bootm_find_images(flag, argc, argv);
 
        return 0;
 }
index 6b6aca66fd20b90e8b0bbfd1fa01f9899dbf8c37..48738ac60524d3b63095a00d6608a66dd1c6aaa0 100644 (file)
@@ -580,7 +580,7 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
         * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
         * have a header that provide this informaiton.
         */
-       if (bootm_find_ramdisk_fdt(flag, argc, argv))
+       if (bootm_find_images(flag, argc, argv))
                return 1;
 
        return 0;
@@ -721,7 +721,7 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
         * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
         * have a header that provide this informaiton.
         */
-       if (bootm_find_ramdisk_fdt(flag, argc, argv))
+       if (bootm_find_images(flag, argc, argv))
                return 1;
 
        return 0;
index 618148876975bf39947c4cd9cec91a4bd7d7e3e7..49813772ce568b3e0660dbd1faaa50458a7f6206 100644 (file)
@@ -49,7 +49,7 @@ int boot_selected_os(int argc, char * const argv[], int state,
 ulong bootm_disable_interrupts(void);
 
 /* This is a special function used by booti/bootz */
-int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]);
+int bootm_find_images(int flag, int argc, char * const argv[]);
 
 int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
                    int states, bootm_headers_t *images, int boot_progress);