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
The following commit(s) were added to refs/heads/master by this push:
new bec9058 arch: lc823450: Replace the critical section with spinlock in
lc823450_serial.c
bec9058 is described below
commit bec9058b4cb368e33361a14f317b015d03e0a451
Author: Masayuki Ishikawa <[email protected]>
AuthorDate: Wed Dec 8 08:14:30 2021 +0900
arch: lc823450: Replace the critical section with spinlock in
lc823450_serial.c
Summary:
- This commit replaces the critical section with spinlock
- The logic is the same as cxd56_serial.c
Impact:
- None
Testing:
- Tested with lc823450-xgevk:bt
Signed-off-by: Masayuki Ishikawa <[email protected]>
---
arch/arm/src/lc823450/lc823450_serial.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm/src/lc823450/lc823450_serial.c
b/arch/arm/src/lc823450/lc823450_serial.c
index 21689df..93b5a5b 100644
--- a/arch/arm/src/lc823450/lc823450_serial.c
+++ b/arch/arm/src/lc823450/lc823450_serial.c
@@ -40,6 +40,7 @@
#include <nuttx/fs/ioctl.h>
#include <nuttx/semaphore.h>
#include <nuttx/serial/serial.h>
+#include <nuttx/spinlock.h>
#include <arch/board/board.h>
@@ -172,6 +173,7 @@ struct up_dev_s
sem_t rxpkt_wait;
sem_t txdma_wait;
#endif /* CONFIG_HSUART */
+ spinlock_t lock;
};
/****************************************************************************
@@ -944,7 +946,7 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
irqstate_t flags;
- flags = enter_critical_section();
+ flags = spin_lock_irqsave(&priv->lock);
if (enable)
{
/* Set to receive an interrupt when the TX fifo is half emptied */
@@ -963,7 +965,9 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
* the TX interrupt.
*/
+ spin_unlock_irqrestore(&priv->lock, flags);
uart_xmitchars(dev);
+ flags = spin_lock_irqsave(&priv->lock);
#endif
}
else
@@ -974,7 +978,7 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
up_serialout(priv, UART_UIEN, priv->im);
}
- leave_critical_section(flags);
+ spin_unlock_irqrestore(&priv->lock, flags);
}
/****************************************************************************