drivers: serial: uart_stm32: fix for async_rx_buf_rsp

uart_stm32_async_rx_buf_rsp() does not return the necessary errors when
rx_next_buffer is already set & when async uart rx is disabled.
This patch was submitted by @mkaranki

Signed-off-by: Abderrahmane Jarmouni <abderrahmane.jarmouni-ext@st.com>
This commit is contained in:
Abderrahmane Jarmouni 2024-02-15 16:59:47 +01:00 committed by Alberto Escolar
parent 1a3bb3fd5c
commit 4affeaab20

View file

@ -1684,12 +1684,25 @@ static int uart_stm32_async_rx_buf_rsp(const struct device *dev, uint8_t *buf,
size_t len)
{
struct uart_stm32_data *data = dev->data;
unsigned int key;
int err = 0;
LOG_DBG("replace buffer (%d)", len);
key = irq_lock();
if (data->rx_next_buffer != NULL) {
err = -EBUSY;
} else if (!data->dma_rx.enabled) {
err = -EACCES;
} else {
data->rx_next_buffer = buf;
data->rx_next_buffer_len = len;
}
return 0;
irq_unlock(key);
return err;
}
static int uart_stm32_async_init(const struct device *dev)