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 56e0e6a5ec988024bbc7cd8b8e02a0f19b75c83d Author: Masayuki Ishikawa <[email protected]> AuthorDate: Mon Feb 28 10:59:26 2022 +0900 arch: imx6: Remove sem_t from imx_serial.c Summary: - I noticed that when exiting getprime, DEBUGASSERT happens in nxsem_wait() - Finally, I found that up_putc() uses nxsem_wait() - This commit fixes this issue by removing the semaphore. - Also, up_putc() now calls imx_lowputc() Impact: - None Testing: - Tested with sabre-6quad:netknsh (not merged yet) Signed-off-by: Masayuki Ishikawa <[email protected]> --- arch/arm/src/imx6/imx_serial.c | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/arch/arm/src/imx6/imx_serial.c b/arch/arm/src/imx6/imx_serial.c index 239c4121..9f4100d 100644 --- a/arch/arm/src/imx6/imx_serial.c +++ b/arch/arm/src/imx6/imx_serial.c @@ -42,7 +42,6 @@ #include <nuttx/spinlock.h> #include <nuttx/init.h> #include <nuttx/fs/ioctl.h> -#include <nuttx/semaphore.h> #include <nuttx/serial/serial.h> #include "chip.h" @@ -239,10 +238,6 @@ static bool imx_txempty(struct uart_dev_s *dev); * Private Data ****************************************************************************/ -/* Used to assure mutually exclusive access up_putc() */ - -static sem_t g_putc_lock = SEM_INITIALIZER(1); - /* Serial driver UART operations */ static const struct uart_ops_s g_uart_ops = @@ -1123,30 +1118,12 @@ int up_putc(int ch) { struct imx_uart_s *priv = (struct imx_uart_s *)CONSOLE_DEV.priv; uint32_t ier; - bool locked; - int ret; - - /* Only one thread may enter up_putc at a time. */ - - locked = false; - - if (!up_interrupt_context() && g_nx_initstate >= OSINIT_HARDWARE) - { - ret = nxsem_wait(&g_putc_lock); - if (ret < 0) - { - return ret; - } - - locked = true; - } /* Disable UART interrupts and wait until the hardware is ready to send * a byte. */ imx_disableuartint(priv, &ier); - imx_waittxready(priv); /* Check for LF */ @@ -1154,19 +1131,12 @@ int up_putc(int ch) { /* Add CR */ - imx_serialout(priv, UART_TXD_OFFSET, (uint32_t)'\r'); - imx_waittxready(priv); + imx_lowputc('\r'); } - imx_serialout(priv, UART_TXD_OFFSET, (uint32_t)ch); - imx_waittxready(priv); + imx_lowputc(ch); imx_restoreuartint(priv, ier); - if (locked) - { - nxsem_post(&g_putc_lock); - } - return ch; }
