This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 622945c391f drivers/syslog/ramlog: support reading the log from 
interrupt context.
622945c391f is described below

commit 622945c391fd7d3dd2dc0f0aacd42cc2717ce6b4
Author: yukangzhi <[email protected]>
AuthorDate: Sat Nov 29 11:50:45 2025 +0800

    drivers/syslog/ramlog: support reading the log from interrupt context.
    
    ramlog_file_read() asserted !up_interrupt_context() at entry because it
    may block waiting for new data when the buffer is empty. This prevents
    reading the buffered log from an interrupt handler or a panic/crash
    handler, where it is most useful to dump the recent log.
    
    Remove the assertion and, when called from interrupt context, stop
    reading and return what has been copied as soon as the buffer becomes
    empty instead of waiting for more data.
    
    Assisted-by: Kiro
    Signed-off-by: yukangzhi <[email protected]>
---
 drivers/syslog/ramlog.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/syslog/ramlog.c b/drivers/syslog/ramlog.c
index 3a122188fe7..4a2a40291cc 100644
--- a/drivers/syslog/ramlog.c
+++ b/drivers/syslog/ramlog.c
@@ -480,12 +480,6 @@ static ssize_t ramlog_file_read(FAR struct file *filep, 
FAR char *buffer,
   uint32_t tail;
   uint32_t pos;
 
-  /* If the circular buffer is empty, then wait for something to be written
-   * to it.  This function may NOT be called from an interrupt handler.
-   */
-
-  DEBUGASSERT(!up_interrupt_context());
-
   /* Get exclusive access to the rl_tail index */
 
   flags = enter_critical_section();
@@ -500,6 +494,15 @@ static ssize_t ramlog_file_read(FAR struct file *filep, 
FAR char *buffer,
         {
           /* The circular buffer is empty. */
 
+          /* If the function be called from an interrupt handler,
+           * then just break out of the loop.
+           */
+
+          if (up_interrupt_context())
+            {
+              break;
+            }
+
 #ifdef CONFIG_RAMLOG_NONBLOCKING
           /* Return what we have (with zero mean the end-of-file) */
 

Reply via email to