Skip to content

Commit e78b078

Browse files
jfischer-nocfriedt
authored andcommitted
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 <[email protected]>
1 parent d6ca3fd commit e78b078

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

drivers/console/uart_console.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,10 @@ static int uart_console_init(const struct device *arg)
597597
ARG_UNUSED(arg);
598598

599599
/* Claim console device */
600-
uart_console_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME);
600+
uart_console_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
601+
if (!device_is_ready(uart_console_dev)) {
602+
return -ENODEV;
603+
}
601604

602605
uart_console_hook_install();
603606

subsys/console/getchar.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ int console_init(void)
5252
const struct device *uart_dev;
5353
int ret;
5454

55-
uart_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME);
55+
uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
56+
if (!device_is_ready(uart_dev)) {
57+
return -ENODEV;
58+
}
59+
5660
ret = tty_init(&console_serial, uart_dev);
5761

5862
if (ret) {

subsys/logging/log_backend_uart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ static void process(const struct log_backend *const backend,
7575

7676
static void log_backend_uart_init(struct log_backend const *const backend)
7777
{
78-
uart_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME);
79-
__ASSERT_NO_MSG((void *)uart_dev);
78+
uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
79+
__ASSERT_NO_MSG(device_is_ready(uart_dev));
8080

8181
if (IS_ENABLED(CONFIG_LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX)) {
8282
/* Print a separator so the output can be fed into

0 commit comments

Comments
 (0)