drivers: retained_mem: Add optional mutex disablement
Adds an optional Kconfig to disable use of mutexes in the retained memory driver. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
parent
96a9b7e1ff
commit
0bf39f4a94
|
@ -15,6 +15,15 @@ config RETAINED_MEM_INIT_PRIORITY
|
||||||
help
|
help
|
||||||
Retained memory devices initialization priority,
|
Retained memory devices initialization priority,
|
||||||
|
|
||||||
|
config RETAINED_MEM_MUTEXES
|
||||||
|
int "Retained memory mutex support"
|
||||||
|
default y
|
||||||
|
depends on MULTITHREADING
|
||||||
|
help
|
||||||
|
Use mutexes to prevent issues with concurrent retained memory access.
|
||||||
|
Should only be disabled whereby retained memory access is required
|
||||||
|
in an ISR or for special use cases.
|
||||||
|
|
||||||
module = RETAINED_MEM
|
module = RETAINED_MEM
|
||||||
module-str = retained_mem
|
module-str = retained_mem
|
||||||
source "subsys/logging/Kconfig.template.log_config"
|
source "subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(retained_mem_nrf_gpregret, CONFIG_RETAINED_MEM_LOG_LEVEL);
|
LOG_MODULE_REGISTER(retained_mem_nrf_gpregret, CONFIG_RETAINED_MEM_LOG_LEVEL);
|
||||||
|
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct nrf_gpregret_data {
|
struct nrf_gpregret_data {
|
||||||
struct k_mutex lock;
|
struct k_mutex lock;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ struct nrf_gpregret_config {
|
||||||
|
|
||||||
static inline void nrf_gpregret_lock_take(const struct device *dev)
|
static inline void nrf_gpregret_lock_take(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct nrf_gpregret_data *data = dev->data;
|
struct nrf_gpregret_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_lock(&data->lock, K_FOREVER);
|
k_mutex_lock(&data->lock, K_FOREVER);
|
||||||
|
@ -40,7 +40,7 @@ static inline void nrf_gpregret_lock_take(const struct device *dev)
|
||||||
|
|
||||||
static inline void nrf_gpregret_lock_release(const struct device *dev)
|
static inline void nrf_gpregret_lock_release(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct nrf_gpregret_data *data = dev->data;
|
struct nrf_gpregret_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_unlock(&data->lock);
|
k_mutex_unlock(&data->lock);
|
||||||
|
@ -51,7 +51,7 @@ static inline void nrf_gpregret_lock_release(const struct device *dev)
|
||||||
|
|
||||||
static int nrf_gpregret_init(const struct device *dev)
|
static int nrf_gpregret_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct nrf_gpregret_data *data = dev->data;
|
struct nrf_gpregret_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_init(&data->lock);
|
k_mutex_init(&data->lock);
|
||||||
|
@ -115,7 +115,7 @@ static const struct retained_mem_driver_api nrf_gpregret_api = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NRF_GPREGRET_DEVICE(inst) \
|
#define NRF_GPREGRET_DEVICE(inst) \
|
||||||
IF_ENABLED(CONFIG_MULTITHREADING, \
|
IF_ENABLED(CONFIG_RETAINED_MEM_MUTEXES, \
|
||||||
(static struct nrf_gpregret_data nrf_gpregret_data_##inst;) \
|
(static struct nrf_gpregret_data nrf_gpregret_data_##inst;) \
|
||||||
) \
|
) \
|
||||||
static const struct nrf_gpregret_config nrf_gpregret_config_##inst = { \
|
static const struct nrf_gpregret_config nrf_gpregret_config_##inst = { \
|
||||||
|
@ -125,7 +125,7 @@ static const struct retained_mem_driver_api nrf_gpregret_api = {
|
||||||
DEVICE_DT_INST_DEFINE(inst, \
|
DEVICE_DT_INST_DEFINE(inst, \
|
||||||
&nrf_gpregret_init, \
|
&nrf_gpregret_init, \
|
||||||
NULL, \
|
NULL, \
|
||||||
COND_CODE_1(CONFIG_MULTITHREADING, \
|
COND_CODE_1(CONFIG_RETAINED_MEM_MUTEXES, \
|
||||||
(&nrf_gpregret_data_##inst), (NULL) \
|
(&nrf_gpregret_data_##inst), (NULL) \
|
||||||
), \
|
), \
|
||||||
&nrf_gpregret_config_##inst, \
|
&nrf_gpregret_config_##inst, \
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(retained_mem_zephyr_ram, CONFIG_RETAINED_MEM_LOG_LEVEL);
|
LOG_MODULE_REGISTER(retained_mem_zephyr_ram, CONFIG_RETAINED_MEM_LOG_LEVEL);
|
||||||
|
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct zephyr_retained_mem_ram_data {
|
struct zephyr_retained_mem_ram_data {
|
||||||
struct k_mutex lock;
|
struct k_mutex lock;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ struct zephyr_retained_mem_ram_config {
|
||||||
|
|
||||||
static inline void zephyr_retained_mem_ram_lock_take(const struct device *dev)
|
static inline void zephyr_retained_mem_ram_lock_take(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct zephyr_retained_mem_ram_data *data = dev->data;
|
struct zephyr_retained_mem_ram_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_lock(&data->lock, K_FOREVER);
|
k_mutex_lock(&data->lock, K_FOREVER);
|
||||||
|
@ -40,7 +40,7 @@ static inline void zephyr_retained_mem_ram_lock_take(const struct device *dev)
|
||||||
|
|
||||||
static inline void zephyr_retained_mem_ram_lock_release(const struct device *dev)
|
static inline void zephyr_retained_mem_ram_lock_release(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct zephyr_retained_mem_ram_data *data = dev->data;
|
struct zephyr_retained_mem_ram_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_unlock(&data->lock);
|
k_mutex_unlock(&data->lock);
|
||||||
|
@ -51,7 +51,7 @@ static inline void zephyr_retained_mem_ram_lock_release(const struct device *dev
|
||||||
|
|
||||||
static int zephyr_retained_mem_ram_init(const struct device *dev)
|
static int zephyr_retained_mem_ram_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_RETAINED_MEM_MUTEXES
|
||||||
struct zephyr_retained_mem_ram_data *data = dev->data;
|
struct zephyr_retained_mem_ram_data *data = dev->data;
|
||||||
|
|
||||||
k_mutex_init(&data->lock);
|
k_mutex_init(&data->lock);
|
||||||
|
@ -116,7 +116,7 @@ static const struct retained_mem_driver_api zephyr_retained_mem_ram_api = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZEPHYR_RETAINED_MEM_RAM_DEVICE(inst) \
|
#define ZEPHYR_RETAINED_MEM_RAM_DEVICE(inst) \
|
||||||
IF_ENABLED(CONFIG_MULTITHREADING, \
|
IF_ENABLED(CONFIG_RETAINED_MEM_MUTEXES, \
|
||||||
(static struct zephyr_retained_mem_ram_data \
|
(static struct zephyr_retained_mem_ram_data \
|
||||||
zephyr_retained_mem_ram_data_##inst;) \
|
zephyr_retained_mem_ram_data_##inst;) \
|
||||||
) \
|
) \
|
||||||
|
@ -128,7 +128,7 @@ static const struct retained_mem_driver_api zephyr_retained_mem_ram_api = {
|
||||||
DEVICE_DT_INST_DEFINE(inst, \
|
DEVICE_DT_INST_DEFINE(inst, \
|
||||||
&zephyr_retained_mem_ram_init, \
|
&zephyr_retained_mem_ram_init, \
|
||||||
NULL, \
|
NULL, \
|
||||||
COND_CODE_1(CONFIG_MULTITHREADING, \
|
COND_CODE_1(CONFIG_RETAINED_MEM_MUTEXES, \
|
||||||
(&zephyr_retained_mem_ram_data_##inst), (NULL) \
|
(&zephyr_retained_mem_ram_data_##inst), (NULL) \
|
||||||
), \
|
), \
|
||||||
&zephyr_retained_mem_ram_config_##inst, \
|
&zephyr_retained_mem_ram_config_##inst, \
|
||||||
|
|
Loading…
Reference in a new issue