From e10ed057e878acb59fc764c599dc24ea28832ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Mon, 8 Apr 2024 17:24:09 +0200 Subject: [PATCH] drivers: serial: uart_async_to_irq: Move resetting to disabling function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move resetting of the receiver state to disabling function so that once uart is disabled there is no data pending in the module. Signed-off-by: Krzysztof Chruściński --- drivers/serial/uart_async_to_irq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/serial/uart_async_to_irq.c b/drivers/serial/uart_async_to_irq.c index 59216cbc13d..eed05e88e6d 100644 --- a/drivers/serial/uart_async_to_irq.c +++ b/drivers/serial/uart_async_to_irq.c @@ -107,6 +107,10 @@ static void on_rx_dis(const struct device *dev, struct uart_async_to_irq_data *d if (data->flags & A2I_RX_ENABLE) { int err; + if (data->rx.async_rx.pending_bytes == 0) { + uart_async_rx_reset(&data->rx.async_rx); + } + err = try_rx_enable(dev, data); if (err == 0) { data->rx.pending_buf_req = 0; @@ -331,7 +335,6 @@ int uart_async_to_irq_rx_enable(const struct device *dev) return err; } - uart_async_rx_reset(&data->rx.async_rx); err = try_rx_enable(dev, data); if (err == 0) { @@ -355,6 +358,8 @@ int uart_async_to_irq_rx_disable(const struct device *dev) k_sem_take(&data->rx.sem, K_FOREVER); } + uart_async_rx_reset(&data->rx.async_rx); + return 0; }