diff --git a/drivers/note/noterpmsg_driver.c b/drivers/note/noterpmsg_driver.c index be47721792fa9..e6d5f30fc0483 100644 --- a/drivers/note/noterpmsg_driver.c +++ b/drivers/note/noterpmsg_driver.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "noterpmsg.h" @@ -49,6 +50,7 @@ struct noterpmsg_driver_s uint8_t buffer[CONFIG_DRIVERS_NOTERPMSG_BUFSIZE]; struct work_s work; struct rpmsg_endpoint ept; + spinlock_t note_driver_lock; }; /**************************************************************************** @@ -178,7 +180,7 @@ static bool noterpmsg_transfer(FAR struct noterpmsg_driver_s *drv, static void noterpmsg_work(FAR void *priv) { FAR struct noterpmsg_driver_s *drv = priv; - irqstate_t flags = enter_critical_section(); + irqstate_t flags = spin_lock_irqsave_wo_note(&drv->note_driver_lock); if (!noterpmsg_transfer(drv, false)) { @@ -186,7 +188,7 @@ static void noterpmsg_work(FAR void *priv) NOTE_RPMSG_WORK_DELAY); } - leave_critical_section(flags); + spin_unlock_irqrestore_wo_note(&drv->note_driver_lock, flags); } static void noterpmsg_add(FAR struct note_driver_s *driver, @@ -197,7 +199,7 @@ static void noterpmsg_add(FAR struct note_driver_s *driver, irqstate_t flags; size_t space; - flags = enter_critical_section(); + flags = spin_lock_irqsave_wo_note(&drv->note_driver_lock); space = CONFIG_DRIVERS_NOTERPMSG_BUFSIZE - noterpmsg_length(drv); if (space < notelen) @@ -234,7 +236,7 @@ static void noterpmsg_add(FAR struct note_driver_s *driver, NOTE_RPMSG_WORK_DELAY); } - leave_critical_section(flags); + spin_unlock_irqrestore_wo_note(&drv->note_driver_lock, flags); } static int noterpmsg_ept_cb(FAR struct rpmsg_endpoint *ept, @@ -254,6 +256,7 @@ static void noterpmsg_device_created(FAR struct rpmsg_device *rdev, rpmsg_get_cpuname(rdev)) == 0) { drv->ept.priv = drv; + spin_lock_init(&drv->note_driver_lock); ret = rpmsg_create_ept(&drv->ept, rdev, NOTERPMSG_EPT_NAME, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,