This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 42381e0e4b254a9faa30f1ef3668726c1f0b2a24 Author: yinshengkai <[email protected]> AuthorDate: Fri Nov 1 10:39:04 2024 +0800 note: noteram reads multiple binary data at a time In binary mode noteram_read() returned one note per call, whatever the size of the caller's buffer, so reading out the buffer took one read() per note. Copy as many whole notes as fit into the buffer, taking the lock only once, and return the number of bytes copied. Assisted-by: Kiro:claude-opus-5-5 Signed-off-by: yinshengkai <[email protected]> --- drivers/note/noteram_driver.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c index acd16affbe3..b6827833fd0 100644 --- a/drivers/note/noteram_driver.c +++ b/drivers/note/noteram_driver.c @@ -496,9 +496,22 @@ static ssize_t noteram_read(FAR struct file *filep, FAR char *buffer, if (ctx->mode == NOTERAM_MODE_READ_BINARY) #endif { + size_t nread = 0; flags = spin_lock_irqsave_notrace(&drv->lock); - ret = noteram_get(drv, (FAR uint8_t *)buffer, buflen); + while (nread < buflen) + { + ret = noteram_get(drv, (FAR uint8_t *)buffer + nread, + buflen - nread); + if (ret <= 0) + { + break; + } + + nread += ret; + } + spin_unlock_irqrestore_notrace(&drv->lock, flags); + return nread; } #ifdef CONFIG_DRIVERS_NOTERAM_TEXT_DUMP else
