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 <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
5a1750b053
commit
07107f92c7
1 changed files with 1 additions and 13 deletions
|
@ -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);
|
fill_length = flash_get_write_block_size(ctx->fdev);
|
||||||
if (ctx->buf_bytes % fill_length) {
|
if (ctx->buf_bytes % fill_length) {
|
||||||
fill_length -= ctx->buf_bytes % fill_length;
|
fill_length -= ctx->buf_bytes % fill_length;
|
||||||
/*
|
filler = flash_get_parameters(ctx->fdev)->erase_value;
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(ctx->buf + ctx->buf_bytes, filler, fill_length);
|
memset(ctx->buf + ctx->buf_bytes, filler, fill_length);
|
||||||
ctx->buf_bytes += fill_length;
|
ctx->buf_bytes += fill_length;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue