From d000ff38dcafd391764f69a1e6ab6c7df1f00a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Mon, 25 May 2020 12:26:40 +0000 Subject: [PATCH] drivers: serial: nrfx: Force poll_out when lock attempts are over MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the loop that tries to obtain the lock in poll_out() finishes because of hitting the max number of trials (what normally should never happen), force the lock to be taken instead of just giving up with sending the data. The latter approach that was in use so far could not deal with a situation when some thread was aborted while keeping the lock. Other threads would then have no chance to send anything with poll_out() until it was called from an ISR. Signed-off-by: Andrzej Głąbek --- drivers/serial/uart_nrfx_uart.c | 2 +- drivers/serial/uart_nrfx_uarte.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/serial/uart_nrfx_uart.c b/drivers/serial/uart_nrfx_uart.c index 4024e6c6a80..3a79ed58f2b 100644 --- a/drivers/serial/uart_nrfx_uart.c +++ b/drivers/serial/uart_nrfx_uart.c @@ -280,7 +280,7 @@ static void uart_nrfx_poll_out(struct device *dev, unsigned char c) */ k_msleep(1); if (--safety_cnt == 0) { - return; + break; } } } else { diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 79ede11a6fc..dcf6bf680e5 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -1030,7 +1030,7 @@ static void uarte_nrfx_poll_out(struct device *dev, unsigned char c) */ k_msleep(1); if (--safety_cnt == 0) { - return; + break; } } } else {