mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-30 08:30:50 +09:00
sparse: Simplify multiple logic
To check the alignment of the image blocks to the storage blocks, the current code uses a convoluted syntax, while a simple mod also does the work. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
7bfc3b1346
commit
40aeeda396
@ -37,11 +37,14 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <aboot.h>
|
#include <aboot.h>
|
||||||
|
#include <div64.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <part.h>
|
#include <part.h>
|
||||||
#include <sparse_format.h>
|
#include <sparse_format.h>
|
||||||
|
|
||||||
|
#include <linux/math64.h>
|
||||||
|
|
||||||
typedef struct sparse_buffer {
|
typedef struct sparse_buffer {
|
||||||
void *data;
|
void *data;
|
||||||
u32 length;
|
u32 length;
|
||||||
@ -260,7 +263,7 @@ void write_sparse_image(block_dev_desc_t *dev_desc,
|
|||||||
{
|
{
|
||||||
lbaint_t start;
|
lbaint_t start;
|
||||||
lbaint_t blkcnt;
|
lbaint_t blkcnt;
|
||||||
unsigned int chunk;
|
unsigned int chunk, offset;
|
||||||
sparse_header_t *sparse_header;
|
sparse_header_t *sparse_header;
|
||||||
chunk_header_t *chunk_header;
|
chunk_header_t *chunk_header;
|
||||||
sparse_buffer_t *buffer;
|
sparse_buffer_t *buffer;
|
||||||
@ -274,9 +277,12 @@ void write_sparse_image(block_dev_desc_t *dev_desc,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* verify sparse_header->blk_sz is an exact multiple of info->blksz */
|
/*
|
||||||
if (sparse_header->blk_sz !=
|
* Verify that the sparse block size is a multiple of our
|
||||||
(sparse_header->blk_sz & ~(info->blksz - 1))) {
|
* storage backend block size
|
||||||
|
*/
|
||||||
|
div_u64_rem(sparse_header->blk_sz, info->blksz, &offset);
|
||||||
|
if (offset) {
|
||||||
printf("%s: Sparse image block size issue [%u]\n",
|
printf("%s: Sparse image block size issue [%u]\n",
|
||||||
__func__, sparse_header->blk_sz);
|
__func__, sparse_header->blk_sz);
|
||||||
fastboot_fail("sparse image block size issue");
|
fastboot_fail("sparse image block size issue");
|
||||||
|
Loading…
Reference in New Issue
Block a user