From 5bf8edc85f83882a1380163aa10d81c2c3493848 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 28 Nov 2023 14:24:14 +1000 Subject: [PATCH] logging: uart: cleanup device runtime PM checks `pm_device_runtime_get` and `pm_device_runtime_put` have returned `0` when device runtime PM is not enabled since #56222. Manually checking the state is no longer required. Additionally, the functions have been able to run in an ISR context since #60785, which removed the need to special case `k_is_in_isr()`. Signed-off-by: Jordan Yates --- subsys/logging/backends/log_backend_uart.c | 27 +++++++--------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/subsys/logging/backends/log_backend_uart.c b/subsys/logging/backends/log_backend_uart.c index 46fa12b92e1..4173180f627 100644 --- a/subsys/logging/backends/log_backend_uart.c +++ b/subsys/logging/backends/log_backend_uart.c @@ -86,13 +86,11 @@ static int char_out(uint8_t *data, size_t length, void *ctx) struct lbu_data *lb_data = cb_ctx->data; const struct device *uart_dev = LBU_UART_DEV(cb_ctx); - if (pm_device_runtime_is_enabled(uart_dev) && !k_is_in_isr()) { - if (pm_device_runtime_get(uart_dev) < 0) { - /* Enabling the UART instance has failed but this - * function MUST return the number of bytes consumed. - */ - return length; - } + if (pm_device_runtime_get(uart_dev) < 0) { + /* Enabling the UART instance has failed but this + * function MUST return the number of bytes consumed. + */ + return length; } if (IS_ENABLED(CONFIG_LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX)) { @@ -116,10 +114,8 @@ static int char_out(uint8_t *data, size_t length, void *ctx) (void)err; cleanup: - if (pm_device_runtime_is_enabled(uart_dev) && !k_is_in_isr()) { - /* As errors cannot be returned, ignore the return value */ - (void)pm_device_runtime_put(uart_dev); - } + /* As errors cannot be returned, ignore the return value */ + (void)pm_device_runtime_put(uart_dev); return length; } @@ -190,14 +186,7 @@ static void panic(struct log_backend const *const backend) /* Ensure that the UART device is in active mode */ #if defined(CONFIG_PM_DEVICE_RUNTIME) - if (pm_device_runtime_is_enabled(uart_dev)) { - if (k_is_in_isr()) { - /* pm_device_runtime_get cannot be used from ISRs */ - pm_device_action_run(uart_dev, PM_DEVICE_ACTION_RESUME); - } else { - pm_device_runtime_get(uart_dev); - } - } + pm_device_runtime_get(uart_dev); #elif defined(CONFIG_PM_DEVICE) enum pm_device_state pm_state; int rc;