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

lupyuen pushed a commit to branch releases/13.0
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/releases/13.0 by this push:
     new 859e61df607 arch/nrf91: fix broken modem initialization
859e61df607 is described below

commit 859e61df6074edadd3c16bd2308772aa07648cac
Author: raiden00pl <[email protected]>
AuthorDate: Fri Jun 5 11:59:41 2026 +0200

    arch/nrf91: fix broken modem initialization
    
    fix broken modem initialization for nrf91
    
    Signed-off-by: raiden00pl <[email protected]>
---
 arch/arm/src/nrf91/nrf91_modem_os.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/arch/arm/src/nrf91/nrf91_modem_os.c 
b/arch/arm/src/nrf91/nrf91_modem_os.c
index 940befab047..cabb4ebe696 100644
--- a/arch/arm/src/nrf91/nrf91_modem_os.c
+++ b/arch/arm/src/nrf91/nrf91_modem_os.c
@@ -29,6 +29,7 @@
 #include <arch/irq.h>
 
 #include <nuttx/arch.h>
+#include <nuttx/clock.h>
 #include <nuttx/mutex.h>
 #include <nuttx/semaphore.h>
 #include <nuttx/signal.h>
@@ -266,7 +267,6 @@ int32_t nrf_modem_os_timedwait(uint32_t context, int32_t 
*timeout)
 {
   struct nrf91_modem_os_waiting_s *waiting   = NULL;
   struct timespec                  ts_now;
-  struct timespec                  abstime;
   int32_t                          remaining = 0;
   int32_t                          diff      = 0;
   int                              ret       = -EAGAIN;
@@ -307,12 +307,12 @@ int32_t nrf_modem_os_timedwait(uint32_t context, int32_t 
*timeout)
     }
   else
     {
-      /* Wait for event or timeout */
+      /* Wait for event or timeout (relative timeout in milliseconds).
+       * Capture the return value so a posted event is reported as success
+       * instead of a timeout.
+       */
 
-      abstime.tv_sec  = *timeout / 1000;
-      abstime.tv_nsec = (*timeout % 1000) * 1000000;
-
-      nxsem_timedwait(&waiting->sem, &abstime);
+      ret = nxsem_tickwait(&waiting->sem, MSEC2TICK(*timeout));
     }
 
   /* Free a waiting slot */
@@ -477,12 +477,9 @@ int nrf_modem_os_sem_take(void *sem, int timeout)
     }
   else
     {
-      struct timespec abstime;
-
-      abstime.tv_sec  = timeout / 1000;
-      abstime.tv_nsec = (timeout % 1000) * 1000000;
+      /* Relative timeout in milliseconds. */
 
-      ret = nxsem_timedwait(s, &abstime);
+      ret = nxsem_tickwait(s, MSEC2TICK(timeout));
     }
 
   return ret;

Reply via email to