Skip to content

Commit b6fe7aa

Browse files
committed
usb: device_next: cdc_acm: Fix unused function warning
Move cdc_acm_send_notification behind the #ifdef CONFIG_UART_LINE_CTRL to avoid unused function warning when config option CONFIG_UART_LINE_CTRL is deactivated. Signed-off-by: Tim Pambor <[email protected]>
1 parent ab2622f commit b6fe7aa

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

subsys/usb/device_next/class/usbd_cdc_acm.c

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -571,54 +571,6 @@ static int usbd_cdc_acm_init(struct usbd_class_data *const c_data)
571571
return 0;
572572
}
573573

574-
static inline int cdc_acm_send_notification(const struct device *dev,
575-
const uint16_t serial_state)
576-
{
577-
struct cdc_acm_notification notification = {
578-
.bmRequestType = 0xA1,
579-
.bNotificationType = USB_CDC_SERIAL_STATE,
580-
.wValue = 0,
581-
.wIndex = 0,
582-
.wLength = sys_cpu_to_le16(sizeof(uint16_t)),
583-
.data = sys_cpu_to_le16(serial_state),
584-
};
585-
struct cdc_acm_uart_data *data = dev->data;
586-
const struct cdc_acm_uart_config *cfg = dev->config;
587-
struct usbd_class_data *c_data = cfg->c_data;
588-
struct net_buf *buf;
589-
uint8_t ep;
590-
int ret;
591-
592-
if (!atomic_test_bit(&data->state, CDC_ACM_CLASS_ENABLED)) {
593-
LOG_INF("USB configuration is not enabled");
594-
return -EACCES;
595-
}
596-
597-
if (atomic_test_bit(&data->state, CDC_ACM_CLASS_SUSPENDED)) {
598-
LOG_INF("USB support is suspended (FIXME)");
599-
return -EACCES;
600-
}
601-
602-
ep = cdc_acm_get_int_in(c_data);
603-
buf = usbd_ep_buf_alloc(c_data, ep, sizeof(struct cdc_acm_notification));
604-
if (buf == NULL) {
605-
return -ENOMEM;
606-
}
607-
608-
net_buf_add_mem(buf, &notification, sizeof(struct cdc_acm_notification));
609-
ret = usbd_ep_enqueue(c_data, buf);
610-
if (ret) {
611-
net_buf_unref(buf);
612-
return ret;
613-
}
614-
615-
if (k_sem_take(&data->notif_sem, K_FOREVER) == -EAGAIN) {
616-
return -ECANCELED;
617-
}
618-
619-
return ret;
620-
}
621-
622574
/*
623575
* TX handler is triggered when the state of TX fifo has been altered.
624576
*/
@@ -1019,6 +971,54 @@ static void cdc_acm_poll_out(const struct device *dev, const unsigned char c)
1019971
}
1020972

1021973
#ifdef CONFIG_UART_LINE_CTRL
974+
static inline int cdc_acm_send_notification(const struct device *dev,
975+
const uint16_t serial_state)
976+
{
977+
struct cdc_acm_notification notification = {
978+
.bmRequestType = 0xA1,
979+
.bNotificationType = USB_CDC_SERIAL_STATE,
980+
.wValue = 0,
981+
.wIndex = 0,
982+
.wLength = sys_cpu_to_le16(sizeof(uint16_t)),
983+
.data = sys_cpu_to_le16(serial_state),
984+
};
985+
struct cdc_acm_uart_data *data = dev->data;
986+
const struct cdc_acm_uart_config *cfg = dev->config;
987+
struct usbd_class_data *c_data = cfg->c_data;
988+
struct net_buf *buf;
989+
uint8_t ep;
990+
int ret;
991+
992+
if (!atomic_test_bit(&data->state, CDC_ACM_CLASS_ENABLED)) {
993+
LOG_INF("USB configuration is not enabled");
994+
return -EACCES;
995+
}
996+
997+
if (atomic_test_bit(&data->state, CDC_ACM_CLASS_SUSPENDED)) {
998+
LOG_INF("USB support is suspended (FIXME)");
999+
return -EACCES;
1000+
}
1001+
1002+
ep = cdc_acm_get_int_in(c_data);
1003+
buf = usbd_ep_buf_alloc(c_data, ep, sizeof(struct cdc_acm_notification));
1004+
if (buf == NULL) {
1005+
return -ENOMEM;
1006+
}
1007+
1008+
net_buf_add_mem(buf, &notification, sizeof(struct cdc_acm_notification));
1009+
ret = usbd_ep_enqueue(c_data, buf);
1010+
if (ret) {
1011+
net_buf_unref(buf);
1012+
return ret;
1013+
}
1014+
1015+
if (k_sem_take(&data->notif_sem, K_FOREVER) == -EAGAIN) {
1016+
return -ECANCELED;
1017+
}
1018+
1019+
return ret;
1020+
}
1021+
10221022
static int cdc_acm_line_ctrl_set(const struct device *dev,
10231023
const uint32_t ctrl, const uint32_t val)
10241024
{

0 commit comments

Comments
 (0)