From 8592d4319138b55b6c7bbab35057d5faa6d63a22 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Fri, 5 Jun 2020 10:41:05 +0200 Subject: [PATCH] drivers: uart: sam0: Reorder events on rx_disable Modified order of reported events on rx disable to match API description: first RX_RDY and then RX_BUF_RELEASED. Signed-off-by: Krzysztof Chruscinski --- drivers/serial/uart_sam0.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/serial/uart_sam0.c b/drivers/serial/uart_sam0.c index 3477e4503ba..85ba5309064 100644 --- a/drivers/serial/uart_sam0.c +++ b/drivers/serial/uart_sam0.c @@ -970,21 +970,6 @@ static int uart_sam0_rx_disable(struct device *dev) regs->INTENCLR.reg = SERCOM_USART_INTENCLR_RXC; dma_stop(dev_data->dma, cfg->rx_dma_channel); - if (dev_data->rx_next_len) { - struct uart_event evt = { - .type = UART_RX_BUF_RELEASED, - .data.rx_buf = { - .buf = dev_data->rx_next_buf, - }, - }; - - dev_data->rx_next_buf = NULL; - dev_data->rx_next_len = 0U; - - if (dev_data->async_cb) { - dev_data->async_cb(&evt, dev_data->async_cb_data); - } - } if (dma_get_status(dev_data->dma, cfg->rx_dma_channel, &st) == 0 && st.pending_length != 0U) { @@ -1007,6 +992,22 @@ static int uart_sam0_rx_disable(struct device *dev) dev_data->async_cb(&evt, dev_data->async_cb_data); } + if (dev_data->rx_next_len) { + struct uart_event evt = { + .type = UART_RX_BUF_RELEASED, + .data.rx_buf = { + .buf = dev_data->rx_next_buf, + }, + }; + + dev_data->rx_next_buf = NULL; + dev_data->rx_next_len = 0U; + + if (dev_data->async_cb) { + dev_data->async_cb(&evt, dev_data->async_cb_data); + } + } + evt.type = UART_RX_DISABLED; if (dev_data->async_cb) { dev_data->async_cb(&evt, dev_data->async_cb_data);