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 <syver.haraldsen@nordicsemi.no>
This commit is contained in:
Syver Haraldsen
2025-09-01 09:00:17 +02:00
committed by Benjamin Cabé
parent 633246a3ea
commit 6331225c94
2 changed files with 14 additions and 0 deletions

View File

@@ -106,6 +106,15 @@ int stream_flash_init(struct stream_flash_ctx *ctx, const struct device *fdev,
*/
size_t stream_flash_bytes_written(const struct stream_flash_ctx *ctx);
/**
* @brief Read number of bytes buffered for the next flash write.
*
* @param ctx context
*
* @return Number of payload bytes buffered for the next flash write.
*/
size_t stream_flash_bytes_buffered(const struct stream_flash_ctx *ctx);
/**
* @brief Process input buffers to be written to flash device in single blocks.
* Will store remainder between calls.

View File

@@ -307,6 +307,11 @@ size_t stream_flash_bytes_written(const struct stream_flash_ctx *ctx)
return ctx->bytes_written;
}
size_t stream_flash_bytes_buffered(const struct stream_flash_ctx *ctx)
{
return ctx->buf_bytes;
}
#ifdef CONFIG_STREAM_FLASH_INSPECT
struct _inspect_flash {
size_t buf_len;