diff options
author | Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com> | 2016-07-29 11:56:36 -0500 |
---|---|---|
committer | Andrew Boie <andrew.p.boie@intel.com> | 2016-07-31 18:13:27 +0000 |
commit | eaebd1774be2f356242a9459efb331b1e8104c1c (patch) | |
tree | 4ba25d3a75c2adf6e07eac1fe70db856e475cab5 /usb | |
parent | 9a8ff013abd35a877fb8b97080095f4a2deb88f5 (diff) |
sys_log: replace USB CDC ACM Device Class Driver debug macros
USB CDC ACM Device Class driver is now using new system log macros
also updated the Kconfig variable to be a level rather than a bool.
JIRA: ZEP-311
Change-Id: I7093255f34ab514b030882ef4f54c955e7e848ec
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
Diffstat (limited to 'usb')
-rw-r--r-- | usb/class/Kconfig | 22 | ||||
-rw-r--r-- | usb/class/cdc_acm.c | 47 |
2 files changed, 37 insertions, 32 deletions
diff --git a/usb/class/Kconfig b/usb/class/Kconfig index 783d3b617..9dcf2c66c 100644 --- a/usb/class/Kconfig +++ b/usb/class/Kconfig @@ -32,12 +32,24 @@ config CDC_ACM_PORT_NAME help Port name through which CDC ACM class device driver is accessed -config USB_CDC_ACM_DEBUG - bool - prompt "Enable debug options for USB CDC ACM device class driver" - default n +config SYS_LOG_USB_CDC_ACM_LEVEL + int + prompt "USB CDC ACM device class driver log level" depends on USB_CDC_ACM + default 0 help - This option enables the debug features for USB CDC ACM device class driver + Sets log level for USB CDC ACM device class driver + + Levels are: + + - 0 OFF, do not write + + - 1 ERROR, only write SYS_LOG_ERR + + - 2 WARNING, write SYS_LOG_WRN in adition to previous level + + - 3 INFO, write SYS_LOG_INF in adition to previous levels + + - 4 DEBUG, write SYS_LOG_DBG in adition to previous levels endif # CONFIG_USB_DEVICE_STACK diff --git a/usb/class/cdc_acm.c b/usb/class/cdc_acm.c index e15b0f7fd..0a6965781 100644 --- a/usb/class/cdc_acm.c +++ b/usb/class/cdc_acm.c @@ -52,16 +52,8 @@ /* definitions */ -#ifndef CONFIG_USB_CDC_ACM_DEBUG -#define DBG(...) { ; } -#else -#if defined(CONFIG_STDOUT_CONSOLE) -#include <stdio.h> -#define DBG printf -#else -#define DBG printk -#endif /* CONFIG_STDOUT_CONSOLE */ -#endif /* CONFIG_USB_CDC_ACM_DEBUG */ +#define SYS_LOG_LEVEL CONFIG_SYS_LOG_USB_CDC_ACM_LEVEL +#include <misc/sys_log.h> #define DEV_DATA(dev) \ ((struct cdc_acm_dev_data_t * const)(dev)->driver_data) @@ -269,7 +261,7 @@ int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup, case CDC_SET_LINE_CODING: memcpy(&dev_data->line_coding, *data, sizeof(dev_data->line_coding)); - DBG("\nCDC_SET_LINE_CODING %d %d %d %d\n", + SYS_LOG_DBG("\nCDC_SET_LINE_CODING %d %d %d %d", sys_le32_to_cpu(dev_data->line_coding.dwDTERate), dev_data->line_coding.bCharFormat, dev_data->line_coding.bParityType, @@ -278,13 +270,14 @@ int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup, case CDC_SET_CONTROL_LINE_STATE: dev_data->line_state = (uint8_t)sys_le16_to_cpu(pSetup->wValue); - DBG("CDC_SET_CONTROL_LINE_STATE 0x%x\n", dev_data->line_state); + SYS_LOG_DBG("CDC_SET_CONTROL_LINE_STATE 0x%x", + dev_data->line_state); break; case CDC_GET_LINE_CODING: *data = (uint8_t *)(&dev_data->line_coding); *len = sizeof(dev_data->line_coding); - DBG("\nCDC_GET_LINE_CODING %d %d %d %d\n", + SYS_LOG_DBG("\nCDC_GET_LINE_CODING %d %d %d %d", sys_le32_to_cpu(dev_data->line_coding.dwDTERate), dev_data->line_coding.bCharFormat, dev_data->line_coding.bParityType, @@ -292,7 +285,7 @@ int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup, break; default: - DBG("CDC ACM request 0x%x, value 0x%x\n", + SYS_LOG_DBG("CDC ACM request 0x%x, value 0x%x", pSetup->bRequest, pSetup->wValue); return -EINVAL; } @@ -353,7 +346,7 @@ static void cdc_acm_bulk_out(uint8_t ep, if (((buf_head + 1) % CDC_ACM_BUFFER_SIZE) == dev_data->rx_buf_tail) { /* FIFO full, discard data */ - DBG("CDC buffer full!\n"); + SYS_LOG_ERR("CDC buffer full!"); } else { dev_data->rx_buf[buf_head] = tmp_buf[j]; buf_head = (buf_head + 1) % CDC_ACM_BUFFER_SIZE; @@ -381,7 +374,7 @@ static void cdc_acm_int_in(uint8_t ep, enum usb_dc_ep_cb_status_code ep_status) struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev); dev_data->notification_sent = 1; - DBG("CDC_IntIN EP[%x]\r\n", ep); + SYS_LOG_DBG("CDC_IntIN EP[%x]\r", ep); } /** @@ -401,29 +394,29 @@ static void cdc_acm_dev_status_cb(enum usb_dc_status_code status) /* Check the USB status and do needed action if required */ switch (status) { case USB_DC_ERROR: - DBG("USB device error\n"); + SYS_LOG_DBG("USB device error"); break; case USB_DC_RESET: - DBG("USB device reset detected\n"); + SYS_LOG_DBG("USB device reset detected"); break; case USB_DC_CONNECTED: - DBG("USB device connected\n"); + SYS_LOG_DBG("USB device connected"); break; case USB_DC_CONFIGURED: - DBG("USB device configured\n"); + SYS_LOG_DBG("USB device configured"); break; case USB_DC_DISCONNECTED: - DBG("USB device disconnected\n"); + SYS_LOG_DBG("USB device disconnected"); break; case USB_DC_SUSPEND: - DBG("USB device supended\n"); + SYS_LOG_DBG("USB device supended"); break; case USB_DC_RESUME: - DBG("USB device resumed\n"); + SYS_LOG_DBG("USB device resumed"); break; case USB_DC_UNKNOWN: default: - DBG("USB unknown state\n"); + SYS_LOG_DBG("USB unknown state"); break; } } @@ -495,14 +488,14 @@ static int cdc_acm_init(struct device *dev) /* Initialize the USB driver with the right configuration */ ret = usb_set_config(&cdc_acm_config); if (ret < 0) { - DBG("Failed to config USB\n"); + SYS_LOG_ERR("Failed to config USB"); return ret; } /* Enable USB driver */ ret = usb_enable(&cdc_acm_config); if (ret < 0) { - DBG("Failed to enable USB\n"); + SYS_LOG_ERR("Failed to enable USB"); return ret; } @@ -745,7 +738,7 @@ static int cdc_acm_send_notification(struct device *dev, uint16_t serial_state) while (!((volatile uint8_t)dev_data->notification_sent)) { sys_thread_busy_wait(1); if (++cnt > CDC_CONTROL_SERIAL_STATE_TIMEOUT_US) { - DBG("CDC ACM notification timeout!\n"); + SYS_LOG_DBG("CDC ACM notification timeout!"); return -EIO; } } |