Skip to content

Commit d6ca3fd

Browse files
jfischer-nocfriedt
authored andcommitted
tests: uart: remove CONFIG_UART_CONSOLE_ON_DEV_NAME usage
Use DT_CHOSEN(zephyr_console) instead of CONFIG_UART_CONSOLE_ON_DEV_NAME Kconfig option. Signed-off-by: Johann Fischer <[email protected]>
1 parent 6974c7c commit d6ca3fd

File tree

7 files changed

+32
-19
lines changed

7 files changed

+32
-19
lines changed

tests/drivers/uart/uart_async_api/src/test_uart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#elif defined(CONFIG_BOARD_NUCLEO_H723ZG)
4545
#define UART_DEVICE_NAME DT_LABEL(DT_NODELABEL(usart2))
4646
#else
47-
#define UART_DEVICE_NAME CONFIG_UART_CONSOLE_ON_DEV_NAME
47+
#define UART_DEVICE_NAME DT_LABEL(DT_CHOSEN(zephyr_console))
4848
#endif
4949

5050
void init_test(void);

tests/drivers/uart/uart_basic_api/src/test_uart.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <drivers/uart.h>
1919
#include <ztest.h>
2020

21-
#define UART_DEVICE_NAME CONFIG_UART_CONSOLE_ON_DEV_NAME
22-
2321
void test_uart_configure(void);
2422
void test_uart_config_get(void);
2523
void test_uart_poll_out(void);

tests/drivers/uart/uart_basic_api/src/test_uart_config.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ const struct uart_config uart_cfg = {
3636

3737
static int test_configure(void)
3838
{
39-
const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
39+
const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
4040

41-
if (!uart_dev) {
42-
TC_PRINT("Cannot get UART device\n");
41+
if (!device_is_ready(uart_dev)) {
42+
TC_PRINT("UART device not ready\n");
4343
return TC_FAIL;
4444
}
4545

@@ -58,10 +58,10 @@ static int test_configure(void)
5858
/* test UART configure get (retrieve configuration) */
5959
static int test_config_get(void)
6060
{
61-
const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
61+
const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
6262

63-
if (!uart_dev) {
64-
TC_PRINT("Cannot get UART device\n");
63+
if (!device_is_ready(uart_dev)) {
64+
TC_PRINT("UART device not ready\n");
6565
return TC_FAIL;
6666
}
6767

tests/drivers/uart/uart_basic_api/src/test_uart_fifo.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ static void uart_fifo_callback(const struct device *dev, void *user_data)
9292

9393
static int test_fifo_read(void)
9494
{
95-
const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
95+
const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
96+
97+
if (!device_is_ready(uart_dev)) {
98+
TC_PRINT("UART device not ready\n");
99+
return TC_FAIL;
100+
}
96101

97102
/* Verify uart_irq_callback_set() */
98103
uart_irq_callback_set(uart_dev, uart_fifo_callback);
@@ -115,7 +120,12 @@ static int test_fifo_read(void)
115120

116121
static int test_fifo_fill(void)
117122
{
118-
const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
123+
const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
124+
125+
if (!device_is_ready(uart_dev)) {
126+
TC_PRINT("UART device not ready\n");
127+
return TC_FAIL;
128+
}
119129

120130
char_sent = 0;
121131

tests/drivers/uart/uart_basic_api/src/test_uart_pending.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ static void uart_pending_callback(const struct device *dev, void *user_data)
9393

9494
static int test_pending(void)
9595
{
96-
const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
96+
const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
97+
98+
if (!device_is_ready(uart_dev)) {
99+
TC_PRINT("UART device not ready\n");
100+
return TC_FAIL;
101+
}
97102

98103
/*
99104
* Set IRQ callback function to handle RX IRQ.

tests/drivers/uart/uart_basic_api/src/test_uart_poll.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ static const char *poll_data = "This is a POLL test.\r\n";
1111
static int test_poll_in(void)
1212
{
1313
unsigned char recv_char;
14-
const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
14+
const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
1515

16-
if (!uart_dev) {
17-
TC_PRINT("Cannot get UART device\n");
16+
if (!device_is_ready(uart_dev)) {
17+
TC_PRINT("UART device not ready\n");
1818
return TC_FAIL;
1919
}
2020

@@ -38,10 +38,10 @@ static int test_poll_in(void)
3838
static int test_poll_out(void)
3939
{
4040
int i;
41-
const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
41+
const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
4242

43-
if (!uart_dev) {
44-
TC_PRINT("Cannot get UART device\n");
43+
if (!device_is_ready(uart_dev)) {
44+
TC_PRINT("UART device not ready\n");
4545
return TC_FAIL;
4646
}
4747

tests/drivers/uart/uart_mix_fifo_poll/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#elif defined(CONFIG_BOARD_ATSAME54_XPRO)
2929
#define UART_DEVICE_NAME DT_LABEL(DT_NODELABEL(sercom1))
3030
#else
31-
#define UART_DEVICE_NAME CONFIG_UART_CONSOLE_ON_DEV_NAME
31+
#define UART_DEVICE_NAME DT_LABEL(DT_CHOSEN(zephyr_console))
3232
#endif
3333

3434
struct rx_source {

0 commit comments

Comments
 (0)