From 2cb1511602db820f8fe77c6aadebd5583fe78bc7 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 5 Jun 2026 11:59:41 +0200 Subject: [PATCH] arch/nrf91: fix broken modem initialization fix broken modem initialization for nrf91 Signed-off-by: raiden00pl --- 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 #include +#include #include #include #include @@ -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; + /* Relative timeout in milliseconds. */ - abstime.tv_sec = timeout / 1000; - abstime.tv_nsec = (timeout % 1000) * 1000000; - - ret = nxsem_timedwait(s, &abstime); + ret = nxsem_tickwait(s, MSEC2TICK(timeout)); } return ret;