Skip to content

Commit d33871c

Browse files
nordic-krchnordicjm
authored andcommitted
drivers: serial: nrf_sw_lpuart: Fix missing UART_RX_BUF_RELEASED event
Fix case when UART_RX_BUF_RELEASED event is not called after explicit uart_rx_disable() call. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent a555524 commit d33871c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/serial/uart_nrf_sw_lpuart.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,14 +791,28 @@ static int api_rx_disable(const struct device *dev)
791791

792792
data->rx_state = RX_TO_OFF;
793793

794+
if (data->rx_buf) {
795+
struct uart_event buf_rel_evt = {
796+
.type = UART_RX_BUF_RELEASED,
797+
.data = {
798+
.rx_buf = {
799+
.buf = data->rx_buf
800+
}
801+
}
802+
};
803+
804+
data->rx_buf = NULL;
805+
user_callback(dev, &buf_rel_evt);
806+
}
807+
794808
err = uart_rx_disable(data->uart);
795809
if (err == -EFAULT) {
810+
796811
struct uart_event event = {
797812
.type = UART_RX_DISABLED
798813
};
799814

800815
data->rx_state = RX_OFF;
801-
data->rx_buf = NULL;
802816
user_callback(dev, &event);
803817
}
804818

0 commit comments

Comments
 (0)