Skip to content

Commit d8854e9

Browse files
committed
retention: Add optional mutex disablement
Adds an optional Kconfig to disable use of mutexes in the retention subsystem. Signed-off-by: Jamie McCrae <[email protected]>
1 parent ac07d0b commit d8854e9

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

drivers/retained_mem/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ config RETAINED_MEM_INIT_PRIORITY
1616
Retained memory devices initialization priority,
1717

1818
config RETAINED_MEM_MUTEXES
19-
int "Retained memory mutex support"
19+
bool "Retained memory mutex support"
2020
default y
2121
depends on MULTITHREADING
2222
help

subsys/retention/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ config RETENTION_INIT_PRIORITY
1919
Retention device initialization priority (must be higher than init
2020
priorities for retained memory drivers.
2121

22+
config RETENTION_MUTEXES
23+
bool "Retention mutex support"
24+
default y
25+
depends on MULTITHREADING
26+
help
27+
Use mutexes to prevent issues with concurrent retention device
28+
access. Should only be disabled whereby retained memory access is
29+
required in an ISR or for special use cases.
30+
2231
config RETENTION_BUFFER_SIZE
2332
int "Retention stack buffer sizes"
2433
default 16

subsys/retention/retention.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum {
3131

3232
struct retention_data {
3333
bool header_written;
34-
#ifdef CONFIG_MULTITHREADING
34+
#ifdef CONFIG_RETENTION_MUTEXES
3535
struct k_mutex lock;
3636
#endif
3737
};
@@ -48,7 +48,7 @@ struct retention_config {
4848

4949
static inline void retention_lock_take(const struct device *dev)
5050
{
51-
#ifdef CONFIG_MULTITHREADING
51+
#ifdef CONFIG_RETENTION_MUTEXES
5252
struct retention_data *data = dev->data;
5353

5454
k_mutex_lock(&data->lock, K_FOREVER);
@@ -59,7 +59,7 @@ static inline void retention_lock_take(const struct device *dev)
5959

6060
static inline void retention_lock_release(const struct device *dev)
6161
{
62-
#ifdef CONFIG_MULTITHREADING
62+
#ifdef CONFIG_RETENTION_MUTEXES
6363
struct retention_data *data = dev->data;
6464

6565
k_mutex_unlock(&data->lock);
@@ -112,7 +112,7 @@ static int retention_checksum(const struct device *dev, uint32_t *output)
112112
static int retention_init(const struct device *dev)
113113
{
114114
const struct retention_config *config = dev->config;
115-
#ifdef CONFIG_MULTITHREADING
115+
#ifdef CONFIG_RETENTION_MUTEXES
116116
struct retention_data *data = dev->data;
117117
#endif
118118
ssize_t area_size;
@@ -139,7 +139,7 @@ static int retention_init(const struct device *dev)
139139
return -EINVAL;
140140
}
141141

142-
#ifdef CONFIG_MULTITHREADING
142+
#ifdef CONFIG_RETENTION_MUTEXES
143143
k_mutex_init(&data->lock);
144144
#endif
145145

0 commit comments

Comments
 (0)