usb: cdc: add option to force IAD

Interface Association descriptor has to be used with Windows 7.
Add CONFIG_CDC_ACM_IAD option to force its usage, disabled by default.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
diff --git a/subsys/usb/class/Kconfig b/subsys/usb/class/Kconfig
index 7389176..056c47d 100644
--- a/subsys/usb/class/Kconfig
+++ b/subsys/usb/class/Kconfig
@@ -46,6 +46,14 @@
 	help
 	  CDC ACM class bulk endpoints size
 
+config CDC_ACM_IAD
+	bool "Force using Interface Association Descriptor"
+	default n
+	help
+	  IAD should not be required for non-composite CDC ACM device,
+	  but Windows 7 fails to properly enumerate without it.
+	  Enable if you want CDC ACM to work with Windows 7.
+
 module = USB_CDC_ACM
 module-str = usb cdc acm
 source "subsys/logging/Kconfig.template.log_config"
diff --git a/subsys/usb/class/cdc_acm.c b/subsys/usb/class/cdc_acm.c
index a859b55..77e431d 100644
--- a/subsys/usb/class/cdc_acm.c
+++ b/subsys/usb/class/cdc_acm.c
@@ -78,7 +78,7 @@
 #define ACM_IN_EP_IDX			2
 
 struct usb_cdc_acm_config {
-#ifdef CONFIG_USB_COMPOSITE_DEVICE
+#if (CONFIG_USB_COMPOSITE_DEVICE || CONFIG_CDC_ACM_IAD)
 	struct usb_association_descriptor iad_cdc;
 #endif
 	struct usb_if_descriptor if0;
@@ -989,7 +989,7 @@
 		.endpoint = cdc_acm_ep_data_##x,			\
 	};
 
-#if CONFIG_USB_COMPOSITE_DEVICE
+#if (CONFIG_USB_COMPOSITE_DEVICE || CONFIG_CDC_ACM_IAD)
 #define DEFINE_CDC_ACM_DESCR(x, int_ep_addr, out_ep_addr, in_ep_addr)	\
 	USBD_CLASS_DESCR_DEFINE(primary, x)				\
 	struct usb_cdc_acm_config cdc_acm_cfg_##x = {			\
@@ -1014,7 +1014,7 @@
 					CONFIG_CDC_ACM_BULK_EP_MPS,	\
 					0x00),				\
 }
-#else /* CONFIG_USB_COMPOSITE_DEVICE */
+#else /* (CONFIG_USB_COMPOSITE_DEVICE || CONFIG_CDC_ACM_IAD) */
 #define DEFINE_CDC_ACM_DESCR(x, int_ep_addr, out_ep_addr, in_ep_addr)	\
 	USBD_CLASS_DESCR_DEFINE(primary, x)				\
 	struct usb_cdc_acm_config cdc_acm_cfg_##x = {			\
@@ -1038,7 +1038,7 @@
 					CONFIG_CDC_ACM_BULK_EP_MPS,	\
 					0x00),				\
 }
-#endif /* CONFIG_USB_COMPOSITE_DEVICE */
+#endif /* (CONFIG_USB_COMPOSITE_DEVICE || CONFIG_CDC_ACM_IAD) */
 
 #define DEFINE_CDC_ACM_DEV_DATA(x, _)					\
 	RING_BUF_DECLARE(rx_ringbuf_##x,				\