From 9628ecdc39f0dac696160910bce97c06f6a90af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Thu, 17 Nov 2022 17:41:30 +0100 Subject: [PATCH] drivers: uart_nrfx_uarte: Fix call to HW_RX_COUNTING_ENABLED() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the macro references `data->async->hw_rx_counting`, it cannot be called when `data->async` is NULL, and this could happen when the PM_DEVICE_ACTION_RESUME action was requested for an instance that uses the interrupt-driven API while for another instance that uses the asynchronous API the hardware counting of bytes was configured. Prevent this by calling the macro from a proper `if` block. Signed-off-by: Andrzej Głąbek --- drivers/serial/uart_nrfx_uarte.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index a0f1f041cd5..13ecd313426 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -1956,10 +1956,11 @@ static int uarte_nrfx_pm_action(const struct device *dev, nrf_uarte_enable(uarte); #ifdef UARTE_ANY_ASYNC - if (HW_RX_COUNTING_ENABLED(data)) { - nrfx_timer_enable(&cfg->timer); - } if (data->async) { + if (HW_RX_COUNTING_ENABLED(data)) { + nrfx_timer_enable(&cfg->timer); + } + return 0; } #endif