This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 0af9a49d9c2cc0dff2235faead801bd543290548 Author: Abdelatif Guettouche <[email protected]> AuthorDate: Mon Aug 30 11:38:53 2021 +0200 esp32/esp32_oneshot_lowerhalf.c: Use device specific locks. Signed-off-by: Abdelatif Guettouche <[email protected]> --- arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c b/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c index 3c911fe..e807939 100644 --- a/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c @@ -35,6 +35,7 @@ #include <nuttx/arch.h> #include <nuttx/timers/oneshot.h> #include <nuttx/kmalloc.h> +#include <nuttx/spinlock.h> #include "esp32_oneshot.h" @@ -60,6 +61,7 @@ struct esp32_oneshot_lowerhalf_s oneshot_callback_t callback; /* Upper half Interrupt callback */ void *arg; /* Argument passed to handler */ uint16_t resolution; + spinlock_t lock; /* Device specific lock */ }; /**************************************************************************** @@ -208,12 +210,12 @@ static int esp32_lh_start(struct oneshot_lowerhalf_s *lower, /* Save the callback information and start the timer */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&priv->lock); priv->callback = callback; priv->arg = arg; ret = esp32_oneshot_start(&priv->oneshot, esp32_oneshot_lh_handler, priv, ts); - leave_critical_section(flags); + spin_unlock_irqrestore(&priv->lock, flags); if (ret < 0) { @@ -259,11 +261,11 @@ static int esp32_lh_cancel(struct oneshot_lowerhalf_s *lower, /* Cancel the timer */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&priv->lock); ret = esp32_oneshot_cancel(&priv->oneshot, ts); priv->callback = NULL; priv->arg = NULL; - leave_critical_section(flags); + spin_unlock_irqrestore(&priv->lock, flags); if (ret < 0) {
