]> git.sur5r.net Git - u-boot/commitdiff
rockchip: mkimage: simplify start/size calculation for rc4_encode
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Wed, 15 Mar 2017 11:08:42 +0000 (12:08 +0100)
committerSimon Glass <sjg@chromium.org>
Wed, 5 Apr 2017 02:01:57 +0000 (20:01 -0600)
The RC4 encoding works on full blocks, but the calculation of the
starting offset and size are needlessly complicated by using a
reference value known to be offset into a block by the size of the
header and then correcting for the (hard-coded) size of the header
(i.e. 4 bytes).

We change this over to use the RK_SPL_HDR_START directly (which is
known to be on a block boundary).

X-AffectedPlatforms: RK3399-Q7
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com>
tools/rksd.c
tools/rkspi.c

index ff2233ff2dc978f0e71d07d80793669f982aca07..e55c52267fd8b189d139581d5003cf844c3d32bb 100644 (file)
@@ -43,8 +43,8 @@ static void rksd_set_header(void *buf,  struct stat *sbuf,  int ifd,
               RK_SPL_HDR_SIZE);
 
        if (rkcommon_need_rc4_spl(params))
-               rkcommon_rc4_encode_spl(buf, RK_SPL_START - 4,
-                                       params->file_size - RK_SPL_START + 4);
+               rkcommon_rc4_encode_spl(buf, RK_SPL_HDR_START,
+                                       params->file_size - RK_SPL_HDR_START);
 }
 
 static int rksd_extract_subimage(void *buf,  struct image_tool_params *params)
index 0271d2e817bfa0e1d543b4b3c414b4351568238e..9fa43e8303468552153dd9b8234c838ac1a3d4c4 100644 (file)
@@ -49,8 +49,8 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,
               RK_SPL_HDR_SIZE);
 
        if (rkcommon_need_rc4_spl(params))
-               rkcommon_rc4_encode_spl(buf, RK_SPL_START - 4,
-                                       params->file_size - RK_SPL_START + 4);
+               rkcommon_rc4_encode_spl(buf, RK_SPL_HDR_START,
+                                       params->file_size - RK_SPL_HDR_START);
 
        /*
         * Spread the image out so we only use the first 2KB of each 4KB