Lines Matching +full:short +full:- +full:descriptor
1 // SPDX-License-Identifier: GPL-2.0
34 /* Find the next descriptor of type dt1 or dt2 */ in find_next_descriptor()
37 if (h->bDescriptorType == dt1 || h->bDescriptorType == dt2) in find_next_descriptor()
39 buffer += h->bLength; in find_next_descriptor()
40 size -= h->bLength; in find_next_descriptor()
48 return buffer - buffer0; in find_next_descriptor()
58 * The SuperSpeedPlus Isoc endpoint companion descriptor immediately in usb_parse_ssp_isoc_endpoint_companion()
59 * follows the SuperSpeed Endpoint Companion descriptor in usb_parse_ssp_isoc_endpoint_companion()
62 if (desc->bDescriptorType != USB_DT_SSP_ISOC_ENDPOINT_COMP || in usb_parse_ssp_isoc_endpoint_companion()
66 cfgno, inum, asnum, ep->desc.bEndpointAddress); in usb_parse_ssp_isoc_endpoint_companion()
69 memcpy(&ep->ssp_isoc_ep_comp, desc, USB_DT_SSP_ISOC_EP_COMP_SIZE); in usb_parse_ssp_isoc_endpoint_companion()
79 /* The SuperSpeed endpoint companion descriptor is supposed to in usb_parse_ss_endpoint_companion()
80 * be the first thing immediately following the endpoint descriptor. in usb_parse_ss_endpoint_companion()
84 if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP || in usb_parse_ss_endpoint_companion()
89 cfgno, inum, asnum, ep->desc.bEndpointAddress); in usb_parse_ss_endpoint_companion()
98 ep->ss_ep_comp.bLength = USB_DT_SS_EP_COMP_SIZE; in usb_parse_ss_endpoint_companion()
99 ep->ss_ep_comp.bDescriptorType = USB_DT_SS_ENDPOINT_COMP; in usb_parse_ss_endpoint_companion()
100 if (usb_endpoint_xfer_isoc(&ep->desc) || in usb_parse_ss_endpoint_companion()
101 usb_endpoint_xfer_int(&ep->desc)) in usb_parse_ss_endpoint_companion()
102 ep->ss_ep_comp.wBytesPerInterval = in usb_parse_ss_endpoint_companion()
103 ep->desc.wMaxPacketSize; in usb_parse_ss_endpoint_companion()
106 buffer += desc->bLength; in usb_parse_ss_endpoint_companion()
107 size -= desc->bLength; in usb_parse_ss_endpoint_companion()
108 memcpy(&ep->ss_ep_comp, desc, USB_DT_SS_EP_COMP_SIZE); in usb_parse_ss_endpoint_companion()
111 if (usb_endpoint_xfer_control(&ep->desc) && desc->bMaxBurst != 0) { in usb_parse_ss_endpoint_companion()
114 "setting to zero\n", desc->bMaxBurst, in usb_parse_ss_endpoint_companion()
115 cfgno, inum, asnum, ep->desc.bEndpointAddress); in usb_parse_ss_endpoint_companion()
116 ep->ss_ep_comp.bMaxBurst = 0; in usb_parse_ss_endpoint_companion()
117 } else if (desc->bMaxBurst > 15) { in usb_parse_ss_endpoint_companion()
120 "setting to 15\n", desc->bMaxBurst, in usb_parse_ss_endpoint_companion()
121 cfgno, inum, asnum, ep->desc.bEndpointAddress); in usb_parse_ss_endpoint_companion()
122 ep->ss_ep_comp.bMaxBurst = 15; in usb_parse_ss_endpoint_companion()
125 if ((usb_endpoint_xfer_control(&ep->desc) || in usb_parse_ss_endpoint_companion()
126 usb_endpoint_xfer_int(&ep->desc)) && in usb_parse_ss_endpoint_companion()
127 desc->bmAttributes != 0) { in usb_parse_ss_endpoint_companion()
131 usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk", in usb_parse_ss_endpoint_companion()
132 desc->bmAttributes, in usb_parse_ss_endpoint_companion()
133 cfgno, inum, asnum, ep->desc.bEndpointAddress); in usb_parse_ss_endpoint_companion()
134 ep->ss_ep_comp.bmAttributes = 0; in usb_parse_ss_endpoint_companion()
135 } else if (usb_endpoint_xfer_bulk(&ep->desc) && in usb_parse_ss_endpoint_companion()
136 desc->bmAttributes > 16) { in usb_parse_ss_endpoint_companion()
140 cfgno, inum, asnum, ep->desc.bEndpointAddress); in usb_parse_ss_endpoint_companion()
141 ep->ss_ep_comp.bmAttributes = 16; in usb_parse_ss_endpoint_companion()
142 } else if (usb_endpoint_xfer_isoc(&ep->desc) && in usb_parse_ss_endpoint_companion()
143 !USB_SS_SSP_ISOC_COMP(desc->bmAttributes) && in usb_parse_ss_endpoint_companion()
144 USB_SS_MULT(desc->bmAttributes) > 3) { in usb_parse_ss_endpoint_companion()
148 USB_SS_MULT(desc->bmAttributes), in usb_parse_ss_endpoint_companion()
149 cfgno, inum, asnum, ep->desc.bEndpointAddress); in usb_parse_ss_endpoint_companion()
150 ep->ss_ep_comp.bmAttributes = 2; in usb_parse_ss_endpoint_companion()
153 if (usb_endpoint_xfer_isoc(&ep->desc)) in usb_parse_ss_endpoint_companion()
154 max_tx = (desc->bMaxBurst + 1) * in usb_parse_ss_endpoint_companion()
155 (USB_SS_MULT(desc->bmAttributes)) * in usb_parse_ss_endpoint_companion()
156 usb_endpoint_maxp(&ep->desc); in usb_parse_ss_endpoint_companion()
157 else if (usb_endpoint_xfer_int(&ep->desc)) in usb_parse_ss_endpoint_companion()
158 max_tx = usb_endpoint_maxp(&ep->desc) * in usb_parse_ss_endpoint_companion()
159 (desc->bMaxBurst + 1); in usb_parse_ss_endpoint_companion()
162 if (le16_to_cpu(desc->wBytesPerInterval) > max_tx) { in usb_parse_ss_endpoint_companion()
166 usb_endpoint_xfer_isoc(&ep->desc) ? "Isoc" : "Int", in usb_parse_ss_endpoint_companion()
167 le16_to_cpu(desc->wBytesPerInterval), in usb_parse_ss_endpoint_companion()
168 cfgno, inum, asnum, ep->desc.bEndpointAddress, in usb_parse_ss_endpoint_companion()
170 ep->ss_ep_comp.wBytesPerInterval = cpu_to_le16(max_tx); in usb_parse_ss_endpoint_companion()
172 /* Parse a possible SuperSpeedPlus isoc ep companion descriptor */ in usb_parse_ss_endpoint_companion()
173 if (usb_endpoint_xfer_isoc(&ep->desc) && in usb_parse_ss_endpoint_companion()
174 USB_SS_SSP_ISOC_COMP(desc->bmAttributes)) in usb_parse_ss_endpoint_companion()
179 static const unsigned short low_speed_maxpacket_maxes[4] = {
185 static const unsigned short full_speed_maxpacket_maxes[4] = {
191 static const unsigned short high_speed_maxpacket_maxes[4] = {
199 static const unsigned short super_speed_maxpacket_maxes[4] = {
209 if (e1->bEndpointAddress == e2->bEndpointAddress) in endpoint_is_duplicate()
232 for (i = 0; i < config->desc.bNumInterfaces; ++i) { in config_endpoint_is_duplicate()
233 intfc = config->intf_cache[i]; in config_endpoint_is_duplicate()
235 for (j = 0; j < intfc->num_altsetting; ++j) { in config_endpoint_is_duplicate()
236 alt = &intfc->altsetting[j]; in config_endpoint_is_duplicate()
238 if (alt->desc.bInterfaceNumber == inum && in config_endpoint_is_duplicate()
239 alt->desc.bAlternateSetting != asnum) in config_endpoint_is_duplicate()
242 for (k = 0; k < alt->desc.bNumEndpoints; ++k) { in config_endpoint_is_duplicate()
243 epd = &alt->endpoint[k].desc; in config_endpoint_is_duplicate()
265 const unsigned short *maxpacket_maxes; in usb_parse_endpoint()
268 buffer += d->bLength; in usb_parse_endpoint()
269 size -= d->bLength; in usb_parse_endpoint()
271 if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) in usb_parse_endpoint()
273 else if (d->bLength >= USB_DT_ENDPOINT_SIZE) in usb_parse_endpoint()
277 "invalid endpoint descriptor of length %d, skipping\n", in usb_parse_endpoint()
278 cfgno, inum, asnum, d->bLength); in usb_parse_endpoint()
282 i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK; in usb_parse_endpoint()
286 cfgno, inum, asnum, d->bEndpointAddress); in usb_parse_endpoint()
291 if (ifp->desc.bNumEndpoints >= num_ep) in usb_parse_endpoint()
297 cfgno, inum, asnum, d->bEndpointAddress); in usb_parse_endpoint()
302 if (udev->quirks & USB_QUIRK_ENDPOINT_IGNORE) { in usb_parse_endpoint()
306 d->bEndpointAddress); in usb_parse_endpoint()
311 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; in usb_parse_endpoint()
312 ++ifp->desc.bNumEndpoints; in usb_parse_endpoint()
314 memcpy(&endpoint->desc, d, n); in usb_parse_endpoint()
315 INIT_LIST_HEAD(&endpoint->urb_list); in usb_parse_endpoint()
325 switch (udev->speed) { in usb_parse_endpoint()
330 * Many device manufacturers are using full-speed in usb_parse_endpoint()
331 * bInterval values in high-speed interrupt endpoint in usb_parse_endpoint()
333 * 8-ms default value otherwise. in usb_parse_endpoint()
335 n = fls(d->bInterval*8); in usb_parse_endpoint()
337 n = 7; /* 8 ms = 2^(7-1) uframes */ in usb_parse_endpoint()
346 if (udev->quirks & USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL) { in usb_parse_endpoint()
347 n = clamp(fls(d->bInterval) + 3, i, j); in usb_parse_endpoint()
354 if (udev->quirks & USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL) { in usb_parse_endpoint()
355 n = clamp(fls(d->bInterval), i, j); in usb_parse_endpoint()
361 * For low-speed, 10 ms is the official minimum. in usb_parse_endpoint()
371 switch (udev->speed) { in usb_parse_endpoint()
373 n = 7; /* 8 ms = 2^(7-1) uframes */ in usb_parse_endpoint()
376 n = 4; /* 8 ms = 2^(4-1) frames */ in usb_parse_endpoint()
380 if (d->bInterval < i || d->bInterval > j) { in usb_parse_endpoint()
385 d->bEndpointAddress, d->bInterval, n); in usb_parse_endpoint()
386 endpoint->desc.bInterval = n; in usb_parse_endpoint()
389 /* Some buggy low-speed devices have Bulk endpoints, which is in usb_parse_endpoint()
393 if (udev->speed == USB_SPEED_LOW && usb_endpoint_xfer_bulk(d)) { in usb_parse_endpoint()
396 cfgno, inum, asnum, d->bEndpointAddress); in usb_parse_endpoint()
397 endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT; in usb_parse_endpoint()
398 endpoint->desc.bInterval = 1; in usb_parse_endpoint()
399 if (usb_endpoint_maxp(&endpoint->desc) > 8) in usb_parse_endpoint()
400 endpoint->desc.wMaxPacketSize = cpu_to_le16(8); in usb_parse_endpoint()
406 * the USB-2 spec requires such endpoints to have wMaxPacketSize = 0 in usb_parse_endpoint()
409 maxp = usb_endpoint_maxp(&endpoint->desc); in usb_parse_endpoint()
412 cfgno, inum, asnum, d->bEndpointAddress); in usb_parse_endpoint()
417 switch (udev->speed) { in usb_parse_endpoint()
439 j = maxpacket_maxes[usb_endpoint_type(&endpoint->desc)]; in usb_parse_endpoint()
443 cfgno, inum, asnum, d->bEndpointAddress, maxp, j); in usb_parse_endpoint()
445 endpoint->desc.wMaxPacketSize = cpu_to_le16(i | maxp); in usb_parse_endpoint()
453 if (udev->speed == USB_SPEED_HIGH && usb_endpoint_xfer_bulk(d)) { in usb_parse_endpoint()
457 cfgno, inum, asnum, d->bEndpointAddress, in usb_parse_endpoint()
461 /* Parse a possible SuperSpeed endpoint companion descriptor */ in usb_parse_endpoint()
462 if (udev->speed >= USB_SPEED_SUPER) in usb_parse_endpoint()
467 * find the next endpoint or interface descriptor */ in usb_parse_endpoint()
468 endpoint->extra = buffer; in usb_parse_endpoint()
471 endpoint->extralen = i; in usb_parse_endpoint()
472 retval = buffer - buffer0 + i; in usb_parse_endpoint()
474 dev_dbg(ddev, "skipped %d descriptor%s after %s\n", in usb_parse_endpoint()
481 return buffer - buffer0 + i; in usb_parse_endpoint()
489 for (j = 0; j < intfc->num_altsetting; j++) { in usb_release_interface_cache()
490 struct usb_host_interface *alt = &intfc->altsetting[j]; in usb_release_interface_cache()
492 kfree(alt->endpoint); in usb_release_interface_cache()
493 kfree(alt->string); in usb_release_interface_cache()
512 buffer += d->bLength; in usb_parse_interface()
513 size -= d->bLength; in usb_parse_interface()
515 if (d->bLength < USB_DT_INTERFACE_SIZE) in usb_parse_interface()
520 inum = d->bInterfaceNumber; in usb_parse_interface()
521 for (i = 0; i < config->desc.bNumInterfaces; ++i) { in usb_parse_interface()
523 intfc = config->intf_cache[i]; in usb_parse_interface()
527 if (!intfc || intfc->num_altsetting >= nalts[i]) in usb_parse_interface()
531 asnum = d->bAlternateSetting; in usb_parse_interface()
532 for ((i = 0, alt = &intfc->altsetting[0]); in usb_parse_interface()
533 i < intfc->num_altsetting; in usb_parse_interface()
535 if (alt->desc.bAlternateSetting == asnum) { in usb_parse_interface()
536 dev_warn(ddev, "Duplicate descriptor for config %d " in usb_parse_interface()
543 ++intfc->num_altsetting; in usb_parse_interface()
544 memcpy(&alt->desc, d, USB_DT_INTERFACE_SIZE); in usb_parse_interface()
547 * find the first endpoint or interface descriptor */ in usb_parse_interface()
548 alt->extra = buffer; in usb_parse_interface()
551 alt->extralen = i; in usb_parse_interface()
553 dev_dbg(ddev, "skipped %d descriptor%s after %s\n", in usb_parse_interface()
556 size -= i; in usb_parse_interface()
559 num_ep = num_ep_orig = alt->desc.bNumEndpoints; in usb_parse_interface()
560 alt->desc.bNumEndpoints = 0; /* Use as a counter */ in usb_parse_interface()
571 alt->endpoint = kzalloc(len, GFP_KERNEL); in usb_parse_interface()
572 if (!alt->endpoint) in usb_parse_interface()
573 return -ENOMEM; in usb_parse_interface()
579 if (((struct usb_descriptor_header *) buffer)->bDescriptorType in usb_parse_interface()
589 size -= retval; in usb_parse_interface()
594 "endpoint descriptor%s, different from the interface " in usb_parse_interface()
595 "descriptor's value: %d\n", in usb_parse_interface()
597 return buffer - buffer0; in usb_parse_interface()
602 return buffer - buffer0 + i; in usb_parse_interface()
608 struct device *ddev = &dev->dev; in usb_parse_configuration()
621 memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE); in usb_parse_configuration()
622 nintf = nintf_orig = config->desc.bNumInterfaces; in usb_parse_configuration()
623 config->desc.bNumInterfaces = 0; // Adjusted later in usb_parse_configuration()
625 if (config->desc.bDescriptorType != USB_DT_CONFIG || in usb_parse_configuration()
626 config->desc.bLength < USB_DT_CONFIG_SIZE || in usb_parse_configuration()
627 config->desc.bLength > size) { in usb_parse_configuration()
628 dev_err(ddev, "invalid descriptor for config index %d: " in usb_parse_configuration()
630 config->desc.bDescriptorType, config->desc.bLength); in usb_parse_configuration()
631 return -EINVAL; in usb_parse_configuration()
633 cfgno = config->desc.bConfigurationValue; in usb_parse_configuration()
635 buffer += config->desc.bLength; in usb_parse_configuration()
636 size -= config->desc.bLength; in usb_parse_configuration()
650 (buffer2 += header->bLength, size2 -= header->bLength)) { in usb_parse_configuration()
653 dev_warn(ddev, "config %d descriptor has %d excess " in usb_parse_configuration()
660 if ((header->bLength > size2) || (header->bLength < 2)) { in usb_parse_configuration()
661 dev_warn(ddev, "config %d has an invalid descriptor " in usb_parse_configuration()
663 cfgno, header->bLength); in usb_parse_configuration()
667 if (header->bDescriptorType == USB_DT_INTERFACE) { in usb_parse_configuration()
672 if (d->bLength < USB_DT_INTERFACE_SIZE) { in usb_parse_configuration()
674 "interface descriptor of length %d, " in usb_parse_configuration()
675 "skipping\n", cfgno, d->bLength); in usb_parse_configuration()
679 inum = d->bInterfaceNumber; in usb_parse_configuration()
681 if ((dev->quirks & USB_QUIRK_HONOR_BNUMINTERFACES) && in usb_parse_configuration()
693 cfgno, inum, nintf_orig - 1); in usb_parse_configuration()
710 } else if (header->bDescriptorType == in usb_parse_configuration()
715 if (d->bLength < USB_DT_INTERFACE_ASSOCIATION_SIZE) { in usb_parse_configuration()
717 "config %d has an invalid interface association descriptor of length %d, skipping\n", in usb_parse_configuration()
718 cfgno, d->bLength); in usb_parse_configuration()
728 config->intf_assoc[iad_num] = d; in usb_parse_configuration()
732 } else if (header->bDescriptorType == USB_DT_DEVICE || in usb_parse_configuration()
733 header->bDescriptorType == USB_DT_CONFIG) in usb_parse_configuration()
735 "descriptor of type 0x%X, skipping\n", in usb_parse_configuration()
736 cfgno, header->bDescriptorType); in usb_parse_configuration()
739 size = buffer2 - buffer; in usb_parse_configuration()
740 config->desc.wTotalLength = cpu_to_le16(buffer2 - buffer0); in usb_parse_configuration()
744 "the descriptor's value: %d\n", in usb_parse_configuration()
748 config->desc.bNumInterfaces = nintf = n; in usb_parse_configuration()
773 config->intf_cache[i] = intfc; in usb_parse_configuration()
775 return -ENOMEM; in usb_parse_configuration()
776 kref_init(&intfc->ref); in usb_parse_configuration()
779 /* FIXME: parse the BOS descriptor */ in usb_parse_configuration()
782 * find the first interface descriptor */ in usb_parse_configuration()
783 config->extra = buffer; in usb_parse_configuration()
786 config->extralen = i; in usb_parse_configuration()
788 dev_dbg(ddev, "skipped %d descriptor%s after %s\n", in usb_parse_configuration()
791 size -= i; in usb_parse_configuration()
801 size -= retval; in usb_parse_configuration()
806 intfc = config->intf_cache[i]; in usb_parse_configuration()
807 for (j = 0; j < intfc->num_altsetting; ++j) { in usb_parse_configuration()
808 for (n = 0; n < intfc->num_altsetting; ++n) { in usb_parse_configuration()
809 if (intfc->altsetting[n].desc. in usb_parse_configuration()
813 if (n >= intfc->num_altsetting) in usb_parse_configuration()
822 /* hub-only!! ... and only exported for reset/reinit path.
829 if (!dev->config) in usb_destroy_configuration()
832 if (dev->rawdescriptors) { in usb_destroy_configuration()
833 for (i = 0; i < dev->descriptor.bNumConfigurations; i++) in usb_destroy_configuration()
834 kfree(dev->rawdescriptors[i]); in usb_destroy_configuration()
836 kfree(dev->rawdescriptors); in usb_destroy_configuration()
837 dev->rawdescriptors = NULL; in usb_destroy_configuration()
840 for (c = 0; c < dev->descriptor.bNumConfigurations; c++) { in usb_destroy_configuration()
841 struct usb_host_config *cf = &dev->config[c]; in usb_destroy_configuration()
843 kfree(cf->string); in usb_destroy_configuration()
844 for (i = 0; i < cf->desc.bNumInterfaces; i++) { in usb_destroy_configuration()
845 if (cf->intf_cache[i]) in usb_destroy_configuration()
846 kref_put(&cf->intf_cache[i]->ref, in usb_destroy_configuration()
850 kfree(dev->config); in usb_destroy_configuration()
851 dev->config = NULL; in usb_destroy_configuration()
858 * hub-only!! ... and only in reset path, or usb_new_device()
863 struct device *ddev = &dev->dev; in usb_get_configuration()
864 int ncfg = dev->descriptor.bNumConfigurations; in usb_get_configuration()
873 dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG; in usb_get_configuration()
878 return -EINVAL; in usb_get_configuration()
882 dev->config = kzalloc(length, GFP_KERNEL); in usb_get_configuration()
883 if (!dev->config) in usb_get_configuration()
884 return -ENOMEM; in usb_get_configuration()
887 dev->rawdescriptors = kzalloc(length, GFP_KERNEL); in usb_get_configuration()
888 if (!dev->rawdescriptors) in usb_get_configuration()
889 return -ENOMEM; in usb_get_configuration()
893 return -ENOMEM; in usb_get_configuration()
896 /* We grab just the first descriptor so we know how long in usb_get_configuration()
902 "descriptor/%s: %d\n", cfgno, "start", result); in usb_get_configuration()
903 if (result != -EPIPE) in usb_get_configuration()
906 dev->descriptor.bNumConfigurations = cfgno; in usb_get_configuration()
909 dev_err(ddev, "config index %d descriptor too short " in usb_get_configuration()
912 result = -EINVAL; in usb_get_configuration()
915 length = max((int) le16_to_cpu(desc->wTotalLength), in usb_get_configuration()
921 result = -ENOMEM; in usb_get_configuration()
925 if (dev->quirks & USB_QUIRK_DELAY_INIT) in usb_get_configuration()
932 "descriptor/%s\n", cfgno, "all"); in usb_get_configuration()
937 dev_warn(ddev, "config index %d descriptor too short " in usb_get_configuration()
942 dev->rawdescriptors[cfgno] = bigbuffer; in usb_get_configuration()
945 &dev->config[cfgno], bigbuffer, length); in usb_get_configuration()
954 dev->descriptor.bNumConfigurations = cfgno; in usb_get_configuration()
961 if (dev->bos) { in usb_release_bos_descriptor()
962 kfree(dev->bos->desc); in usb_release_bos_descriptor()
963 kfree(dev->bos); in usb_release_bos_descriptor()
964 dev->bos = NULL; in usb_release_bos_descriptor()
977 /* Get BOS descriptor set */
980 struct device *ddev = &dev->dev; in usb_get_bos_descriptor()
991 return -ENOMEM; in usb_get_bos_descriptor()
993 /* Get BOS descriptor */ in usb_get_bos_descriptor()
995 if (ret < USB_DT_BOS_SIZE || bos->bLength < USB_DT_BOS_SIZE) { in usb_get_bos_descriptor()
996 dev_err(ddev, "unable to get BOS descriptor or descriptor too short\n"); in usb_get_bos_descriptor()
998 ret = -ENOMSG; in usb_get_bos_descriptor()
1003 length = bos->bLength; in usb_get_bos_descriptor()
1004 total_len = le16_to_cpu(bos->wTotalLength); in usb_get_bos_descriptor()
1005 num = bos->bNumDeviceCaps; in usb_get_bos_descriptor()
1008 return -EINVAL; in usb_get_bos_descriptor()
1010 dev->bos = kzalloc(sizeof(struct usb_host_bos), GFP_KERNEL); in usb_get_bos_descriptor()
1011 if (!dev->bos) in usb_get_bos_descriptor()
1012 return -ENOMEM; in usb_get_bos_descriptor()
1014 /* Now let's get the whole BOS descriptor set */ in usb_get_bos_descriptor()
1017 ret = -ENOMEM; in usb_get_bos_descriptor()
1020 dev->bos->desc = (struct usb_bos_descriptor *)buffer; in usb_get_bos_descriptor()
1024 dev_err(ddev, "unable to get BOS descriptor set\n"); in usb_get_bos_descriptor()
1026 ret = -ENOMSG; in usb_get_bos_descriptor()
1031 total_len -= length; in usb_get_bos_descriptor()
1037 if (total_len < sizeof(*cap) || total_len < cap->bLength) { in usb_get_bos_descriptor()
1038 dev->bos->desc->bNumDeviceCaps = i; in usb_get_bos_descriptor()
1041 cap_type = cap->bDevCapabilityType; in usb_get_bos_descriptor()
1042 length = cap->bLength; in usb_get_bos_descriptor()
1044 dev->bos->desc->bNumDeviceCaps = i; in usb_get_bos_descriptor()
1048 if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) { in usb_get_bos_descriptor()
1049 dev_warn(ddev, "descriptor type invalid, skip\n"); in usb_get_bos_descriptor()
1055 /* Wireless USB cap descriptor is handled by wusb */ in usb_get_bos_descriptor()
1058 dev->bos->ext_cap = in usb_get_bos_descriptor()
1062 dev->bos->ss_cap = in usb_get_bos_descriptor()
1067 ssac = (le32_to_cpu(ssp_cap->bmAttributes) & in usb_get_bos_descriptor()
1070 dev->bos->ssp_cap = ssp_cap; in usb_get_bos_descriptor()
1073 dev->bos->ss_id = in usb_get_bos_descriptor()
1077 dev->bos->ptm_cap = in usb_get_bos_descriptor()
1084 total_len -= length; in usb_get_bos_descriptor()
1087 dev->bos->desc->wTotalLength = cpu_to_le16(buffer - buffer0); in usb_get_bos_descriptor()