From 7dff17251918ed58c0a40b6554b5e352b4dac1e5 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Fri, 3 Feb 2023 15:10:56 +0100 Subject: [PATCH] drivers: serial: stm32 uart driver avoid LOG_WRN when going to sleep When the LOG_WRN is used on stm32 uart driver it could block execution : when pin state for sleep mode is not defined by the DTS even if no error is raised, LOG_ msg is crashing when entering sleep mode. Signed-off-by: Francois Ramu --- drivers/serial/uart_stm32.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 4ae4ccf6eee..ed82d91d150 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1792,10 +1792,14 @@ static int uart_stm32_pm_action(const struct device *dev, /* Move pins to sleep state */ err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP); - if (err == -ENOENT) { - /* Warn but don't block PM suspend */ - LOG_WRN("(LP)UART pinctrl sleep state not available "); - } else if (err < 0) { + if ((err < 0) && (err != -ENOENT)) { + /* + * If returning -ENOENT, no pins where defined for sleep mode : + * Do not output on console (might sleep already) when going to sleep, + * "(LP)UART pinctrl sleep state not available" + * and don't block PM suspend. + * Else return the error. + */ return err; } break;