Merge tag 'dm-pull-22aug20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
[platform/kernel/u-boot.git] / tools / rkcommon.c
index c2382df..61c392e 100644 (file)
@@ -133,7 +133,7 @@ static int rkcommon_get_aligned_size(struct image_tool_params *params,
 
 int rkcommon_check_params(struct image_tool_params *params)
 {
-       int i;
+       int i, size;
 
        /*
         * If this is a operation (list or extract), the don't require
@@ -153,17 +153,17 @@ int rkcommon_check_params(struct image_tool_params *params)
                spl_params.boot_file += 1;
        }
 
-       spl_params.init_size =
-               rkcommon_get_aligned_size(params, spl_params.init_file);
-       if (spl_params.init_size < 0)
+       size = rkcommon_get_aligned_size(params, spl_params.init_file);
+       if (size < 0)
                return EXIT_FAILURE;
+       spl_params.init_size = size;
 
        /* Boot file is optional, and only for back-to-bootrom functionality. */
        if (spl_params.boot_file) {
-               spl_params.boot_size =
-                       rkcommon_get_aligned_size(params, spl_params.boot_file);
-               if (spl_params.boot_size < 0)
+               size = rkcommon_get_aligned_size(params, spl_params.boot_file);
+               if (size < 0)
                        return EXIT_FAILURE;
+               spl_params.boot_size = size;
        }
 
        if (spl_params.init_size > rkcommon_get_spl_size(params)) {
@@ -307,11 +307,13 @@ static int rkcommon_parse_header(const void *buf, struct header0_info *header0,
                                           rkcommon_offset_to_spi(hdr1_offset));
 
        for (i = 0; i < ARRAY_SIZE(spl_infos); i++) {
-               if (!memcmp(&hdr1_sdmmc->magic, spl_infos[i].spl_hdr, 4)) {
+               if (!memcmp(&hdr1_sdmmc->magic, spl_infos[i].spl_hdr,
+                           RK_SPL_HDR_SIZE)) {
                        if (spl_info)
                                *spl_info = &spl_infos[i];
                        return IH_TYPE_RKSD;
-               } else if (!memcmp(&hdr1_spi->magic, spl_infos[i].spl_hdr, 4)) {
+               } else if (!memcmp(&hdr1_spi->magic, spl_infos[i].spl_hdr,
+                                  RK_SPL_HDR_SIZE)) {
                        if (spl_info)
                                *spl_info = &spl_infos[i];
                        return IH_TYPE_RKSPI;