diff options
author | Steve Rae <srae@broadcom.com> | 2016-06-07 11:19:38 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-06-27 16:37:39 -0400 |
commit | 2c72404687f1061d042769cc65ef90e6c3da3f96 (patch) | |
tree | 7ccf1a26328276f817dd8c0336ac8b74d911d28b /common/fb_nand.c | |
parent | 9bc34799c8e6d8907b18e02c405576aa6bf9ce15 (diff) | |
download | u-boot-2c72404687f1061d042769cc65ef90e6c3da3f96.tar.gz |
fastboot: sparse: implement reserve()
In order to process the CHUNK_TYPE_DONT_CARE properly, there is
a requirement to be able to 'reserve' a specified number of blocks
in the storage media. Because of the special handling of "bad blocks"
in NAND devices, this is implemented in a storage abstraction function.
Signed-off-by: Steve Rae <srae@broadcom.com>
Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Diffstat (limited to 'common/fb_nand.c')
-rw-r--r-- | common/fb_nand.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/fb_nand.c b/common/fb_nand.c index 77ca55d435..c8c79e9238 100644 --- a/common/fb_nand.c +++ b/common/fb_nand.c @@ -126,6 +126,25 @@ static lbaint_t fb_nand_sparse_write(struct sparse_storage *info, return written / info->blksz; } +static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info, + lbaint_t blk, lbaint_t blkcnt) +{ + int bad_blocks = 0; + +/* + * TODO - implement a function to determine the total number + * of blocks which must be used in order to reserve the specified + * number ("blkcnt") of "good-blocks", starting at "blk"... + * ( possibly something like the "check_skip_len()" function ) + */ + + /* + * the return value must be 'blkcnt' ("good-blocks") plus the + * number of "bad-blocks" encountered within this space... + */ + return blkcnt + bad_blocks; +} + void fb_nand_flash_write(const char *cmd, void *download_buffer, unsigned int download_bytes) { @@ -155,6 +174,7 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer, sparse.start = part->offset / sparse.blksz; sparse.size = part->size / sparse.blksz; sparse.write = fb_nand_sparse_write; + sparse.reserve = fb_nand_sparse_reserve; printf("Flashing sparse image at offset " LBAFU "\n", sparse.start); |