usb: gadget: composite: Exclude SS Dev Cap Desc
authorJohn Youn <johnyoun@synopsys.com>
Fri, 28 Apr 2017 08:55:14 +0000 (12:55 +0400)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Fri, 2 Jun 2017 08:22:32 +0000 (11:22 +0300)
Don't send the SuperSpeed USB Device Capability descriptor if
the gadget is not capable of SuperSpeed.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/composite.c

index 49d685ad0da90d1a1282dd9d25f31ad64db22087..abec93ab81ee144f9f1b75f3d3e890e0186925da 100644 (file)
@@ -607,7 +607,6 @@ static int count_configs(struct usb_composite_dev *cdev, unsigned type)
 static int bos_desc(struct usb_composite_dev *cdev)
 {
        struct usb_ext_cap_descriptor   *usb_ext;
-       struct usb_ss_cap_descriptor    *ss_cap;
        struct usb_dcd_config_params    dcd_config_params;
        struct usb_bos_descriptor       *bos = cdev->req->buf;
 
@@ -633,29 +632,35 @@ static int bos_desc(struct usb_composite_dev *cdev)
         * The Superspeed USB Capability descriptor shall be implemented by all
         * SuperSpeed devices.
         */
-       ss_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
-       bos->bNumDeviceCaps++;
-       le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);
-       ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE;
-       ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
-       ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE;
-       ss_cap->bmAttributes = 0; /* LTM is not supported yet */
-       ss_cap->wSpeedSupported = cpu_to_le16(USB_LOW_SPEED_OPERATION |
-                               USB_FULL_SPEED_OPERATION |
-                               USB_HIGH_SPEED_OPERATION |
-                               USB_5GBPS_OPERATION);
-       ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION;
-
-       /* Get Controller configuration */
-       if (cdev->gadget->ops->get_config_params)
-               cdev->gadget->ops->get_config_params(&dcd_config_params);
-       else {
-               dcd_config_params.bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT;
-               dcd_config_params.bU2DevExitLat =
-                       cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT);
+       if (gadget_is_superspeed(cdev->gadget)) {
+               struct usb_ss_cap_descriptor *ss_cap;
+
+               ss_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
+               bos->bNumDeviceCaps++;
+               le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);
+               ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE;
+               ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
+               ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE;
+               ss_cap->bmAttributes = 0; /* LTM is not supported yet */
+               ss_cap->wSpeedSupported = cpu_to_le16(USB_LOW_SPEED_OPERATION |
+                                                     USB_FULL_SPEED_OPERATION |
+                                                     USB_HIGH_SPEED_OPERATION |
+                                                     USB_5GBPS_OPERATION);
+               ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION;
+
+               /* Get Controller configuration */
+               if (cdev->gadget->ops->get_config_params) {
+                       cdev->gadget->ops->get_config_params(
+                               &dcd_config_params);
+               } else {
+                       dcd_config_params.bU1devExitLat =
+                               USB_DEFAULT_U1_DEV_EXIT_LAT;
+                       dcd_config_params.bU2DevExitLat =
+                               cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT);
+               }
+               ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat;
+               ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;
        }
-       ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat;
-       ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;
 
        /* The SuperSpeedPlus USB Device Capability descriptor */
        if (gadget_is_superspeed_plus(cdev->gadget)) {