From 0af9a49d9c2cc0dff2235faead801bd543290548 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Mon, 30 Aug 2021 11:38:53 +0200 Subject: [PATCH] esp32/esp32_oneshot_lowerhalf.c: Use device specific locks. Signed-off-by: Abdelatif Guettouche --- 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 3c911fe4b54..e807939908a 100644 --- a/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c @@ -35,6 +35,7 @@ #include #include #include +#include #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) {