From 07107f92c75d5c130e08c9d6ec1bd4557bde0ed3 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Fri, 19 Feb 2021 12:50:28 +0000 Subject: [PATCH] storage/stream/flash: Use flash_get_parameters to get flash erase_value The stream_flash_buffered_write used to read byte from flash, in front of the current buffer pointer, to obtain value of errased flash; the code has been replaced with obtaining the value from flash parameters. Signed-off-by: Dominik Ermel --- subsys/storage/stream/stream_flash.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/subsys/storage/stream/stream_flash.c b/subsys/storage/stream/stream_flash.c index 1e38315fa69..d7b0cd8e19f 100644 --- a/subsys/storage/stream/stream_flash.c +++ b/subsys/storage/stream/stream_flash.c @@ -152,19 +152,7 @@ int stream_flash_buffered_write(struct stream_flash_ctx *ctx, const uint8_t *dat fill_length = flash_get_write_block_size(ctx->fdev); if (ctx->buf_bytes % fill_length) { fill_length -= ctx->buf_bytes % fill_length; - /* - * Leverage the fact that unwritten memory - * should be erased in order to get the erased - * byte-value. - */ - rc = flash_read(ctx->fdev, - ctx->offset + ctx->bytes_written, - (void *)&filler, - 1); - - if (rc != 0) { - return rc; - } + filler = flash_get_parameters(ctx->fdev)->erase_value; memset(ctx->buf + ctx->buf_bytes, filler, fill_length); ctx->buf_bytes += fill_length;