Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion subsys/shell/backends/shell_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <zephyr/init.h>
#include <zephyr/logging/log.h>
#include <zephyr/net_buf.h>
#include <zephyr/pm/device_runtime.h>

#define LOG_MODULE_NAME shell_uart
LOG_MODULE_REGISTER(shell_uart);
Expand Down Expand Up @@ -290,6 +291,7 @@ static int init(const struct shell_transport *transport,
void *context)
{
struct shell_uart_common *common = (struct shell_uart_common *)transport->ctx;
int ret;

common->dev = (const struct device *)config;
common->handler = evt_handler;
Expand All @@ -300,6 +302,11 @@ static int init(const struct shell_transport *transport,
k_fifo_init(&common->smp.buf_ready);
#endif

ret = pm_device_runtime_get(common->dev);
if (ret < 0) {
return ret;
}

if (IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_API_ASYNC)) {
async_init((struct shell_uart_async *)transport->ctx);
} else if (IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_API_INTERRUPT_DRIVEN)) {
Expand Down Expand Up @@ -331,6 +338,8 @@ static void polling_uninit(struct shell_uart_polling *sh_uart)

static int uninit(const struct shell_transport *transport)
{
struct shell_uart_common *common = (struct shell_uart_common *)transport->ctx;

if (IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_API_ASYNC)) {
async_uninit((struct shell_uart_async *)transport->ctx);
} else if (IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_API_INTERRUPT_DRIVEN)) {
Expand All @@ -339,7 +348,7 @@ static int uninit(const struct shell_transport *transport)
polling_uninit((struct shell_uart_polling *)transport->ctx);
}

return 0;
return pm_device_runtime_put(common->dev);
}

static int enable(const struct shell_transport *transport, bool blocking_tx)
Expand Down