X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fusb%2Fgadget%2Fep0.c;h=4ba2f3d99fd67861bc1d9fee5bba71b69315d3d0;hb=12d0b8f5f07b76d7447d60f7528d578233553909;hp=2b4ec44e161768b2e6e5fb3eeccda344ae524325;hpb=2731b9a86685190d26b1883f27afda5ac8e1a313;p=u-boot diff --git a/drivers/usb/gadget/ep0.c b/drivers/usb/gadget/ep0.c index 2b4ec44e16..4ba2f3d99f 100644 --- a/drivers/usb/gadget/ep0.c +++ b/drivers/usb/gadget/ep0.c @@ -16,20 +16,7 @@ * Tom Rushworth , * Bruce Balden * - * 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+ */ /* @@ -184,7 +171,6 @@ static int ep0_get_descriptor (struct usb_device_instance *device, int index) { int port = 0; /* XXX compound device */ - char *cp; /*dbg_ep0(3, "max: %x type: %x index: %x", max, descriptor_type, index); */ @@ -196,7 +182,6 @@ static int ep0_get_descriptor (struct usb_device_instance *device, /* setup tx urb */ urb->actual_length = 0; - cp = (char*)urb->buffer; dbg_ep0 (2, "%s", USBD_DEVICE_DESCRIPTORS (descriptor_type)); @@ -330,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); @@ -340,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; }