From e78b0785b3bd20889823bb7edee40d109b28c871 Mon Sep 17 00:00:00 2001 From: Johann Fischer Date: Thu, 22 Jul 2021 15:57:31 +0200 Subject: [PATCH] console: remove device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME) Remove device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME) and use DEVICE_DT_GET(DT_CHOSEN(zephyr_console)) to get chosen "zephyr,console" node. Signed-off-by: Johann Fischer --- drivers/console/uart_console.c | 5 ++++- subsys/console/getchar.c | 6 +++++- subsys/logging/log_backend_uart.c | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c index 4b194b2a1b4..5c105857d0f 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -597,7 +597,10 @@ static int uart_console_init(const struct device *arg) ARG_UNUSED(arg); /* Claim console device */ - uart_console_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); + uart_console_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); + if (!device_is_ready(uart_console_dev)) { + return -ENODEV; + } uart_console_hook_install(); diff --git a/subsys/console/getchar.c b/subsys/console/getchar.c index f9434f5f09b..69b9433e4f9 100644 --- a/subsys/console/getchar.c +++ b/subsys/console/getchar.c @@ -52,7 +52,11 @@ int console_init(void) const struct device *uart_dev; int ret; - uart_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); + uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); + if (!device_is_ready(uart_dev)) { + return -ENODEV; + } + ret = tty_init(&console_serial, uart_dev); if (ret) { diff --git a/subsys/logging/log_backend_uart.c b/subsys/logging/log_backend_uart.c index c4530502c02..a6c3d3b7286 100644 --- a/subsys/logging/log_backend_uart.c +++ b/subsys/logging/log_backend_uart.c @@ -75,8 +75,8 @@ static void process(const struct log_backend *const backend, static void log_backend_uart_init(struct log_backend const *const backend) { - uart_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); - __ASSERT_NO_MSG((void *)uart_dev); + uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); + __ASSERT_NO_MSG(device_is_ready(uart_dev)); if (IS_ENABLED(CONFIG_LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX)) { /* Print a separator so the output can be fed into