From 39fe351512d28edcba63b90bcf91b1b5113f66e6 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 4 Oct 2025 14:21:01 +0000 Subject: [PATCH] retention: skip mutex lock/unlock when in pre-kernel Skip the mutex locking/unlocking when called during pre-kernel. Signed-off-by: Henrik Brix Andersen --- subsys/retention/retention.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/subsys/retention/retention.c b/subsys/retention/retention.c index a61f8df6b4d8a..3b61da48518a3 100644 --- a/subsys/retention/retention.c +++ b/subsys/retention/retention.c @@ -63,7 +63,9 @@ static inline void retention_lock_take(const struct device *dev) #ifdef CONFIG_RETENTION_MUTEXES struct retention_data *data = dev->data; - k_mutex_lock(&data->lock, K_FOREVER); + if (!k_is_pre_kernel()) { + k_mutex_lock(&data->lock, K_FOREVER); + } #else ARG_UNUSED(dev); #endif @@ -74,7 +76,9 @@ static inline void retention_lock_release(const struct device *dev) #ifdef CONFIG_RETENTION_MUTEXES struct retention_data *data = dev->data; - k_mutex_unlock(&data->lock); + if (!k_is_pre_kernel()) { + k_mutex_unlock(&data->lock); + } #else ARG_UNUSED(dev); #endif