diff --git a/samples/boards/stm32/power_mgmt/serial_wakeup/src/main.c b/samples/boards/stm32/power_mgmt/serial_wakeup/src/main.c index 8ba5aefed72..8d749c338c7 100644 --- a/samples/boards/stm32/power_mgmt/serial_wakeup/src/main.c +++ b/samples/boards/stm32/power_mgmt/serial_wakeup/src/main.c @@ -11,19 +11,16 @@ #include #include -#define DEV_NAME DT_CHOSEN(zephyr_console) - void main(void) { - static const struct device *dev; + const struct device *const dev = + DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); - dev = DEVICE_DT_GET(DEV_NAME); - if (dev < 0) { - printk("Failed to get device"); + if (!device_is_ready(dev)) { + printk("Console device not ready"); + return; } - printk("Device ready\n"); - #if CONFIG_PM_DEVICE /* In PM_DEVICE modes, enable device as a wakeup source will prevent * system to switch it off (clock off, set pins to sleep configuration, ...)