]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spl: fit: Fix the number of bytes read in raw mode
authorLokesh Vutla <lokeshvutla@ti.com>
Tue, 19 Jul 2016 09:26:14 +0000 (14:56 +0530)
committerTom Rini <trini@konsulko.com>
Fri, 22 Jul 2016 18:46:25 +0000 (14:46 -0400)
In raw mode a full sector is to be read even if image covers part of
a sector. Number of sectors are calculated as ROUND_UP(size)/sec_size by FIT
framework. This calculation assumes that image is at the 0th offset of a sector,
which is not true always in FIT case. So, include the image offset while
calculating number of sectors.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
common/spl/spl_fit.c

index 069e94d529b380e19abb3f452ab26dd39cdb2354..be86072c24e8138dc66be8be456d70ffe931ea4e 100644 (file)
@@ -115,8 +115,10 @@ static int get_aligned_image_overhead(struct spl_load_info *info, int offset)
 static int get_aligned_image_size(struct spl_load_info *info, int data_size,
                                  int offset)
 {
+       data_size = data_size + get_aligned_image_overhead(info, offset);
+
        if (info->filename)
-               return data_size + get_aligned_image_overhead(info, offset);
+               return data_size;
 
        return (data_size + info->bl_len - 1) / info->bl_len;
 }