Skip to content

Commit de50859

Browse files
[nrf fromtree] storage/stream_flash: Add API to query buffered data size
add a wrapper function to read the number of bytes currently buffered and pending for the next flash write operation. Signed-off-by: Syver Haraldsen <[email protected]> (cherry picked from commit 6331225)
1 parent cf180fe commit de50859

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/zephyr/storage/stream_flash.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ int stream_flash_init(struct stream_flash_ctx *ctx, const struct device *fdev,
106106
*/
107107
size_t stream_flash_bytes_written(const struct stream_flash_ctx *ctx);
108108

109+
/**
110+
* @brief Read number of bytes buffered for the next flash write.
111+
*
112+
* @param ctx context
113+
*
114+
* @return Number of payload bytes buffered for the next flash write.
115+
*/
116+
size_t stream_flash_bytes_buffered(const struct stream_flash_ctx *ctx);
117+
109118
/**
110119
* @brief Process input buffers to be written to flash device in single blocks.
111120
* Will store remainder between calls.

subsys/storage/stream/stream_flash.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ size_t stream_flash_bytes_written(const struct stream_flash_ctx *ctx)
307307
return ctx->bytes_written;
308308
}
309309

310+
size_t stream_flash_bytes_buffered(const struct stream_flash_ctx *ctx)
311+
{
312+
return ctx->buf_bytes;
313+
}
314+
310315
#ifdef CONFIG_STREAM_FLASH_INSPECT
311316
struct _inspect_flash {
312317
size_t buf_len;

0 commit comments

Comments
 (0)