Lines Matching +full:composite +full:- +full:in

1 // SPDX-License-Identifier: GPL-2.0+
3 * composite.c - infrastructure for Composite USB Gadgets
5 * Copyright (C) 2006-2008 David Brownell
18 #include <linux/usb/composite.h>
25 * struct usb_os_string - represents OS String to be reported by a gadget
41 * The code in this file is utility code, used to build a gadget driver
44 * with the relevant device-wide data.
50 return (struct usb_gadget_strings **)uc->stash; in get_containers_gs()
54 * function_descriptors() - get function descriptors for speed
73 descriptors = f->ssp_descriptors; in function_descriptors()
78 descriptors = f->ss_descriptors; in function_descriptors()
83 descriptors = f->hs_descriptors; in function_descriptors()
88 descriptors = f->fs_descriptors; in function_descriptors()
100 * next_desc() - advance to the next desc_type descriptor
113 if ((*t)->bDescriptorType == desc_type) in next_desc()
120 * for_each_desc() - iterate over desc_type descriptors in the
131 * config_ep_by_speed_and_alt() - configures the given endpoint
141 * endpoint according to gadget speed and saves it in the
143 * assigned to it - overwrites it with currently corresponding
166 return -EIO; in config_ep_by_speed_and_alt()
169 switch (g->speed) { in config_ep_by_speed_and_alt()
172 if (f->ssp_descriptors) { in config_ep_by_speed_and_alt()
173 speed_desc = f->ssp_descriptors; in config_ep_by_speed_and_alt()
182 if (f->ss_descriptors) { in config_ep_by_speed_and_alt()
183 speed_desc = f->ss_descriptors; in config_ep_by_speed_and_alt()
192 if (f->hs_descriptors) { in config_ep_by_speed_and_alt()
193 speed_desc = f->hs_descriptors; in config_ep_by_speed_and_alt()
200 speed_desc = f->fs_descriptors; in config_ep_by_speed_and_alt()
207 f->name); in config_ep_by_speed_and_alt()
213 if (int_desc->bAlternateSetting == alt) { in config_ep_by_speed_and_alt()
218 return -EIO; in config_ep_by_speed_and_alt()
224 if (chosen_desc->bEndpointAddress == _ep->address) in config_ep_by_speed_and_alt()
227 return -EIO; in config_ep_by_speed_and_alt()
231 _ep->maxpacket = usb_endpoint_maxp(chosen_desc); in config_ep_by_speed_and_alt()
232 _ep->desc = chosen_desc; in config_ep_by_speed_and_alt()
233 _ep->comp_desc = NULL; in config_ep_by_speed_and_alt()
234 _ep->maxburst = 0; in config_ep_by_speed_and_alt()
235 _ep->mult = 1; in config_ep_by_speed_and_alt()
237 if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) || in config_ep_by_speed_and_alt()
238 usb_endpoint_xfer_int(_ep->desc))) in config_ep_by_speed_and_alt()
239 _ep->mult = usb_endpoint_maxp_mult(_ep->desc); in config_ep_by_speed_and_alt()
250 (comp_desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP)) in config_ep_by_speed_and_alt()
251 return -EIO; in config_ep_by_speed_and_alt()
252 _ep->comp_desc = comp_desc; in config_ep_by_speed_and_alt()
253 if (g->speed >= USB_SPEED_SUPER) { in config_ep_by_speed_and_alt()
254 switch (usb_endpoint_type(_ep->desc)) { in config_ep_by_speed_and_alt()
257 _ep->mult = (comp_desc->bmAttributes & 0x3) + 1; in config_ep_by_speed_and_alt()
261 _ep->maxburst = comp_desc->bMaxBurst + 1; in config_ep_by_speed_and_alt()
264 if (comp_desc->bMaxBurst != 0) in config_ep_by_speed_and_alt()
266 _ep->maxburst = 1; in config_ep_by_speed_and_alt()
275 * config_ep_by_speed() - configures the given endpoint
284 * endpoint according to gadget speed and saves it in the
286 * assigned to it - overwrites it with currently corresponding
301 * usb_add_function() - add a function to a configuration
317 int value = -EINVAL; in usb_add_function()
319 DBG(config->cdev, "adding '%s'/%p to config '%s'/%p\n", in usb_add_function()
320 function->name, function, in usb_add_function()
321 config->label, config); in usb_add_function()
323 if (!function->set_alt || !function->disable) in usb_add_function()
326 function->config = config; in usb_add_function()
327 list_add_tail(&function->list, &config->functions); in usb_add_function()
329 if (function->bind_deactivated) { in usb_add_function()
335 /* REVISIT *require* function->bind? */ in usb_add_function()
336 if (function->bind) { in usb_add_function()
337 value = function->bind(config, function); in usb_add_function()
339 list_del(&function->list); in usb_add_function()
340 function->config = NULL; in usb_add_function()
350 if (!config->fullspeed && function->fs_descriptors) in usb_add_function()
351 config->fullspeed = true; in usb_add_function()
352 if (!config->highspeed && function->hs_descriptors) in usb_add_function()
353 config->highspeed = true; in usb_add_function()
354 if (!config->superspeed && function->ss_descriptors) in usb_add_function()
355 config->superspeed = true; in usb_add_function()
356 if (!config->superspeed_plus && function->ssp_descriptors) in usb_add_function()
357 config->superspeed_plus = true; in usb_add_function()
361 DBG(config->cdev, "adding '%s'/%p --> %d\n", in usb_add_function()
362 function->name, function, value); in usb_add_function()
369 if (f->disable) in usb_remove_function()
370 f->disable(f); in usb_remove_function()
372 bitmap_zero(f->endpoints, 32); in usb_remove_function()
373 list_del(&f->list); in usb_remove_function()
374 if (f->unbind) in usb_remove_function()
375 f->unbind(c, f); in usb_remove_function()
377 if (f->bind_deactivated) in usb_remove_function()
383 * usb_function_deactivate - prevent function and gadget enumeration
403 struct usb_composite_dev *cdev = function->config->cdev; in usb_function_deactivate()
407 spin_lock_irqsave(&cdev->lock, flags); in usb_function_deactivate()
409 if (cdev->deactivations == 0) { in usb_function_deactivate()
410 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_deactivate()
411 status = usb_gadget_deactivate(cdev->gadget); in usb_function_deactivate()
412 spin_lock_irqsave(&cdev->lock, flags); in usb_function_deactivate()
415 cdev->deactivations++; in usb_function_deactivate()
417 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_deactivate()
423 * usb_function_activate - allow function and gadget enumeration
434 struct usb_composite_dev *cdev = function->config->cdev; in usb_function_activate()
438 spin_lock_irqsave(&cdev->lock, flags); in usb_function_activate()
440 if (WARN_ON(cdev->deactivations == 0)) in usb_function_activate()
441 status = -EINVAL; in usb_function_activate()
443 cdev->deactivations--; in usb_function_activate()
444 if (cdev->deactivations == 0) { in usb_function_activate()
445 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_activate()
446 status = usb_gadget_activate(cdev->gadget); in usb_function_activate()
447 spin_lock_irqsave(&cdev->lock, flags); in usb_function_activate()
451 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_activate()
457 * usb_interface_id() - allocate an unused interface ID
464 * ID in interface, association, CDC union, and other descriptors. It
467 * also be class-specific or vendor-specific requests to handle.
472 * identifiers are configuration-specific, functions used in more than
473 * one configuration (or more than once in a given configuration) need
476 * Returns the interface ID which was allocated; or -ENODEV if no
482 unsigned id = config->next_interface_id; in usb_interface_id()
485 config->interface[id] = function; in usb_interface_id()
486 config->next_interface_id = id + 1; in usb_interface_id()
489 return -ENODEV; in usb_interface_id()
498 if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)) in encode_bMaxPower()
499 val = c->MaxPower; in encode_bMaxPower()
523 len = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE; in config_buf()
526 c->bLength = USB_DT_CONFIG_SIZE; in config_buf()
527 c->bDescriptorType = type; in config_buf()
529 c->bNumInterfaces = config->next_interface_id; in config_buf()
530 c->bConfigurationValue = config->bConfigurationValue; in config_buf()
531 c->iConfiguration = config->iConfiguration; in config_buf()
532 c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; in config_buf()
533 c->bMaxPower = encode_bMaxPower(speed, config); in config_buf()
536 if (config->descriptors) { in config_buf()
538 config->descriptors); in config_buf()
541 len -= status; in config_buf()
546 list_for_each_entry(f, &config->functions, list) { in config_buf()
556 len -= status; in config_buf()
560 len = next - buf; in config_buf()
561 c->wTotalLength = cpu_to_le16(len); in config_buf()
567 struct usb_gadget *gadget = cdev->gadget; in config_desc()
573 if (gadget->speed >= USB_SPEED_SUPER) in config_desc()
574 speed = gadget->speed; in config_desc()
577 if (gadget->speed == USB_SPEED_HIGH) in config_desc()
589 pos = &cdev->configs; in config_desc()
590 c = cdev->os_desc_config; in config_desc()
594 while ((pos = pos->next) != &cdev->configs) { in config_desc()
598 if (c == cdev->os_desc_config) in config_desc()
605 if (!c->superspeed_plus) in config_desc()
609 if (!c->superspeed) in config_desc()
613 if (!c->highspeed) in config_desc()
617 if (!c->fullspeed) in config_desc()
622 return config_buf(c, speed, cdev->req->buf, type); in config_desc()
623 w_value--; in config_desc()
625 return -EINVAL; in config_desc()
630 struct usb_gadget *gadget = cdev->gadget; in count_configs()
638 if (gadget->speed == USB_SPEED_HIGH) in count_configs()
640 if (gadget->speed == USB_SPEED_SUPER) in count_configs()
642 if (gadget->speed == USB_SPEED_SUPER_PLUS) in count_configs()
647 list_for_each_entry(c, &cdev->configs, list) { in count_configs()
650 if (!c->superspeed_plus) in count_configs()
653 if (!c->superspeed) in count_configs()
656 if (!c->highspeed) in count_configs()
659 if (!c->fullspeed) in count_configs()
668 * bos_desc() - prepares the BOS descriptor.
680 struct usb_bos_descriptor *bos = cdev->req->buf; in bos_desc()
683 bos->bLength = USB_DT_BOS_SIZE; in bos_desc()
684 bos->bDescriptorType = USB_DT_BOS; in bos_desc()
686 bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE); in bos_desc()
687 bos->bNumDeviceCaps = 0; in bos_desc()
690 if (cdev->gadget->ops->get_config_params) { in bos_desc()
691 cdev->gadget->ops->get_config_params(cdev->gadget, in bos_desc()
714 * and shall support LPM when operating in USB2.0 HS mode. in bos_desc()
716 usb_ext = cdev->req->buf + le16_to_cpu(bos->wTotalLength); in bos_desc()
717 bos->bNumDeviceCaps++; in bos_desc()
718 le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE); in bos_desc()
719 usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE; in bos_desc()
720 usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY; in bos_desc()
721 usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT; in bos_desc()
722 usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | in bos_desc()
729 if (gadget_is_superspeed(cdev->gadget)) { in bos_desc()
732 ss_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength); in bos_desc()
733 bos->bNumDeviceCaps++; in bos_desc()
734 le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE); in bos_desc()
735 ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE; in bos_desc()
736 ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY; in bos_desc()
737 ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE; in bos_desc()
738 ss_cap->bmAttributes = 0; /* LTM is not supported yet */ in bos_desc()
739 ss_cap->wSpeedSupported = cpu_to_le16(USB_LOW_SPEED_OPERATION | in bos_desc()
743 ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION; in bos_desc()
744 ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat; in bos_desc()
745 ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat; in bos_desc()
749 if (gadget_is_superspeed_plus(cdev->gadget)) { in bos_desc()
755 if (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x2) in bos_desc()
762 ssic = (ssac + 1) / 2 - 1; in bos_desc()
764 ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength); in bos_desc()
765 bos->bNumDeviceCaps++; in bos_desc()
767 le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SSP_CAP_SIZE(ssac)); in bos_desc()
768 ssp_cap->bLength = USB_DT_USB_SSP_CAP_SIZE(ssac); in bos_desc()
769 ssp_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY; in bos_desc()
770 ssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE; in bos_desc()
771 ssp_cap->bReserved = 0; in bos_desc()
772 ssp_cap->wReserved = 0; in bos_desc()
774 ssp_cap->bmAttributes = in bos_desc()
778 ssp_cap->wFunctionalitySupport = in bos_desc()
786 * - SSID 0 for symmetric RX/TX sublink speed of 10 Gbps. in bos_desc()
789 * - SSID 0 for symmetric RX/TX sublink speed of 5 Gbps. in bos_desc()
792 * - SSID 0 for symmetric RX/TX sublink speed of 5 Gbps. in bos_desc()
793 * - SSID 1 for symmetric RX/TX sublink speed of 10 Gbps. in bos_desc()
802 if (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x1 || in bos_desc()
803 cdev->gadget->max_ssp_rate == USB_SSP_GEN_UNKNOWN) in bos_desc()
813 ssp_cap->bmSublinkSpeedAttr[i] = in bos_desc()
824 return le16_to_cpu(bos->wTotalLength); in bos_desc()
829 struct usb_qualifier_descriptor *qual = cdev->req->buf; in device_qual()
831 qual->bLength = sizeof(*qual); in device_qual()
832 qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER; in device_qual()
834 qual->bcdUSB = cdev->desc.bcdUSB; in device_qual()
835 qual->bDeviceClass = cdev->desc.bDeviceClass; in device_qual()
836 qual->bDeviceSubClass = cdev->desc.bDeviceSubClass; in device_qual()
837 qual->bDeviceProtocol = cdev->desc.bDeviceProtocol; in device_qual()
839 qual->bMaxPacketSize0 = cdev->gadget->ep0->maxpacket; in device_qual()
840 qual->bNumConfigurations = count_configs(cdev, USB_DT_DEVICE_QUALIFIER); in device_qual()
841 qual->bRESERVED = 0; in device_qual()
844 /*-------------------------------------------------------------------------*/
852 list_for_each_entry(f, &cdev->config->functions, list) { in reset_config()
853 if (f->disable) in reset_config()
854 f->disable(f); in reset_config()
856 bitmap_zero(f->endpoints, 32); in reset_config()
858 cdev->config = NULL; in reset_config()
859 cdev->delayed_status = 0; in reset_config()
865 struct usb_gadget *gadget = cdev->gadget; in set_config()
867 int result = -EINVAL; in set_config()
872 list_for_each_entry(iter, &cdev->configs, list) { in set_config()
873 if (iter->bConfigurationValue != number) in set_config()
880 if (cdev->config) in set_config()
888 } else { /* Zero configuration value - need to reset the config */ in set_config()
889 if (cdev->config) in set_config()
895 usb_speed_string(gadget->speed), in set_config()
896 number, c ? c->label : "unconfigured"); in set_config()
902 cdev->config = c; in set_config()
906 struct usb_function *f = c->interface[tmp]; in set_config()
918 descriptors = function_descriptors(f, gadget->speed); in set_config()
924 if ((*descriptors)->bDescriptorType != USB_DT_ENDPOINT) in set_config()
928 addr = ((ep->bEndpointAddress & 0x80) >> 3) in set_config()
929 | (ep->bEndpointAddress & 0x0f); in set_config()
930 set_bit(addr, f->endpoints); in set_config()
933 result = f->set_alt(f, tmp, 0); in set_config()
935 DBG(cdev, "interface %d (%s/%p) alt 0 --> %d\n", in set_config()
936 tmp, f->name, f, result); in set_config()
945 __func__, tmp, f->name); in set_config()
946 cdev->delayed_status++; in set_config()
948 cdev->delayed_status); in set_config()
953 if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)) in set_config()
954 power = c->MaxPower; in set_config()
958 if (gadget->speed < USB_SPEED_SUPER) in set_config()
969 if (result >= 0 && cdev->delayed_status) in set_config()
979 if (!config->bConfigurationValue) in usb_add_config_only()
980 return -EINVAL; in usb_add_config_only()
983 list_for_each_entry(c, &cdev->configs, list) { in usb_add_config_only()
984 if (c->bConfigurationValue == config->bConfigurationValue) in usb_add_config_only()
985 return -EBUSY; in usb_add_config_only()
988 config->cdev = cdev; in usb_add_config_only()
989 list_add_tail(&config->list, &cdev->configs); in usb_add_config_only()
991 INIT_LIST_HEAD(&config->functions); in usb_add_config_only()
992 config->next_interface_id = 0; in usb_add_config_only()
993 memset(config->interface, 0, sizeof(config->interface)); in usb_add_config_only()
1000 * usb_add_config() - add a configuration to a device.
1006 * One of the main tasks of a composite @bind() routine is to
1011 * assigns global resources including string IDs, and per-configuration
1018 int status = -EINVAL; in usb_add_config()
1024 config->bConfigurationValue, in usb_add_config()
1025 config->label, config); in usb_add_config()
1033 while (!list_empty(&config->functions)) { in usb_add_config()
1036 f = list_first_entry(&config->functions, in usb_add_config()
1038 list_del(&f->list); in usb_add_config()
1039 if (f->unbind) { in usb_add_config()
1041 f->name, f); in usb_add_config()
1042 f->unbind(config, f); in usb_add_config()
1046 list_del(&config->list); in usb_add_config()
1047 config->cdev = NULL; in usb_add_config()
1052 config->bConfigurationValue, config, in usb_add_config()
1053 config->superspeed_plus ? " superplus" : "", in usb_add_config()
1054 config->superspeed ? " super" : "", in usb_add_config()
1055 config->highspeed ? " high" : "", in usb_add_config()
1056 config->fullspeed in usb_add_config()
1057 ? (gadget_is_dualspeed(cdev->gadget) in usb_add_config()
1063 struct usb_function *f = config->interface[i]; in usb_add_config()
1068 i, f->name, f); in usb_add_config()
1072 /* set_alt(), or next bind(), sets up ep->claimed as needed */ in usb_add_config()
1073 usb_ep_autoconfig_reset(cdev->gadget); in usb_add_config()
1077 DBG(cdev, "added config '%s'/%u --> %d\n", config->label, in usb_add_config()
1078 config->bConfigurationValue, status); in usb_add_config()
1086 while (!list_empty(&config->functions)) { in remove_config()
1089 f = list_first_entry(&config->functions, in remove_config()
1094 list_del(&config->list); in remove_config()
1095 if (config->unbind) { in remove_config()
1096 DBG(cdev, "unbind config '%s'/%p\n", config->label, config); in remove_config()
1097 config->unbind(config); in remove_config()
1103 * usb_remove_config() - remove a configuration from a device.
1116 spin_lock_irqsave(&cdev->lock, flags); in usb_remove_config()
1118 if (cdev->config == config) in usb_remove_config()
1121 spin_unlock_irqrestore(&cdev->lock, flags); in usb_remove_config()
1126 /*-------------------------------------------------------------------------*/
1128 /* We support strings in multiple languages ... string descriptor zero
1142 language = cpu_to_le16(s->language); in collect_langs()
1165 if (s->language != language) in lookup_string()
1171 return -EINVAL; in lookup_string()
1177 struct usb_composite_driver *composite = cdev->driver; in get_string() local
1194 s->bDescriptorType = USB_DT_STRING; in get_string()
1196 sp = composite->strings; in get_string()
1198 collect_langs(sp, s->wData); in get_string()
1200 list_for_each_entry(c, &cdev->configs, list) { in get_string()
1201 sp = c->strings; in get_string()
1203 collect_langs(sp, s->wData); in get_string()
1205 list_for_each_entry(f, &c->functions, list) { in get_string()
1206 sp = f->strings; in get_string()
1208 collect_langs(sp, s->wData); in get_string()
1211 list_for_each_entry(uc, &cdev->gstrings, list) { in get_string()
1215 collect_langs(sp, s->wData); in get_string()
1218 for (len = 0; len <= USB_MAX_STRING_LEN && s->wData[len]; len++) in get_string()
1221 return -EINVAL; in get_string()
1223 s->bLength = 2 * (len + 1); in get_string()
1224 return s->bLength; in get_string()
1227 if (cdev->use_os_string && language == 0 && id == OS_STRING_IDX) { in get_string()
1229 b->bLength = sizeof(*b); in get_string()
1230 b->bDescriptorType = USB_DT_STRING; in get_string()
1232 sizeof(b->qwSignature) == sizeof(cdev->qw_sign), in get_string()
1234 memcpy(&b->qwSignature, cdev->qw_sign, sizeof(b->qwSignature)); in get_string()
1235 b->bMS_VendorCode = cdev->b_vendor_code; in get_string()
1236 b->bPad = 0; in get_string()
1240 list_for_each_entry(uc, &cdev->gstrings, list) { in get_string()
1249 /* String IDs are device-scoped, so we look up each string in get_string()
1251 * simpler-is-better here. in get_string()
1253 if (composite->strings) { in get_string()
1254 len = lookup_string(composite->strings, buf, language, id); in get_string()
1258 list_for_each_entry(c, &cdev->configs, list) { in get_string()
1259 if (c->strings) { in get_string()
1260 len = lookup_string(c->strings, buf, language, id); in get_string()
1264 list_for_each_entry(f, &c->functions, list) { in get_string()
1265 if (!f->strings) in get_string()
1267 len = lookup_string(f->strings, buf, language, id); in get_string()
1272 return -EINVAL; in get_string()
1276 * usb_string_id() - allocate an unused string ID
1282 * then store that ID in the appropriate descriptors and string table.
1291 if (cdev->next_string_id < 254) { in usb_string_id()
1294 /* 255 reserved as well? -- mina86 */ in usb_string_id()
1295 cdev->next_string_id++; in usb_string_id()
1296 return cdev->next_string_id; in usb_string_id()
1298 return -ENODEV; in usb_string_id()
1303 * usb_string_ids_tab() - allocate unused string IDs in batch
1320 int next = cdev->next_string_id; in usb_string_ids_tab()
1322 for (; str->s; ++str) { in usb_string_ids_tab()
1324 return -ENODEV; in usb_string_ids_tab()
1325 str->id = ++next; in usb_string_ids_tab()
1328 cdev->next_string_id = next; in usb_string_ids_tab()
1353 return ERR_PTR(-ENOMEM); in copy_gadget_strings()
1355 stash = uc->stash; in copy_gadget_strings()
1363 gs->language = sp[n_gs]->language; in copy_gadget_strings()
1364 gs->strings = stash; in copy_gadget_strings()
1365 org_s = sp[n_gs]->strings; in copy_gadget_strings()
1370 if (org_s->s) in copy_gadget_strings()
1371 s->s = org_s->s; in copy_gadget_strings()
1373 s->s = ""; in copy_gadget_strings()
1377 s->s = NULL; in copy_gadget_strings()
1386 * usb_gstrings_attach() - attach gadget strings to a cdev and assign ids
1390 * @n_strings: number of entries in each usb_strings array (sp[]->strings)
1396 * The ->language pointer of each struct usb_gadget_strings has to contain the
1398 * For instance: sp[0] is en-US, sp[1] is es-ES. It is expected that the first
1399 * usb_string entry of es-ES contains the translation of the first usb_string
1400 * entry of en-US. Therefore both entries become the same id assign.
1415 return ERR_PTR(-EINVAL); in usb_gstrings_attach()
1422 ret = usb_string_ids_tab(cdev, n_gs[0]->strings); in usb_gstrings_attach()
1431 m_s = n_gs[0]->strings; in usb_gstrings_attach()
1432 s = n_gs[i]->strings; in usb_gstrings_attach()
1434 s->id = m_s->id; in usb_gstrings_attach()
1439 list_add_tail(&uc->list, &cdev->gstrings); in usb_gstrings_attach()
1440 return n_gs[0]->strings; in usb_gstrings_attach()
1448 * usb_string_ids_n() - allocate unused string IDs in batch
1453 * Returns the first requested ID. This ID and next @n-1 IDs are now
1454 * valid IDs. At least provided that @n is non-zero because if it
1459 * then store that ID in the appropriate descriptors and string table.
1468 unsigned next = c->next_string_id; in usb_string_ids_n()
1470 return -ENODEV; in usb_string_ids_n()
1471 c->next_string_id += n; in usb_string_ids_n()
1476 /*-------------------------------------------------------------------------*/
1482 if (req->status || req->actual != req->length) in composite_setup_complete()
1483 DBG((struct usb_composite_dev *) ep->driver_data, in composite_setup_complete()
1484 "setup complete --> %d, %d/%d\n", in composite_setup_complete()
1485 req->status, req->actual, req->length); in composite_setup_complete()
1489 * so they don't have to maintain the same ->complete() stubs. in composite_setup_complete()
1491 * Because of that, we need to check for the validity of ->context in composite_setup_complete()
1494 if (!req->context) in composite_setup_complete()
1497 cdev = req->context; in composite_setup_complete()
1499 if (cdev->req == req) in composite_setup_complete()
1500 cdev->setup_pending = false; in composite_setup_complete()
1501 else if (cdev->os_desc_req == req) in composite_setup_complete()
1502 cdev->os_desc_pending = false; in composite_setup_complete()
1512 ret = usb_ep_queue(cdev->gadget->ep0, req, gfp_flags); in composite_ep0_queue()
1514 if (cdev->req == req) in composite_ep0_queue()
1515 cdev->setup_pending = true; in composite_ep0_queue()
1516 else if (cdev->os_desc_req == req) in composite_ep0_queue()
1517 cdev->os_desc_pending = true; in composite_ep0_queue()
1530 for (i = 0; i < c->next_interface_id; ++i) { in count_ext_compat()
1534 f = c->interface[i]; in count_ext_compat()
1535 for (j = 0; j < f->os_desc_n; ++j) { in count_ext_compat()
1538 if (i != f->os_desc_table[j].if_id) in count_ext_compat()
1540 d = f->os_desc_table[j].os_desc; in count_ext_compat()
1541 if (d && d->ext_compat_id) in count_ext_compat()
1555 for (i = 0; i < c->next_interface_id; ++i) { in fill_ext_compat()
1559 f = c->interface[i]; in fill_ext_compat()
1560 for (j = 0; j < f->os_desc_n; ++j) { in fill_ext_compat()
1563 if (i != f->os_desc_table[j].if_id) in fill_ext_compat()
1565 d = f->os_desc_table[j].os_desc; in fill_ext_compat()
1566 if (d && d->ext_compat_id) { in fill_ext_compat()
1569 memcpy(buf, d->ext_compat_id, 16); in fill_ext_compat()
1590 f = c->interface[interface]; in count_ext_prop()
1591 for (j = 0; j < f->os_desc_n; ++j) { in count_ext_prop()
1594 if (interface != f->os_desc_table[j].if_id) in count_ext_prop()
1596 d = f->os_desc_table[j].os_desc; in count_ext_prop()
1597 if (d && d->ext_compat_id) in count_ext_prop()
1598 return d->ext_prop_count; in count_ext_prop()
1610 f = c->interface[interface]; in len_ext_prop()
1611 for (j = 0; j < f->os_desc_n; ++j) { in len_ext_prop()
1612 if (interface != f->os_desc_table[j].if_id) in len_ext_prop()
1614 d = f->os_desc_table[j].os_desc; in len_ext_prop()
1616 return min(res + d->ext_prop_len, 4096); in len_ext_prop()
1628 f = c->interface[interface]; in fill_ext_prop()
1631 for (j = 0; j < f->os_desc_n; ++j) { in fill_ext_prop()
1632 if (interface != f->os_desc_table[j].if_id) in fill_ext_prop()
1634 d = f->os_desc_table[j].os_desc; in fill_ext_prop()
1636 list_for_each_entry(ext_prop, &d->ext_prop, entry) { in fill_ext_prop()
1637 n = ext_prop->data_len + in fill_ext_prop()
1638 ext_prop->name_len + 14; in fill_ext_prop()
1642 usb_ext_prop_put_type(buf, ext_prop->type); in fill_ext_prop()
1643 ret = usb_ext_prop_put_name(buf, ext_prop->name, in fill_ext_prop()
1644 ext_prop->name_len); in fill_ext_prop()
1647 switch (ext_prop->type) { in fill_ext_prop()
1652 ext_prop->data, in fill_ext_prop()
1653 ext_prop->data_len); in fill_ext_prop()
1657 ext_prop->data, in fill_ext_prop()
1658 ext_prop->data_len); in fill_ext_prop()
1665 return -EINVAL; in fill_ext_prop()
1677 * not handled lower down, in hardware or the hardware driver(like
1680 * the work is in config and function specific setup.
1686 struct usb_request *req = cdev->req; in composite_setup()
1687 int value = -EOPNOTSUPP; in composite_setup()
1689 u16 w_index = le16_to_cpu(ctrl->wIndex); in composite_setup()
1691 u16 w_value = le16_to_cpu(ctrl->wValue); in composite_setup()
1692 u16 w_length = le16_to_cpu(ctrl->wLength); in composite_setup()
1698 if (ctrl->bRequestType & USB_DIR_IN) { in composite_setup()
1700 __le16 *temp = (__le16 *)&ctrl->wLength; in composite_setup()
1709 /* partial re-init of the response message; the function or the in composite_setup()
1710 * gadget might need to intercept e.g. a control-OUT completion in composite_setup()
1713 req->zero = 0; in composite_setup()
1714 req->context = cdev; in composite_setup()
1715 req->complete = composite_setup_complete; in composite_setup()
1716 req->length = 0; in composite_setup()
1717 gadget->ep0->driver_data = cdev; in composite_setup()
1720 * Don't let non-standard requests match any of the cases below in composite_setup()
1723 if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD) in composite_setup()
1726 switch (ctrl->bRequest) { in composite_setup()
1730 if (ctrl->bRequestType != USB_DIR_IN) in composite_setup()
1735 cdev->desc.bNumConfigurations = in composite_setup()
1737 cdev->desc.bMaxPacketSize0 = in composite_setup()
1738 cdev->gadget->ep0->maxpacket; in composite_setup()
1740 if (gadget->speed >= USB_SPEED_SUPER) { in composite_setup()
1741 cdev->desc.bcdUSB = cpu_to_le16(0x0320); in composite_setup()
1742 cdev->desc.bMaxPacketSize0 = 9; in composite_setup()
1744 cdev->desc.bcdUSB = cpu_to_le16(0x0210); in composite_setup()
1747 if (gadget->lpm_capable) in composite_setup()
1748 cdev->desc.bcdUSB = cpu_to_le16(0x0201); in composite_setup()
1750 cdev->desc.bcdUSB = cpu_to_le16(0x0200); in composite_setup()
1753 value = min(w_length, (u16) sizeof cdev->desc); in composite_setup()
1754 memcpy(req->buf, &cdev->desc, value); in composite_setup()
1758 gadget->speed >= USB_SPEED_SUPER) in composite_setup()
1766 gadget->speed >= USB_SPEED_SUPER) in composite_setup()
1775 value = get_string(cdev, req->buf, in composite_setup()
1782 gadget->lpm_capable) { in composite_setup()
1792 if (cdev->config) in composite_setup()
1793 config = cdev->config; in composite_setup()
1796 &cdev->configs, in composite_setup()
1801 if (gadget->otg_caps && in composite_setup()
1802 (gadget->otg_caps->otg_rev >= 0x0200)) in composite_setup()
1810 memcpy(req->buf, config->descriptors[0], value); in composite_setup()
1818 if (ctrl->bRequestType != 0) in composite_setup()
1821 if (gadget->a_hnp_support) in composite_setup()
1823 else if (gadget->a_alt_hnp_support) in composite_setup()
1828 spin_lock(&cdev->lock); in composite_setup()
1830 spin_unlock(&cdev->lock); in composite_setup()
1833 if (ctrl->bRequestType != USB_DIR_IN) in composite_setup()
1835 if (cdev->config) in composite_setup()
1836 *(u8 *)req->buf = cdev->config->bConfigurationValue; in composite_setup()
1838 *(u8 *)req->buf = 0; in composite_setup()
1844 if (ctrl->bRequestType != USB_RECIP_INTERFACE) in composite_setup()
1846 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1848 f = cdev->config->interface[intf]; in composite_setup()
1855 * as we check this in usb_add_function(). in composite_setup()
1857 if (w_value && !f->get_alt) in composite_setup()
1860 spin_lock(&cdev->lock); in composite_setup()
1861 value = f->set_alt(f, w_index, w_value); in composite_setup()
1865 __func__, intf, f->name); in composite_setup()
1866 cdev->delayed_status++; in composite_setup()
1868 cdev->delayed_status); in composite_setup()
1870 spin_unlock(&cdev->lock); in composite_setup()
1873 if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) in composite_setup()
1875 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1877 f = cdev->config->interface[intf]; in composite_setup()
1881 value = f->get_alt ? f->get_alt(f, w_index) : 0; in composite_setup()
1884 *((u8 *)req->buf) = value; in composite_setup()
1888 if (gadget_is_otg(gadget) && gadget->hnp_polling_support && in composite_setup()
1890 if (ctrl->bRequestType != (USB_DIR_IN | in composite_setup()
1893 *((u8 *)req->buf) = gadget->host_request_flag; in composite_setup()
1907 if (ctrl->bRequestType != (USB_DIR_IN | USB_RECIP_INTERFACE)) in composite_setup()
1910 put_unaligned_le16(0, req->buf); in composite_setup()
1911 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1913 f = cdev->config->interface[intf]; in composite_setup()
1916 status = f->get_status ? f->get_status(f) : 0; in composite_setup()
1919 put_unaligned_le16(status & 0x0000ffff, req->buf); in composite_setup()
1930 if (ctrl->bRequestType != (USB_DIR_OUT | USB_RECIP_INTERFACE)) in composite_setup()
1934 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1936 f = cdev->config->interface[intf]; in composite_setup()
1940 if (f->func_suspend) in composite_setup()
1941 value = f->func_suspend(f, w_index >> 8); in composite_setup()
1956 if (cdev->use_os_string && cdev->os_desc_config && in composite_setup()
1957 (ctrl->bRequestType & USB_TYPE_VENDOR) && in composite_setup()
1958 ctrl->bRequest == cdev->b_vendor_code) { in composite_setup()
1964 req = cdev->os_desc_req; in composite_setup()
1965 req->context = cdev; in composite_setup()
1966 req->complete = composite_setup_complete; in composite_setup()
1967 buf = req->buf; in composite_setup()
1968 os_desc_cfg = cdev->os_desc_config; in composite_setup()
1972 switch (ctrl->bRequestType & USB_RECIP_MASK) { in composite_setup()
1994 !os_desc_cfg->interface[interface]) in composite_setup()
2017 "non-core control req%02x.%02x v%04x i%04x l%d\n", in composite_setup()
2018 ctrl->bRequestType, ctrl->bRequest, in composite_setup()
2025 if (cdev->config) { in composite_setup()
2026 list_for_each_entry(f, &cdev->config->functions, list) in composite_setup()
2027 if (f->req_match && in composite_setup()
2028 f->req_match(f, ctrl, false)) in composite_setup()
2032 list_for_each_entry(c, &cdev->configs, list) in composite_setup()
2033 list_for_each_entry(f, &c->functions, list) in composite_setup()
2034 if (f->req_match && in composite_setup()
2035 f->req_match(f, ctrl, true)) in composite_setup()
2040 switch (ctrl->bRequestType & USB_RECIP_MASK) { in composite_setup()
2042 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
2044 f = cdev->config->interface[intf]; in composite_setup()
2048 if (!cdev->config) in composite_setup()
2051 list_for_each_entry(iter, &cdev->config->functions, list) { in composite_setup()
2052 if (test_bit(endp, iter->endpoints)) { in composite_setup()
2060 if (f && f->setup) in composite_setup()
2061 value = f->setup(f, ctrl); in composite_setup()
2065 c = cdev->config; in composite_setup()
2070 if (c->setup) { in composite_setup()
2071 value = c->setup(c, ctrl); in composite_setup()
2075 /* try the only function in the current config */ in composite_setup()
2076 if (!list_is_singular(&c->functions)) in composite_setup()
2078 f = list_first_entry(&c->functions, struct usb_function, in composite_setup()
2080 if (f->setup) in composite_setup()
2081 value = f->setup(f, ctrl); in composite_setup()
2090 req->length = value; in composite_setup()
2091 req->context = cdev; in composite_setup()
2092 req->zero = value < w_length; in composite_setup()
2095 DBG(cdev, "ep_queue --> %d\n", value); in composite_setup()
2096 req->status = 0; in composite_setup()
2097 composite_setup_complete(gadget->ep0, req); in composite_setup()
2118 spin_lock_irqsave(&cdev->lock, flags); in __composite_disconnect()
2119 cdev->suspended = 0; in __composite_disconnect()
2120 if (cdev->config) in __composite_disconnect()
2122 if (cdev->driver->disconnect) in __composite_disconnect()
2123 cdev->driver->disconnect(cdev); in __composite_disconnect()
2124 spin_unlock_irqrestore(&cdev->lock, flags); in __composite_disconnect()
2138 * draw at max 100mA while in a connected, but unconfigured state. in composite_reset()
2144 /*-------------------------------------------------------------------------*/
2152 return sprintf(buf, "%d\n", cdev->suspended); in suspended_show()
2159 struct usb_gadget_strings *gstr = cdev->driver->strings[0]; in __composite_unbind()
2160 struct usb_string *dev_str = gstr->strings; in __composite_unbind()
2165 * state protected by cdev->lock. in __composite_unbind()
2167 WARN_ON(cdev->config); in __composite_unbind()
2169 while (!list_empty(&cdev->configs)) { in __composite_unbind()
2171 c = list_first_entry(&cdev->configs, in __composite_unbind()
2175 if (cdev->driver->unbind && unbind_driver) in __composite_unbind()
2176 cdev->driver->unbind(cdev); in __composite_unbind()
2180 if (dev_str[USB_GADGET_MANUFACTURER_IDX].s == cdev->def_manufacturer) in __composite_unbind()
2183 kfree(cdev->def_manufacturer); in __composite_unbind()
2204 * these variables may have been set in in update_unchanged_dev_desc()
2207 idVendor = new->idVendor; in update_unchanged_dev_desc()
2208 idProduct = new->idProduct; in update_unchanged_dev_desc()
2209 bcdDevice = new->bcdDevice; in update_unchanged_dev_desc()
2210 iSerialNumber = new->iSerialNumber; in update_unchanged_dev_desc()
2211 iManufacturer = new->iManufacturer; in update_unchanged_dev_desc()
2212 iProduct = new->iProduct; in update_unchanged_dev_desc()
2216 new->idVendor = idVendor; in update_unchanged_dev_desc()
2218 new->idProduct = idProduct; in update_unchanged_dev_desc()
2220 new->bcdDevice = bcdDevice; in update_unchanged_dev_desc()
2222 new->bcdDevice = cpu_to_le16(get_default_bcdDevice()); in update_unchanged_dev_desc()
2224 new->iSerialNumber = iSerialNumber; in update_unchanged_dev_desc()
2226 new->iManufacturer = iManufacturer; in update_unchanged_dev_desc()
2228 new->iProduct = iProduct; in update_unchanged_dev_desc()
2231 int composite_dev_prepare(struct usb_composite_driver *composite, in composite_dev_prepare() argument
2234 struct usb_gadget *gadget = cdev->gadget; in composite_dev_prepare()
2235 int ret = -ENOMEM; in composite_dev_prepare()
2238 cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); in composite_dev_prepare()
2239 if (!cdev->req) in composite_dev_prepare()
2240 return -ENOMEM; in composite_dev_prepare()
2242 cdev->req->buf = kzalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL); in composite_dev_prepare()
2243 if (!cdev->req->buf) in composite_dev_prepare()
2246 ret = device_create_file(&gadget->dev, &dev_attr_suspended); in composite_dev_prepare()
2250 cdev->req->complete = composite_setup_complete; in composite_dev_prepare()
2251 cdev->req->context = cdev; in composite_dev_prepare()
2252 gadget->ep0->driver_data = cdev; in composite_dev_prepare()
2254 cdev->driver = composite; in composite_dev_prepare()
2258 * more than 100mA from USB must report itself as bus-powered in in composite_dev_prepare()
2266 * drivers will zero ep->driver_data. in composite_dev_prepare()
2271 kfree(cdev->req->buf); in composite_dev_prepare()
2273 usb_ep_free_request(gadget->ep0, cdev->req); in composite_dev_prepare()
2274 cdev->req = NULL; in composite_dev_prepare()
2283 cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL); in composite_os_desc_req_prepare()
2284 if (!cdev->os_desc_req) { in composite_os_desc_req_prepare()
2285 ret = -ENOMEM; in composite_os_desc_req_prepare()
2289 cdev->os_desc_req->buf = kmalloc(USB_COMP_EP0_OS_DESC_BUFSIZ, in composite_os_desc_req_prepare()
2291 if (!cdev->os_desc_req->buf) { in composite_os_desc_req_prepare()
2292 ret = -ENOMEM; in composite_os_desc_req_prepare()
2293 usb_ep_free_request(ep0, cdev->os_desc_req); in composite_os_desc_req_prepare()
2296 cdev->os_desc_req->context = cdev; in composite_os_desc_req_prepare()
2297 cdev->os_desc_req->complete = composite_setup_complete; in composite_os_desc_req_prepare()
2307 list_for_each_entry_safe(uc, tmp, &cdev->gstrings, list) { in composite_dev_cleanup()
2308 list_del(&uc->list); in composite_dev_cleanup()
2311 if (cdev->os_desc_req) { in composite_dev_cleanup()
2312 if (cdev->os_desc_pending) in composite_dev_cleanup()
2313 usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req); in composite_dev_cleanup()
2315 kfree(cdev->os_desc_req->buf); in composite_dev_cleanup()
2316 cdev->os_desc_req->buf = NULL; in composite_dev_cleanup()
2317 usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req); in composite_dev_cleanup()
2318 cdev->os_desc_req = NULL; in composite_dev_cleanup()
2320 if (cdev->req) { in composite_dev_cleanup()
2321 if (cdev->setup_pending) in composite_dev_cleanup()
2322 usb_ep_dequeue(cdev->gadget->ep0, cdev->req); in composite_dev_cleanup()
2324 kfree(cdev->req->buf); in composite_dev_cleanup()
2325 cdev->req->buf = NULL; in composite_dev_cleanup()
2326 usb_ep_free_request(cdev->gadget->ep0, cdev->req); in composite_dev_cleanup()
2327 cdev->req = NULL; in composite_dev_cleanup()
2329 cdev->next_string_id = 0; in composite_dev_cleanup()
2330 device_remove_file(&cdev->gadget->dev, &dev_attr_suspended); in composite_dev_cleanup()
2335 * In that case, the dispose() callback is used to notify the in composite_dev_cleanup()
2336 * backend that the EPs are no longer in use. in composite_dev_cleanup()
2342 &cdev->gadget->ep_list, ep_list) { in composite_dev_cleanup()
2343 if (ep->ops->dispose) in composite_dev_cleanup()
2344 ep->ops->dispose(ep); in composite_dev_cleanup()
2352 struct usb_composite_driver *composite = to_cdriver(gdriver); in composite_bind() local
2353 int status = -ENOMEM; in composite_bind()
2359 spin_lock_init(&cdev->lock); in composite_bind()
2360 cdev->gadget = gadget; in composite_bind()
2362 INIT_LIST_HEAD(&cdev->configs); in composite_bind()
2363 INIT_LIST_HEAD(&cdev->gstrings); in composite_bind()
2365 status = composite_dev_prepare(composite, cdev); in composite_bind()
2369 /* composite gadget needs to assign strings for whole device (like in composite_bind()
2373 status = composite->bind(cdev); in composite_bind()
2377 if (cdev->use_os_string) { in composite_bind()
2378 status = composite_os_desc_req_prepare(cdev, gadget->ep0); in composite_bind()
2383 update_unchanged_dev_desc(&cdev->desc, composite->dev); in composite_bind()
2386 if (composite->needs_serial && !cdev->desc.iSerialNumber) in composite_bind()
2389 INFO(cdev, "%s ready\n", composite->name); in composite_bind()
2397 /*-------------------------------------------------------------------------*/
2408 if (cdev->config) { in composite_suspend()
2409 list_for_each_entry(f, &cdev->config->functions, list) { in composite_suspend()
2410 if (f->suspend) in composite_suspend()
2411 f->suspend(f); in composite_suspend()
2414 if (cdev->driver->suspend) in composite_suspend()
2415 cdev->driver->suspend(cdev); in composite_suspend()
2417 cdev->suspended = 1; in composite_suspend()
2433 if (cdev->driver->resume) in composite_resume()
2434 cdev->driver->resume(cdev); in composite_resume()
2435 if (cdev->config) { in composite_resume()
2436 list_for_each_entry(f, &cdev->config->functions, list) { in composite_resume()
2437 if (f->resume) in composite_resume()
2438 f->resume(f); in composite_resume()
2441 maxpower = cdev->config->MaxPower ? in composite_resume()
2442 cdev->config->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW; in composite_resume()
2443 if (gadget->speed < USB_SPEED_SUPER) in composite_resume()
2454 cdev->suspended = 0; in composite_resume()
2457 /*-------------------------------------------------------------------------*/
2476 * usb_composite_probe() - register a composite driver
2481 * This function is used to register drivers using the composite driver
2488 * while it was binding. That would usually be done in order to wait for
2495 if (!driver || !driver->dev || !driver->bind) in usb_composite_probe()
2496 return -EINVAL; in usb_composite_probe()
2498 if (!driver->name) in usb_composite_probe()
2499 driver->name = "composite"; in usb_composite_probe()
2501 driver->gadget_driver = composite_driver_template; in usb_composite_probe()
2502 gadget_driver = &driver->gadget_driver; in usb_composite_probe()
2504 gadget_driver->function = (char *) driver->name; in usb_composite_probe()
2505 gadget_driver->driver.name = driver->name; in usb_composite_probe()
2506 gadget_driver->max_speed = driver->max_speed; in usb_composite_probe()
2513 * usb_composite_unregister() - unregister a composite driver
2516 * This function is used to unregister drivers using the composite
2521 usb_gadget_unregister_driver(&driver->gadget_driver); in usb_composite_unregister()
2526 * usb_composite_setup_continue() - Continue with the control transfer
2527 * @cdev: the composite device who's control transfer was kept waiting
2530 * with the control transfer's data/status stage in case it had requested to
2532 * can request the composite framework to delay the setup request's data/status
2538 struct usb_request *req = cdev->req; in usb_composite_setup_continue()
2542 spin_lock_irqsave(&cdev->lock, flags); in usb_composite_setup_continue()
2544 if (cdev->delayed_status == 0) { in usb_composite_setup_continue()
2547 } else if (--cdev->delayed_status == 0) { in usb_composite_setup_continue()
2549 req->length = 0; in usb_composite_setup_continue()
2550 req->context = cdev; in usb_composite_setup_continue()
2553 DBG(cdev, "ep_queue --> %d\n", value); in usb_composite_setup_continue()
2554 req->status = 0; in usb_composite_setup_continue()
2555 composite_setup_complete(cdev->gadget->ep0, req); in usb_composite_setup_continue()
2559 spin_unlock_irqrestore(&cdev->lock, flags); in usb_composite_setup_continue()
2565 return kasprintf(GFP_KERNEL, "%s %s with %s", init_utsname()->sysname, in composite_default_mfr()
2566 init_utsname()->release, gadget->name); in composite_default_mfr()
2572 struct usb_device_descriptor *desc = &cdev->desc; in usb_composite_overwrite_options()
2573 struct usb_gadget_strings *gstr = cdev->driver->strings[0]; in usb_composite_overwrite_options()
2574 struct usb_string *dev_str = gstr->strings; in usb_composite_overwrite_options()
2576 if (covr->idVendor) in usb_composite_overwrite_options()
2577 desc->idVendor = cpu_to_le16(covr->idVendor); in usb_composite_overwrite_options()
2579 if (covr->idProduct) in usb_composite_overwrite_options()
2580 desc->idProduct = cpu_to_le16(covr->idProduct); in usb_composite_overwrite_options()
2582 if (covr->bcdDevice) in usb_composite_overwrite_options()
2583 desc->bcdDevice = cpu_to_le16(covr->bcdDevice); in usb_composite_overwrite_options()
2585 if (covr->serial_number) { in usb_composite_overwrite_options()
2586 desc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id; in usb_composite_overwrite_options()
2587 dev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number; in usb_composite_overwrite_options()
2589 if (covr->manufacturer) { in usb_composite_overwrite_options()
2590 desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; in usb_composite_overwrite_options()
2591 dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer; in usb_composite_overwrite_options()
2594 desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; in usb_composite_overwrite_options()
2595 cdev->def_manufacturer = composite_default_mfr(cdev->gadget); in usb_composite_overwrite_options()
2596 dev_str[USB_GADGET_MANUFACTURER_IDX].s = cdev->def_manufacturer; in usb_composite_overwrite_options()
2599 if (covr->product) { in usb_composite_overwrite_options()
2600 desc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id; in usb_composite_overwrite_options()
2601 dev_str[USB_GADGET_PRODUCT_IDX].s = covr->product; in usb_composite_overwrite_options()