storage/stream/flash: Don't update last erased page offset on failure
The stream_flash_erase_page would update stream_flash_ctx member last_erased_page_start_offset, to page offset it attempted to erase, even if such operation failed. The commit changes this behaviour so that in case of failure the last_erased_page_start_offset would still hold previously, successfully, erase page offset. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
fa20bd129d
commit
94968dfee4
2 changed files with 31 additions and 1 deletions
|
@ -33,7 +33,6 @@ int stream_flash_erase_page(struct stream_flash_ctx *ctx, off_t off)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ctx->last_erased_page_start_offset = page.start_offset;
|
||||
LOG_DBG("Erasing page at offset 0x%08lx", (long)page.start_offset);
|
||||
|
||||
flash_write_protection_set(ctx->fdev, false);
|
||||
|
@ -42,6 +41,8 @@ int stream_flash_erase_page(struct stream_flash_ctx *ctx, off_t off)
|
|||
|
||||
if (rc != 0) {
|
||||
LOG_ERR("Error %d while erasing page", rc);
|
||||
} else {
|
||||
ctx->last_erased_page_start_offset = page.start_offset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue