retention: Add optional mutex disablement
Adds an optional Kconfig to disable use of mutexes in the retention subsystem. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
parent
0bf39f4a94
commit
4cdfa7bdd5
|
@ -16,7 +16,7 @@ config RETAINED_MEM_INIT_PRIORITY
|
||||||
Retained memory devices initialization priority,
|
Retained memory devices initialization priority,
|
||||||
|
|
||||||
config RETAINED_MEM_MUTEXES
|
config RETAINED_MEM_MUTEXES
|
||||||
int "Retained memory mutex support"
|
bool "Retained memory mutex support"
|
||||||
default y
|
default y
|
||||||
depends on MULTITHREADING
|
depends on MULTITHREADING
|
||||||
help
|
help
|
||||||
|
|
|
@ -19,6 +19,15 @@ config RETENTION_INIT_PRIORITY
|
||||||
Retention device initialization priority (must be higher than init
|
Retention device initialization priority (must be higher than init
|
||||||
priorities for retained memory drivers.
|
priorities for retained memory drivers.
|
||||||
|
|
||||||
|
config RETENTION_MUTEXES
|
||||||
|
bool "Retention mutex support"
|
||||||
|
default y
|
||||||
|
depends on MULTITHREADING
|
||||||
|
help
|
||||||
|
Use mutexes to prevent issues with concurrent retention device
|
||||||
|
access. Should only be disabled whereby retained memory access is
|
||||||
|
required in an ISR or for special use cases.
|
||||||
|
|
||||||
config RETENTION_BUFFER_SIZE
|
config RETENTION_BUFFER_SIZE
|
||||||
int "Retention stack buffer sizes"
|
int "Retention stack buffer sizes"
|
||||||
default 16
|
default 16
|
||||||
|
|
|
@ -31,7 +31,7 @@ enum {
|
||||||
|
|
||||||
struct retention_data {
|
struct retention_data {
|
||||||
bool header_written;
|
bool header_written;
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETENTION_MUTEXES
|
||||||
struct k_mutex lock;
|
struct k_mutex lock;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -48,7 +48,7 @@ struct retention_config {
|
||||||
|
|
||||||
static inline void retention_lock_take(const struct device *dev)
|
static inline void retention_lock_take(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETENTION_MUTEXES
|
||||||
struct retention_data *data = dev->data;
|
struct retention_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_lock(&data->lock, K_FOREVER);
|
k_mutex_lock(&data->lock, K_FOREVER);
|
||||||
|
@ -59,7 +59,7 @@ static inline void retention_lock_take(const struct device *dev)
|
||||||
|
|
||||||
static inline void retention_lock_release(const struct device *dev)
|
static inline void retention_lock_release(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETENTION_MUTEXES
|
||||||
struct retention_data *data = dev->data;
|
struct retention_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_unlock(&data->lock);
|
k_mutex_unlock(&data->lock);
|
||||||
|
@ -112,7 +112,7 @@ finish:
|
||||||
static int retention_init(const struct device *dev)
|
static int retention_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct retention_config *config = dev->config;
|
const struct retention_config *config = dev->config;
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETENTION_MUTEXES
|
||||||
struct retention_data *data = dev->data;
|
struct retention_data *data = dev->data;
|
||||||
#endif
|
#endif
|
||||||
ssize_t area_size;
|
ssize_t area_size;
|
||||||
|
@ -139,7 +139,7 @@ static int retention_init(const struct device *dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETENTION_MUTEXES
|
||||||
k_mutex_init(&data->lock);
|
k_mutex_init(&data->lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue