You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/09/09 10:35:29 UTC
[incubator-nuttx] 01/02: esp32_serial.c: Replace critical section
by a device specific spin lock.
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit b5bb1fb8a38b63b3388e8bcfd922852a427d9b84
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Tue Aug 24 16:56:05 2021 +0200
esp32_serial.c: Replace critical section by a device specific spin lock.
Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
arch/xtensa/src/esp32/esp32_serial.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/arch/xtensa/src/esp32/esp32_serial.c b/arch/xtensa/src/esp32/esp32_serial.c
index 3d0f523..d2205f7 100644
--- a/arch/xtensa/src/esp32/esp32_serial.c
+++ b/arch/xtensa/src/esp32/esp32_serial.c
@@ -41,6 +41,7 @@
#include <nuttx/arch.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/serial/serial.h>
+#include <nuttx/spinlock.h>
#include <arch/board/board.h>
@@ -268,6 +269,7 @@ struct esp32_dev_s
#ifdef CONFIG_SERIAL_OFLOWCONTROL
bool oflow; /* Output flow control (CTS) enabled */
#endif
+ spinlock_t lock;
};
/****************************************************************************
@@ -816,7 +818,7 @@ static void esp32_disableallints(struct esp32_dev_s *priv, uint32_t *intena)
/* The following must be atomic */
- flags = enter_critical_section();
+ flags = spin_lock_irqsave(&priv->lock);
if (intena)
{
@@ -828,7 +830,7 @@ static void esp32_disableallints(struct esp32_dev_s *priv, uint32_t *intena)
/* Disable all interrupts */
putreg32(0, UART_INT_ENA_REG(priv->config->id));
- leave_critical_section(flags);
+ spin_unlock_irqrestore(&priv->lock, flags);
}
/****************************************************************************
@@ -953,7 +955,7 @@ static int esp32_setup(struct uart_dev_s *dev)
modifyreg32(UART_CONF1_REG(priv->config->id), 0, regval);
}
-#endif
+#endif
#endif
return OK;
@@ -1641,7 +1643,7 @@ static void esp32_rxint(struct uart_dev_s *dev, bool enable)
irqstate_t flags;
int regval;
- flags = enter_critical_section();
+ flags = spin_lock_irqsave(&priv->lock);
if (enable)
{
@@ -1666,7 +1668,7 @@ static void esp32_rxint(struct uart_dev_s *dev, bool enable)
putreg32(regval, UART_INT_ENA_REG(priv->config->id));
}
- leave_critical_section(flags);
+ spin_unlock_irqrestore(&priv->lock, flags);
}
/****************************************************************************
@@ -1714,7 +1716,7 @@ static void esp32_txint(struct uart_dev_s *dev, bool enable)
if (priv->txdma == false)
{
#endif
- flags = enter_critical_section();
+ flags = spin_lock_irqsave(&priv->lock);
if (enable)
{
@@ -1742,7 +1744,7 @@ static void esp32_txint(struct uart_dev_s *dev, bool enable)
(UART_TX_DONE_INT_ENA | UART_TXFIFO_EMPTY_INT_ENA), 0);
}
- leave_critical_section(flags);
+ spin_unlock_irqrestore(&priv->lock, flags);
#ifdef CONFIG_SERIAL_TXDMA
}
#endif