storage/stream/flash: flash_sync: Check if there is anything to write
The commit moves block that checks if flash_stream_ctx.buf_bytes is non-zero out of CONFIG_STREAM_FLASH_ERASE specific code, as that is universal check and is valid also for not CONFIG_STREAM_FLASH_ERASE code. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
cfb056901c
commit
5a1750b053
1 changed files with 4 additions and 3 deletions
|
@ -56,11 +56,12 @@ static int flash_sync(struct stream_flash_ctx *ctx)
|
||||||
size_t write_addr = ctx->offset + ctx->bytes_written;
|
size_t write_addr = ctx->offset + ctx->bytes_written;
|
||||||
|
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_STREAM_FLASH_ERASE)) {
|
|
||||||
if (ctx->buf_bytes == 0) {
|
if (ctx->buf_bytes == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_STREAM_FLASH_ERASE)) {
|
||||||
|
|
||||||
rc = stream_flash_erase_page(ctx,
|
rc = stream_flash_erase_page(ctx,
|
||||||
write_addr + ctx->buf_bytes - 1);
|
write_addr + ctx->buf_bytes - 1);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue