storage/stream_flash: Support for devices without explicit erase
Support for devices not requiring erase with Stream Flash API. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
7894474cf9
commit
95dfd1210d
@ -11,8 +11,10 @@ menuconfig STREAM_FLASH
|
||||
Enable support of stream to flash API
|
||||
|
||||
if STREAM_FLASH
|
||||
|
||||
config STREAM_FLASH_ERASE
|
||||
bool "Perform erase operations"
|
||||
depends on FLASH_HAS_EXPLICIT_ERASE
|
||||
help
|
||||
If disabled an external actor must erase the flash area being written
|
||||
to.
|
||||
|
||||
@ -76,9 +76,18 @@ static int settings_direct_loader(const char *key, size_t len,
|
||||
|
||||
int stream_flash_erase_page(struct stream_flash_ctx *ctx, off_t off)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_FLASH_HAS_EXPLICIT_ERASE)
|
||||
int rc;
|
||||
struct flash_pages_info page;
|
||||
#if IS_ENABLED(CONFIG_FLASH_HAS_NO_EXPLICIT_ERASE)
|
||||
/* There are both types of devices */
|
||||
const struct flash_parameters *fparams = flash_get_parameters(ctx->fdev);
|
||||
|
||||
/* Stream flash does not rely on erase, it does it when device needs it */
|
||||
if (!(flash_params_get_erase_cap(fparams) & FLASH_ERASE_C_EXPLICIT)) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
rc = flash_get_page_info_by_offs(ctx->fdev, off, &page);
|
||||
if (rc != 0) {
|
||||
LOG_ERR("Error %d while getting page info", rc);
|
||||
@ -100,6 +109,9 @@ int stream_flash_erase_page(struct stream_flash_ctx *ctx, off_t off)
|
||||
}
|
||||
|
||||
return rc;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_STREAM_FLASH_ERASE */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user