Skip to content

Commit fcc3333

Browse files
Revert "[nrf fromlist] storage/stream: fix possible unaligned write on buffer flush"
This reverts commit fa19237. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 6ecbeb3 commit fcc3333

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

subsys/storage/stream/stream_flash.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ int stream_flash_buffered_write(struct stream_flash_ctx *ctx, const u8_t *data,
112112
int processed = 0;
113113
int rc = 0;
114114
int buf_empty_bytes;
115-
size_t fill_length;
116-
u8_t filler;
117115

118116
if (!ctx || !data) {
119117
return -EFAULT;
@@ -146,27 +144,6 @@ int stream_flash_buffered_write(struct stream_flash_ctx *ctx, const u8_t *data,
146144
}
147145

148146
if (flush && ctx->buf_bytes > 0) {
149-
fill_length = flash_get_write_block_size(ctx->fdev);
150-
if (ctx->buf_bytes % fill_length) {
151-
fill_length -= ctx->buf_bytes % fill_length;
152-
/*
153-
* Leverage the fact that unwritten memory
154-
* should be erased in order to get the erased
155-
* byte-value.
156-
*/
157-
rc = flash_read(ctx->fdev,
158-
ctx->offset + ctx->bytes_written,
159-
(void *)&filler,
160-
1);
161-
162-
if (rc != 0) {
163-
return rc;
164-
}
165-
166-
memset(ctx->buf + ctx->buf_bytes, filler, fill_length);
167-
ctx->buf_bytes += fill_length;
168-
}
169-
170147
rc = flash_sync(ctx);
171148
}
172149

@@ -191,11 +168,6 @@ int stream_flash_init(struct stream_flash_ctx *ctx, struct device *fdev,
191168
const struct flash_pages_layout *layout;
192169
const struct flash_driver_api *api = fdev->driver_api;
193170

194-
if (buf_len % flash_get_write_block_size(fdev)) {
195-
LOG_ERR("Buffer size is not aligned to minimal write-block-size");
196-
return -EFAULT;
197-
}
198-
199171
/* Calculate the total size of the flash device */
200172
api->page_layout(fdev, &layout, &layout_size);
201173
for (int i = 0; i < layout_size; i++) {

0 commit comments

Comments
 (0)