diff --git a/subsys/usb/device/class/cdc_acm.c b/subsys/usb/device/class/cdc_acm.c index 417a35f0714..7e5fbbb672a 100644 --- a/subsys/usb/device/class/cdc_acm.c +++ b/subsys/usb/device/class/cdc_acm.c @@ -56,15 +56,17 @@ /* definitions */ #include -#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart) \ - && defined(CONFIG_LOG_BACKEND_UART) \ - && defined(CONFIG_USB_CDC_ACM_LOG_LEVEL) \ - && CONFIG_USB_CDC_ACM_LOG_LEVEL != LOG_LEVEL_NONE /* Prevent endless recursive logging loop and warn user about it */ +#if defined(CONFIG_USB_CDC_ACM_LOG_LEVEL) && CONFIG_USB_CDC_ACM_LOG_LEVEL != LOG_LEVEL_NONE +#define CHOSEN_CONSOLE DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart) +#define CHOSEN_SHELL DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_shell_uart), zephyr_cdc_acm_uart) +#if (CHOSEN_CONSOLE && defined(CONFIG_LOG_BACKEND_UART)) || \ + (CHOSEN_SHELL && defined(CONFIG_SHELL_LOG_BACKEND)) #warning "USB_CDC_ACM_LOG_LEVEL forced to LOG_LEVEL_NONE" #undef CONFIG_USB_CDC_ACM_LOG_LEVEL #define CONFIG_USB_CDC_ACM_LOG_LEVEL LOG_LEVEL_NONE #endif +#endif LOG_MODULE_REGISTER(usb_cdc_acm, CONFIG_USB_CDC_ACM_LOG_LEVEL); /* 115200bps, no parity, 1 stop bit, 8bit char */ diff --git a/subsys/usb/device_next/class/usbd_cdc_acm.c b/subsys/usb/device_next/class/usbd_cdc_acm.c index 80f4a858386..a3806304589 100644 --- a/subsys/usb/device_next/class/usbd_cdc_acm.c +++ b/subsys/usb/device_next/class/usbd_cdc_acm.c @@ -21,15 +21,17 @@ #include "usbd_msg.h" #include -#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart) \ - && defined(CONFIG_LOG_BACKEND_UART) \ - && defined(CONFIG_USBD_CDC_ACM_LOG_LEVEL) \ - && CONFIG_USBD_CDC_ACM_LOG_LEVEL != LOG_LEVEL_NONE /* Prevent endless recursive logging loop and warn user about it */ -#warning "USB_CDC_ACM_LOG_LEVEL forced to LOG_LEVEL_NONE" +#if defined(CONFIG_USBD_CDC_ACM_LOG_LEVEL) && CONFIG_USBD_CDC_ACM_LOG_LEVEL != LOG_LEVEL_NONE +#define CHOSEN_CONSOLE DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart) +#define CHOSEN_SHELL DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_shell_uart), zephyr_cdc_acm_uart) +#if (CHOSEN_CONSOLE && defined(CONFIG_LOG_BACKEND_UART)) || \ + (CHOSEN_SHELL && defined(CONFIG_SHELL_LOG_BACKEND)) +#warning "USBD_CDC_ACM_LOG_LEVEL forced to LOG_LEVEL_NONE" #undef CONFIG_USBD_CDC_ACM_LOG_LEVEL #define CONFIG_USBD_CDC_ACM_LOG_LEVEL LOG_LEVEL_NONE #endif +#endif LOG_MODULE_REGISTER(usbd_cdc_acm, CONFIG_USBD_CDC_ACM_LOG_LEVEL); UDC_BUF_POOL_DEFINE(cdc_acm_ep_pool,