Merge git://git.denx.de/u-boot-usb
[oweals/u-boot.git] / drivers / usb / gadget / ep0.c
index 22499d36bfe20213cbe063065a37c8bcd7260675..4ba2f3d99fd67861bc1d9fee5bba71b69315d3d0 100644 (file)
  *     Tom Rushworth <tbr@lineo.com>,
  *     Bruce Balden <balden@lineo.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -328,7 +315,7 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
                        /*copy_config(urb, &report_descriptor->bData[0], report_descriptor->wLength, max); */
                        if (max - urb->actual_length > 0) {
                                int length =
-                                       MIN (report_descriptor->wLength,
+                                       min(report_descriptor->wLength,
                                             max - urb->actual_length);
                                memcpy (urb->buffer + urb->actual_length,
                                        &report_descriptor->bData[0], length);
@@ -338,12 +325,27 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
                }
                break;
        case USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER:
+#if defined(CONFIG_USBD_HS)
                {
-                       /* If a USB device supports both a full speed and low speed operation
-                        * we must send a Device_Qualifier descriptor here
-                        */
-                       return -1;
+                       struct usb_qualifier_descriptor *qualifier_descriptor =
+                               device->qualifier_descriptor;
+
+                       if (!qualifier_descriptor)
+                               return -1;
+
+                       /* copy descriptor for this device */
+                       copy_config(urb, qualifier_descriptor,
+                                       sizeof(struct usb_qualifier_descriptor),
+                                       max);
+
                }
+               dbg_ep0(3, "copied qualifier descriptor, actual_length: 0x%x",
+                               urb->actual_length);
+#else
+               return -1;
+#endif
+               break;
+
        default:
                return -1;
        }