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
164 return -EIO; in config_ep_by_speed_and_alt()
167 switch (g->speed) { in config_ep_by_speed_and_alt()
170 speed_desc = f->ssp_descriptors; in config_ep_by_speed_and_alt()
177 speed_desc = f->ss_descriptors; in config_ep_by_speed_and_alt()
184 speed_desc = f->hs_descriptors; in config_ep_by_speed_and_alt()
189 speed_desc = f->fs_descriptors; in config_ep_by_speed_and_alt()
196 if (int_desc->bAlternateSetting == alt) { in config_ep_by_speed_and_alt()
201 return -EIO; in config_ep_by_speed_and_alt()
207 if (chosen_desc->bEndpointAddress == _ep->address) in config_ep_by_speed_and_alt()
210 return -EIO; in config_ep_by_speed_and_alt()
214 _ep->maxpacket = usb_endpoint_maxp(chosen_desc); in config_ep_by_speed_and_alt()
215 _ep->desc = chosen_desc; in config_ep_by_speed_and_alt()
216 _ep->comp_desc = NULL; in config_ep_by_speed_and_alt()
217 _ep->maxburst = 0; in config_ep_by_speed_and_alt()
218 _ep->mult = 1; in config_ep_by_speed_and_alt()
220 if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) || in config_ep_by_speed_and_alt()
221 usb_endpoint_xfer_int(_ep->desc))) in config_ep_by_speed_and_alt()
222 _ep->mult = usb_endpoint_maxp_mult(_ep->desc); in config_ep_by_speed_and_alt()
233 (comp_desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP)) in config_ep_by_speed_and_alt()
234 return -EIO; in config_ep_by_speed_and_alt()
235 _ep->comp_desc = comp_desc; in config_ep_by_speed_and_alt()
236 if (g->speed >= USB_SPEED_SUPER) { in config_ep_by_speed_and_alt()
237 switch (usb_endpoint_type(_ep->desc)) { in config_ep_by_speed_and_alt()
240 _ep->mult = (comp_desc->bmAttributes & 0x3) + 1; in config_ep_by_speed_and_alt()
244 _ep->maxburst = comp_desc->bMaxBurst + 1; in config_ep_by_speed_and_alt()
247 if (comp_desc->bMaxBurst != 0) { in config_ep_by_speed_and_alt()
253 _ep->maxburst = 1; in config_ep_by_speed_and_alt()
262 * config_ep_by_speed() - configures the given endpoint
271 * endpoint according to gadget speed and saves it in the
273 * assigned to it - overwrites it with currently corresponding
288 * usb_add_function() - add a function to a configuration
304 int value = -EINVAL; in usb_add_function()
306 DBG(config->cdev, "adding '%s'/%p to config '%s'/%p\n", in usb_add_function()
307 function->name, function, in usb_add_function()
308 config->label, config); in usb_add_function()
310 if (!function->set_alt || !function->disable) in usb_add_function()
313 function->config = config; in usb_add_function()
314 list_add_tail(&function->list, &config->functions); in usb_add_function()
316 if (function->bind_deactivated) { in usb_add_function()
322 /* REVISIT *require* function->bind? */ in usb_add_function()
323 if (function->bind) { in usb_add_function()
324 value = function->bind(config, function); in usb_add_function()
326 list_del(&function->list); in usb_add_function()
327 function->config = NULL; in usb_add_function()
337 if (!config->fullspeed && function->fs_descriptors) in usb_add_function()
338 config->fullspeed = true; in usb_add_function()
339 if (!config->highspeed && function->hs_descriptors) in usb_add_function()
340 config->highspeed = true; in usb_add_function()
341 if (!config->superspeed && function->ss_descriptors) in usb_add_function()
342 config->superspeed = true; in usb_add_function()
343 if (!config->superspeed_plus && function->ssp_descriptors) in usb_add_function()
344 config->superspeed_plus = true; in usb_add_function()
348 DBG(config->cdev, "adding '%s'/%p --> %d\n", in usb_add_function()
349 function->name, function, value); in usb_add_function()
356 if (f->disable) in usb_remove_function()
357 f->disable(f); in usb_remove_function()
359 bitmap_zero(f->endpoints, 32); in usb_remove_function()
360 list_del(&f->list); in usb_remove_function()
361 if (f->unbind) in usb_remove_function()
362 f->unbind(c, f); in usb_remove_function()
364 if (f->bind_deactivated) in usb_remove_function()
370 * usb_function_deactivate - prevent function and gadget enumeration
390 struct usb_composite_dev *cdev = function->config->cdev; in usb_function_deactivate()
394 spin_lock_irqsave(&cdev->lock, flags); in usb_function_deactivate()
396 if (cdev->deactivations == 0) { in usb_function_deactivate()
397 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_deactivate()
398 status = usb_gadget_deactivate(cdev->gadget); in usb_function_deactivate()
399 spin_lock_irqsave(&cdev->lock, flags); in usb_function_deactivate()
402 cdev->deactivations++; in usb_function_deactivate()
404 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_deactivate()
410 * usb_function_activate - allow function and gadget enumeration
421 struct usb_composite_dev *cdev = function->config->cdev; in usb_function_activate()
425 spin_lock_irqsave(&cdev->lock, flags); in usb_function_activate()
427 if (WARN_ON(cdev->deactivations == 0)) in usb_function_activate()
428 status = -EINVAL; in usb_function_activate()
430 cdev->deactivations--; in usb_function_activate()
431 if (cdev->deactivations == 0) { in usb_function_activate()
432 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_activate()
433 status = usb_gadget_activate(cdev->gadget); in usb_function_activate()
434 spin_lock_irqsave(&cdev->lock, flags); in usb_function_activate()
438 spin_unlock_irqrestore(&cdev->lock, flags); in usb_function_activate()
444 * usb_interface_id() - allocate an unused interface ID
451 * ID in interface, association, CDC union, and other descriptors. It
454 * also be class-specific or vendor-specific requests to handle.
459 * identifiers are configuration-specific, functions used in more than
460 * one configuration (or more than once in a given configuration) need
463 * Returns the interface ID which was allocated; or -ENODEV if no
469 unsigned id = config->next_interface_id; in usb_interface_id()
472 config->interface[id] = function; in usb_interface_id()
473 config->next_interface_id = id + 1; in usb_interface_id()
476 return -ENODEV; in usb_interface_id()
485 if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)) in encode_bMaxPower()
486 val = c->MaxPower; in encode_bMaxPower()
510 len = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE; in config_buf()
513 c->bLength = USB_DT_CONFIG_SIZE; in config_buf()
514 c->bDescriptorType = type; in config_buf()
516 c->bNumInterfaces = config->next_interface_id; in config_buf()
517 c->bConfigurationValue = config->bConfigurationValue; in config_buf()
518 c->iConfiguration = config->iConfiguration; in config_buf()
519 c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; in config_buf()
520 c->bMaxPower = encode_bMaxPower(speed, config); in config_buf()
523 if (config->descriptors) { in config_buf()
525 config->descriptors); in config_buf()
528 len -= status; in config_buf()
533 list_for_each_entry(f, &config->functions, list) { in config_buf()
543 len -= status; in config_buf()
547 len = next - buf; in config_buf()
548 c->wTotalLength = cpu_to_le16(len); in config_buf()
554 struct usb_gadget *gadget = cdev->gadget; in config_desc()
560 if (gadget->speed >= USB_SPEED_SUPER) in config_desc()
561 speed = gadget->speed; in config_desc()
564 if (gadget->speed == USB_SPEED_HIGH) in config_desc()
576 pos = &cdev->configs; in config_desc()
577 c = cdev->os_desc_config; in config_desc()
581 while ((pos = pos->next) != &cdev->configs) { in config_desc()
585 if (c == cdev->os_desc_config) in config_desc()
592 if (!c->superspeed_plus) in config_desc()
596 if (!c->superspeed) in config_desc()
600 if (!c->highspeed) in config_desc()
604 if (!c->fullspeed) in config_desc()
609 return config_buf(c, speed, cdev->req->buf, type); in config_desc()
610 w_value--; in config_desc()
612 return -EINVAL; in config_desc()
617 struct usb_gadget *gadget = cdev->gadget; in count_configs()
625 if (gadget->speed == USB_SPEED_HIGH) in count_configs()
627 if (gadget->speed == USB_SPEED_SUPER) in count_configs()
629 if (gadget->speed == USB_SPEED_SUPER_PLUS) in count_configs()
634 list_for_each_entry(c, &cdev->configs, list) { in count_configs()
637 if (!c->superspeed_plus) in count_configs()
640 if (!c->superspeed) in count_configs()
643 if (!c->highspeed) in count_configs()
646 if (!c->fullspeed) in count_configs()
655 * bos_desc() - prepares the BOS descriptor.
667 struct usb_bos_descriptor *bos = cdev->req->buf; in bos_desc()
670 bos->bLength = USB_DT_BOS_SIZE; in bos_desc()
671 bos->bDescriptorType = USB_DT_BOS; in bos_desc()
673 bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE); in bos_desc()
674 bos->bNumDeviceCaps = 0; in bos_desc()
677 if (cdev->gadget->ops->get_config_params) { in bos_desc()
678 cdev->gadget->ops->get_config_params(cdev->gadget, in bos_desc()
701 * and shall support LPM when operating in USB2.0 HS mode. in bos_desc()
703 usb_ext = cdev->req->buf + le16_to_cpu(bos->wTotalLength); in bos_desc()
704 bos->bNumDeviceCaps++; in bos_desc()
705 le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE); in bos_desc()
706 usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE; in bos_desc()
707 usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY; in bos_desc()
708 usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT; in bos_desc()
709 usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | in bos_desc()
716 if (gadget_is_superspeed(cdev->gadget)) { in bos_desc()
719 ss_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength); in bos_desc()
720 bos->bNumDeviceCaps++; in bos_desc()
721 le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE); in bos_desc()
722 ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE; in bos_desc()
723 ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY; in bos_desc()
724 ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE; in bos_desc()
725 ss_cap->bmAttributes = 0; /* LTM is not supported yet */ in bos_desc()
726 ss_cap->wSpeedSupported = cpu_to_le16(USB_LOW_SPEED_OPERATION | in bos_desc()
730 ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION; in bos_desc()
731 ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat; in bos_desc()
732 ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat; in bos_desc()
736 if (gadget_is_superspeed_plus(cdev->gadget)) { in bos_desc()
742 if (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x2) in bos_desc()
749 ssic = (ssac + 1) / 2 - 1; in bos_desc()
751 ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength); in bos_desc()
752 bos->bNumDeviceCaps++; in bos_desc()
754 le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SSP_CAP_SIZE(ssac)); in bos_desc()
755 ssp_cap->bLength = USB_DT_USB_SSP_CAP_SIZE(ssac); in bos_desc()
756 ssp_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY; in bos_desc()
757 ssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE; in bos_desc()
758 ssp_cap->bReserved = 0; in bos_desc()
759 ssp_cap->wReserved = 0; in bos_desc()
761 ssp_cap->bmAttributes = in bos_desc()
765 ssp_cap->wFunctionalitySupport = in bos_desc()
773 * - SSID 0 for symmetric RX/TX sublink speed of 10 Gbps. in bos_desc()
776 * - SSID 0 for symmetric RX/TX sublink speed of 5 Gbps. in bos_desc()
779 * - SSID 0 for symmetric RX/TX sublink speed of 5 Gbps. in bos_desc()
780 * - SSID 1 for symmetric RX/TX sublink speed of 10 Gbps. in bos_desc()
789 if (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x1 || in bos_desc()
790 cdev->gadget->max_ssp_rate == USB_SSP_GEN_UNKNOWN) in bos_desc()
800 ssp_cap->bmSublinkSpeedAttr[i] = in bos_desc()
811 return le16_to_cpu(bos->wTotalLength); in bos_desc()
816 struct usb_qualifier_descriptor *qual = cdev->req->buf; in device_qual()
818 qual->bLength = sizeof(*qual); in device_qual()
819 qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER; in device_qual()
821 qual->bcdUSB = cdev->desc.bcdUSB; in device_qual()
822 qual->bDeviceClass = cdev->desc.bDeviceClass; in device_qual()
823 qual->bDeviceSubClass = cdev->desc.bDeviceSubClass; in device_qual()
824 qual->bDeviceProtocol = cdev->desc.bDeviceProtocol; in device_qual()
826 qual->bMaxPacketSize0 = cdev->gadget->ep0->maxpacket; in device_qual()
827 qual->bNumConfigurations = count_configs(cdev, USB_DT_DEVICE_QUALIFIER); in device_qual()
828 qual->bRESERVED = 0; in device_qual()
831 /*-------------------------------------------------------------------------*/
839 list_for_each_entry(f, &cdev->config->functions, list) { in reset_config()
840 if (f->disable) in reset_config()
841 f->disable(f); in reset_config()
843 bitmap_zero(f->endpoints, 32); in reset_config()
845 cdev->config = NULL; in reset_config()
846 cdev->delayed_status = 0; in reset_config()
852 struct usb_gadget *gadget = cdev->gadget; in set_config()
854 int result = -EINVAL; in set_config()
859 list_for_each_entry(c, &cdev->configs, list) { in set_config()
860 if (c->bConfigurationValue == number) { in set_config()
866 if (cdev->config) in set_config()
874 } else { /* Zero configuration value - need to reset the config */ in set_config()
875 if (cdev->config) in set_config()
881 usb_speed_string(gadget->speed), in set_config()
882 number, c ? c->label : "unconfigured"); in set_config()
888 cdev->config = c; in set_config()
892 struct usb_function *f = c->interface[tmp]; in set_config()
904 descriptors = function_descriptors(f, gadget->speed); in set_config()
910 if ((*descriptors)->bDescriptorType != USB_DT_ENDPOINT) in set_config()
914 addr = ((ep->bEndpointAddress & 0x80) >> 3) in set_config()
915 | (ep->bEndpointAddress & 0x0f); in set_config()
916 set_bit(addr, f->endpoints); in set_config()
919 result = f->set_alt(f, tmp, 0); in set_config()
921 DBG(cdev, "interface %d (%s/%p) alt 0 --> %d\n", in set_config()
922 tmp, f->name, f, result); in set_config()
931 __func__, tmp, f->name); in set_config()
932 cdev->delayed_status++; in set_config()
934 cdev->delayed_status); in set_config()
939 if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)) in set_config()
940 power = c->MaxPower; in set_config()
944 if (gadget->speed < USB_SPEED_SUPER) in set_config()
955 if (result >= 0 && cdev->delayed_status) in set_config()
965 if (!config->bConfigurationValue) in usb_add_config_only()
966 return -EINVAL; in usb_add_config_only()
969 list_for_each_entry(c, &cdev->configs, list) { in usb_add_config_only()
970 if (c->bConfigurationValue == config->bConfigurationValue) in usb_add_config_only()
971 return -EBUSY; in usb_add_config_only()
974 config->cdev = cdev; in usb_add_config_only()
975 list_add_tail(&config->list, &cdev->configs); in usb_add_config_only()
977 INIT_LIST_HEAD(&config->functions); in usb_add_config_only()
978 config->next_interface_id = 0; in usb_add_config_only()
979 memset(config->interface, 0, sizeof(config->interface)); in usb_add_config_only()
986 * usb_add_config() - add a configuration to a device.
992 * One of the main tasks of a composite @bind() routine is to
997 * assigns global resources including string IDs, and per-configuration
1004 int status = -EINVAL; in usb_add_config()
1010 config->bConfigurationValue, in usb_add_config()
1011 config->label, config); in usb_add_config()
1019 while (!list_empty(&config->functions)) { in usb_add_config()
1022 f = list_first_entry(&config->functions, in usb_add_config()
1024 list_del(&f->list); in usb_add_config()
1025 if (f->unbind) { in usb_add_config()
1027 f->name, f); in usb_add_config()
1028 f->unbind(config, f); in usb_add_config()
1032 list_del(&config->list); in usb_add_config()
1033 config->cdev = NULL; in usb_add_config()
1038 config->bConfigurationValue, config, in usb_add_config()
1039 config->superspeed_plus ? " superplus" : "", in usb_add_config()
1040 config->superspeed ? " super" : "", in usb_add_config()
1041 config->highspeed ? " high" : "", in usb_add_config()
1042 config->fullspeed in usb_add_config()
1043 ? (gadget_is_dualspeed(cdev->gadget) in usb_add_config()
1049 struct usb_function *f = config->interface[i]; in usb_add_config()
1054 i, f->name, f); in usb_add_config()
1058 /* set_alt(), or next bind(), sets up ep->claimed as needed */ in usb_add_config()
1059 usb_ep_autoconfig_reset(cdev->gadget); in usb_add_config()
1063 DBG(cdev, "added config '%s'/%u --> %d\n", config->label, in usb_add_config()
1064 config->bConfigurationValue, status); in usb_add_config()
1072 while (!list_empty(&config->functions)) { in remove_config()
1075 f = list_first_entry(&config->functions, in remove_config()
1080 list_del(&config->list); in remove_config()
1081 if (config->unbind) { in remove_config()
1082 DBG(cdev, "unbind config '%s'/%p\n", config->label, config); in remove_config()
1083 config->unbind(config); in remove_config()
1089 * usb_remove_config() - remove a configuration from a device.
1102 spin_lock_irqsave(&cdev->lock, flags); in usb_remove_config()
1104 if (cdev->config == config) in usb_remove_config()
1107 spin_unlock_irqrestore(&cdev->lock, flags); in usb_remove_config()
1112 /*-------------------------------------------------------------------------*/
1114 /* We support strings in multiple languages ... string descriptor zero
1128 language = cpu_to_le16(s->language); in collect_langs()
1151 if (s->language != language) in lookup_string()
1157 return -EINVAL; in lookup_string()
1163 struct usb_composite_driver *composite = cdev->driver; in get_string() local
1180 s->bDescriptorType = USB_DT_STRING; in get_string()
1182 sp = composite->strings; in get_string()
1184 collect_langs(sp, s->wData); in get_string()
1186 list_for_each_entry(c, &cdev->configs, list) { in get_string()
1187 sp = c->strings; in get_string()
1189 collect_langs(sp, s->wData); in get_string()
1191 list_for_each_entry(f, &c->functions, list) { in get_string()
1192 sp = f->strings; in get_string()
1194 collect_langs(sp, s->wData); in get_string()
1197 list_for_each_entry(uc, &cdev->gstrings, list) { in get_string()
1201 collect_langs(sp, s->wData); in get_string()
1204 for (len = 0; len <= USB_MAX_STRING_LEN && s->wData[len]; len++) in get_string()
1207 return -EINVAL; in get_string()
1209 s->bLength = 2 * (len + 1); in get_string()
1210 return s->bLength; in get_string()
1213 if (cdev->use_os_string && language == 0 && id == OS_STRING_IDX) { in get_string()
1215 b->bLength = sizeof(*b); in get_string()
1216 b->bDescriptorType = USB_DT_STRING; in get_string()
1218 sizeof(b->qwSignature) == sizeof(cdev->qw_sign), in get_string()
1220 memcpy(&b->qwSignature, cdev->qw_sign, sizeof(b->qwSignature)); in get_string()
1221 b->bMS_VendorCode = cdev->b_vendor_code; in get_string()
1222 b->bPad = 0; in get_string()
1226 list_for_each_entry(uc, &cdev->gstrings, list) { in get_string()
1235 /* String IDs are device-scoped, so we look up each string in get_string()
1237 * simpler-is-better here. in get_string()
1239 if (composite->strings) { in get_string()
1240 len = lookup_string(composite->strings, buf, language, id); in get_string()
1244 list_for_each_entry(c, &cdev->configs, list) { in get_string()
1245 if (c->strings) { in get_string()
1246 len = lookup_string(c->strings, buf, language, id); in get_string()
1250 list_for_each_entry(f, &c->functions, list) { in get_string()
1251 if (!f->strings) in get_string()
1253 len = lookup_string(f->strings, buf, language, id); in get_string()
1258 return -EINVAL; in get_string()
1262 * usb_string_id() - allocate an unused string ID
1268 * then store that ID in the appropriate descriptors and string table.
1277 if (cdev->next_string_id < 254) { in usb_string_id()
1280 /* 255 reserved as well? -- mina86 */ in usb_string_id()
1281 cdev->next_string_id++; in usb_string_id()
1282 return cdev->next_string_id; in usb_string_id()
1284 return -ENODEV; in usb_string_id()
1289 * usb_string_ids_tab() - allocate unused string IDs in batch
1306 int next = cdev->next_string_id; in usb_string_ids_tab()
1308 for (; str->s; ++str) { in usb_string_ids_tab()
1310 return -ENODEV; in usb_string_ids_tab()
1311 str->id = ++next; in usb_string_ids_tab()
1314 cdev->next_string_id = next; in usb_string_ids_tab()
1339 return ERR_PTR(-ENOMEM); in copy_gadget_strings()
1341 stash = uc->stash; in copy_gadget_strings()
1349 gs->language = sp[n_gs]->language; in copy_gadget_strings()
1350 gs->strings = stash; in copy_gadget_strings()
1351 org_s = sp[n_gs]->strings; in copy_gadget_strings()
1356 if (org_s->s) in copy_gadget_strings()
1357 s->s = org_s->s; in copy_gadget_strings()
1359 s->s = ""; in copy_gadget_strings()
1363 s->s = NULL; in copy_gadget_strings()
1372 * usb_gstrings_attach() - attach gadget strings to a cdev and assign ids
1376 * @n_strings: number of entries in each usb_strings array (sp[]->strings)
1382 * The ->language pointer of each struct usb_gadget_strings has to contain the
1384 * For instance: sp[0] is en-US, sp[1] is es-ES. It is expected that the first
1385 * usb_string entry of es-ES contains the translation of the first usb_string
1386 * entry of en-US. Therefore both entries become the same id assign.
1401 return ERR_PTR(-EINVAL); in usb_gstrings_attach()
1408 ret = usb_string_ids_tab(cdev, n_gs[0]->strings); in usb_gstrings_attach()
1417 m_s = n_gs[0]->strings; in usb_gstrings_attach()
1418 s = n_gs[i]->strings; in usb_gstrings_attach()
1420 s->id = m_s->id; in usb_gstrings_attach()
1425 list_add_tail(&uc->list, &cdev->gstrings); in usb_gstrings_attach()
1426 return n_gs[0]->strings; in usb_gstrings_attach()
1434 * usb_string_ids_n() - allocate unused string IDs in batch
1439 * Returns the first requested ID. This ID and next @n-1 IDs are now
1440 * valid IDs. At least provided that @n is non-zero because if it
1445 * then store that ID in the appropriate descriptors and string table.
1454 unsigned next = c->next_string_id; in usb_string_ids_n()
1456 return -ENODEV; in usb_string_ids_n()
1457 c->next_string_id += n; in usb_string_ids_n()
1462 /*-------------------------------------------------------------------------*/
1468 if (req->status || req->actual != req->length) in composite_setup_complete()
1469 DBG((struct usb_composite_dev *) ep->driver_data, in composite_setup_complete()
1470 "setup complete --> %d, %d/%d\n", in composite_setup_complete()
1471 req->status, req->actual, req->length); in composite_setup_complete()
1475 * so they don't have to maintain the same ->complete() stubs. in composite_setup_complete()
1477 * Because of that, we need to check for the validity of ->context in composite_setup_complete()
1480 if (!req->context) in composite_setup_complete()
1483 cdev = req->context; in composite_setup_complete()
1485 if (cdev->req == req) in composite_setup_complete()
1486 cdev->setup_pending = false; in composite_setup_complete()
1487 else if (cdev->os_desc_req == req) in composite_setup_complete()
1488 cdev->os_desc_pending = false; in composite_setup_complete()
1498 ret = usb_ep_queue(cdev->gadget->ep0, req, gfp_flags); in composite_ep0_queue()
1500 if (cdev->req == req) in composite_ep0_queue()
1501 cdev->setup_pending = true; in composite_ep0_queue()
1502 else if (cdev->os_desc_req == req) in composite_ep0_queue()
1503 cdev->os_desc_pending = true; in composite_ep0_queue()
1516 for (i = 0; i < c->next_interface_id; ++i) { in count_ext_compat()
1520 f = c->interface[i]; in count_ext_compat()
1521 for (j = 0; j < f->os_desc_n; ++j) { in count_ext_compat()
1524 if (i != f->os_desc_table[j].if_id) in count_ext_compat()
1526 d = f->os_desc_table[j].os_desc; in count_ext_compat()
1527 if (d && d->ext_compat_id) in count_ext_compat()
1541 for (i = 0; i < c->next_interface_id; ++i) { in fill_ext_compat()
1545 f = c->interface[i]; in fill_ext_compat()
1546 for (j = 0; j < f->os_desc_n; ++j) { in fill_ext_compat()
1549 if (i != f->os_desc_table[j].if_id) in fill_ext_compat()
1551 d = f->os_desc_table[j].os_desc; in fill_ext_compat()
1552 if (d && d->ext_compat_id) { in fill_ext_compat()
1555 memcpy(buf, d->ext_compat_id, 16); in fill_ext_compat()
1576 f = c->interface[interface]; in count_ext_prop()
1577 for (j = 0; j < f->os_desc_n; ++j) { in count_ext_prop()
1580 if (interface != f->os_desc_table[j].if_id) in count_ext_prop()
1582 d = f->os_desc_table[j].os_desc; in count_ext_prop()
1583 if (d && d->ext_compat_id) in count_ext_prop()
1584 return d->ext_prop_count; in count_ext_prop()
1596 f = c->interface[interface]; in len_ext_prop()
1597 for (j = 0; j < f->os_desc_n; ++j) { in len_ext_prop()
1598 if (interface != f->os_desc_table[j].if_id) in len_ext_prop()
1600 d = f->os_desc_table[j].os_desc; in len_ext_prop()
1602 return min(res + d->ext_prop_len, 4096); in len_ext_prop()
1614 f = c->interface[interface]; in fill_ext_prop()
1617 for (j = 0; j < f->os_desc_n; ++j) { in fill_ext_prop()
1618 if (interface != f->os_desc_table[j].if_id) in fill_ext_prop()
1620 d = f->os_desc_table[j].os_desc; in fill_ext_prop()
1622 list_for_each_entry(ext_prop, &d->ext_prop, entry) { in fill_ext_prop()
1623 n = ext_prop->data_len + in fill_ext_prop()
1624 ext_prop->name_len + 14; in fill_ext_prop()
1628 usb_ext_prop_put_type(buf, ext_prop->type); in fill_ext_prop()
1629 ret = usb_ext_prop_put_name(buf, ext_prop->name, in fill_ext_prop()
1630 ext_prop->name_len); in fill_ext_prop()
1633 switch (ext_prop->type) { in fill_ext_prop()
1638 ext_prop->data, in fill_ext_prop()
1639 ext_prop->data_len); in fill_ext_prop()
1643 ext_prop->data, in fill_ext_prop()
1644 ext_prop->data_len); in fill_ext_prop()
1651 return -EINVAL; in fill_ext_prop()
1663 * not handled lower down, in hardware or the hardware driver(like
1666 * the work is in config and function specific setup.
1672 struct usb_request *req = cdev->req; in composite_setup()
1673 int value = -EOPNOTSUPP; in composite_setup()
1675 u16 w_index = le16_to_cpu(ctrl->wIndex); in composite_setup()
1677 u16 w_value = le16_to_cpu(ctrl->wValue); in composite_setup()
1678 u16 w_length = le16_to_cpu(ctrl->wLength); in composite_setup()
1682 /* partial re-init of the response message; the function or the in composite_setup()
1683 * gadget might need to intercept e.g. a control-OUT completion in composite_setup()
1686 req->zero = 0; in composite_setup()
1687 req->context = cdev; in composite_setup()
1688 req->complete = composite_setup_complete; in composite_setup()
1689 req->length = 0; in composite_setup()
1690 gadget->ep0->driver_data = cdev; in composite_setup()
1693 * Don't let non-standard requests match any of the cases below in composite_setup()
1696 if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD) in composite_setup()
1699 switch (ctrl->bRequest) { in composite_setup()
1703 if (ctrl->bRequestType != USB_DIR_IN) in composite_setup()
1708 cdev->desc.bNumConfigurations = in composite_setup()
1710 cdev->desc.bMaxPacketSize0 = in composite_setup()
1711 cdev->gadget->ep0->maxpacket; in composite_setup()
1713 if (gadget->speed >= USB_SPEED_SUPER) { in composite_setup()
1714 cdev->desc.bcdUSB = cpu_to_le16(0x0320); in composite_setup()
1715 cdev->desc.bMaxPacketSize0 = 9; in composite_setup()
1717 cdev->desc.bcdUSB = cpu_to_le16(0x0210); in composite_setup()
1720 if (gadget->lpm_capable) in composite_setup()
1721 cdev->desc.bcdUSB = cpu_to_le16(0x0201); in composite_setup()
1723 cdev->desc.bcdUSB = cpu_to_le16(0x0200); in composite_setup()
1726 value = min(w_length, (u16) sizeof cdev->desc); in composite_setup()
1727 memcpy(req->buf, &cdev->desc, value); in composite_setup()
1731 gadget->speed >= USB_SPEED_SUPER) in composite_setup()
1739 gadget->speed >= USB_SPEED_SUPER) in composite_setup()
1748 value = get_string(cdev, req->buf, in composite_setup()
1755 gadget->lpm_capable) { in composite_setup()
1765 if (cdev->config) in composite_setup()
1766 config = cdev->config; in composite_setup()
1769 &cdev->configs, in composite_setup()
1774 if (gadget->otg_caps && in composite_setup()
1775 (gadget->otg_caps->otg_rev >= 0x0200)) in composite_setup()
1783 memcpy(req->buf, config->descriptors[0], value); in composite_setup()
1791 if (ctrl->bRequestType != 0) in composite_setup()
1794 if (gadget->a_hnp_support) in composite_setup()
1796 else if (gadget->a_alt_hnp_support) in composite_setup()
1801 spin_lock(&cdev->lock); in composite_setup()
1803 spin_unlock(&cdev->lock); in composite_setup()
1806 if (ctrl->bRequestType != USB_DIR_IN) in composite_setup()
1808 if (cdev->config) in composite_setup()
1809 *(u8 *)req->buf = cdev->config->bConfigurationValue; in composite_setup()
1811 *(u8 *)req->buf = 0; in composite_setup()
1817 if (ctrl->bRequestType != USB_RECIP_INTERFACE) in composite_setup()
1819 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1821 f = cdev->config->interface[intf]; in composite_setup()
1828 * as we check this in usb_add_function(). in composite_setup()
1830 if (w_value && !f->get_alt) in composite_setup()
1833 spin_lock(&cdev->lock); in composite_setup()
1834 value = f->set_alt(f, w_index, w_value); in composite_setup()
1838 __func__, intf, f->name); in composite_setup()
1839 cdev->delayed_status++; in composite_setup()
1841 cdev->delayed_status); in composite_setup()
1843 spin_unlock(&cdev->lock); in composite_setup()
1846 if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) in composite_setup()
1848 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1850 f = cdev->config->interface[intf]; in composite_setup()
1854 value = f->get_alt ? f->get_alt(f, w_index) : 0; in composite_setup()
1857 *((u8 *)req->buf) = value; in composite_setup()
1861 if (gadget_is_otg(gadget) && gadget->hnp_polling_support && in composite_setup()
1863 if (ctrl->bRequestType != (USB_DIR_IN | in composite_setup()
1866 *((u8 *)req->buf) = gadget->host_request_flag; in composite_setup()
1880 if (ctrl->bRequestType != (USB_DIR_IN | USB_RECIP_INTERFACE)) in composite_setup()
1883 put_unaligned_le16(0, req->buf); in composite_setup()
1884 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1886 f = cdev->config->interface[intf]; in composite_setup()
1889 status = f->get_status ? f->get_status(f) : 0; in composite_setup()
1892 put_unaligned_le16(status & 0x0000ffff, req->buf); in composite_setup()
1903 if (ctrl->bRequestType != (USB_DIR_OUT | USB_RECIP_INTERFACE)) in composite_setup()
1907 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
1909 f = cdev->config->interface[intf]; in composite_setup()
1913 if (f->func_suspend) in composite_setup()
1914 value = f->func_suspend(f, w_index >> 8); in composite_setup()
1929 if (cdev->use_os_string && cdev->os_desc_config && in composite_setup()
1930 (ctrl->bRequestType & USB_TYPE_VENDOR) && in composite_setup()
1931 ctrl->bRequest == cdev->b_vendor_code) { in composite_setup()
1937 req = cdev->os_desc_req; in composite_setup()
1938 req->context = cdev; in composite_setup()
1939 req->complete = composite_setup_complete; in composite_setup()
1940 buf = req->buf; in composite_setup()
1941 os_desc_cfg = cdev->os_desc_config; in composite_setup()
1945 switch (ctrl->bRequestType & USB_RECIP_MASK) { in composite_setup()
1987 "non-core control req%02x.%02x v%04x i%04x l%d\n", in composite_setup()
1988 ctrl->bRequestType, ctrl->bRequest, in composite_setup()
1995 if (cdev->config) { in composite_setup()
1996 list_for_each_entry(f, &cdev->config->functions, list) in composite_setup()
1997 if (f->req_match && in composite_setup()
1998 f->req_match(f, ctrl, false)) in composite_setup()
2002 list_for_each_entry(c, &cdev->configs, list) in composite_setup()
2003 list_for_each_entry(f, &c->functions, list) in composite_setup()
2004 if (f->req_match && in composite_setup()
2005 f->req_match(f, ctrl, true)) in composite_setup()
2010 switch (ctrl->bRequestType & USB_RECIP_MASK) { in composite_setup()
2012 if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) in composite_setup()
2014 f = cdev->config->interface[intf]; in composite_setup()
2018 if (!cdev->config) in composite_setup()
2021 list_for_each_entry(f, &cdev->config->functions, list) { in composite_setup()
2022 if (test_bit(endp, f->endpoints)) in composite_setup()
2025 if (&f->list == &cdev->config->functions) in composite_setup()
2030 if (f && f->setup) in composite_setup()
2031 value = f->setup(f, ctrl); in composite_setup()
2035 c = cdev->config; in composite_setup()
2040 if (c->setup) { in composite_setup()
2041 value = c->setup(c, ctrl); in composite_setup()
2045 /* try the only function in the current config */ in composite_setup()
2046 if (!list_is_singular(&c->functions)) in composite_setup()
2048 f = list_first_entry(&c->functions, struct usb_function, in composite_setup()
2050 if (f->setup) in composite_setup()
2051 value = f->setup(f, ctrl); in composite_setup()
2060 req->length = value; in composite_setup()
2061 req->context = cdev; in composite_setup()
2062 req->zero = value < w_length; in composite_setup()
2065 DBG(cdev, "ep_queue --> %d\n", value); in composite_setup()
2066 req->status = 0; in composite_setup()
2067 composite_setup_complete(gadget->ep0, req); in composite_setup()
2088 spin_lock_irqsave(&cdev->lock, flags); in __composite_disconnect()
2089 cdev->suspended = 0; in __composite_disconnect()
2090 if (cdev->config) in __composite_disconnect()
2092 if (cdev->driver->disconnect) in __composite_disconnect()
2093 cdev->driver->disconnect(cdev); in __composite_disconnect()
2094 spin_unlock_irqrestore(&cdev->lock, flags); in __composite_disconnect()
2108 * draw at max 100mA while in a connected, but unconfigured state. in composite_reset()
2114 /*-------------------------------------------------------------------------*/
2122 return sprintf(buf, "%d\n", cdev->suspended); in suspended_show()
2129 struct usb_gadget_strings *gstr = cdev->driver->strings[0]; in __composite_unbind()
2130 struct usb_string *dev_str = gstr->strings; in __composite_unbind()
2135 * state protected by cdev->lock. in __composite_unbind()
2137 WARN_ON(cdev->config); in __composite_unbind()
2139 while (!list_empty(&cdev->configs)) { in __composite_unbind()
2141 c = list_first_entry(&cdev->configs, in __composite_unbind()
2145 if (cdev->driver->unbind && unbind_driver) in __composite_unbind()
2146 cdev->driver->unbind(cdev); in __composite_unbind()
2150 if (dev_str[USB_GADGET_MANUFACTURER_IDX].s == cdev->def_manufacturer) in __composite_unbind()
2153 kfree(cdev->def_manufacturer); in __composite_unbind()
2174 * these variables may have been set in in update_unchanged_dev_desc()
2177 idVendor = new->idVendor; in update_unchanged_dev_desc()
2178 idProduct = new->idProduct; in update_unchanged_dev_desc()
2179 bcdDevice = new->bcdDevice; in update_unchanged_dev_desc()
2180 iSerialNumber = new->iSerialNumber; in update_unchanged_dev_desc()
2181 iManufacturer = new->iManufacturer; in update_unchanged_dev_desc()
2182 iProduct = new->iProduct; in update_unchanged_dev_desc()
2186 new->idVendor = idVendor; in update_unchanged_dev_desc()
2188 new->idProduct = idProduct; in update_unchanged_dev_desc()
2190 new->bcdDevice = bcdDevice; in update_unchanged_dev_desc()
2192 new->bcdDevice = cpu_to_le16(get_default_bcdDevice()); in update_unchanged_dev_desc()
2194 new->iSerialNumber = iSerialNumber; in update_unchanged_dev_desc()
2196 new->iManufacturer = iManufacturer; in update_unchanged_dev_desc()
2198 new->iProduct = iProduct; in update_unchanged_dev_desc()
2201 int composite_dev_prepare(struct usb_composite_driver *composite, in composite_dev_prepare() argument
2204 struct usb_gadget *gadget = cdev->gadget; in composite_dev_prepare()
2205 int ret = -ENOMEM; in composite_dev_prepare()
2208 cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); in composite_dev_prepare()
2209 if (!cdev->req) in composite_dev_prepare()
2210 return -ENOMEM; in composite_dev_prepare()
2212 cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL); in composite_dev_prepare()
2213 if (!cdev->req->buf) in composite_dev_prepare()
2216 ret = device_create_file(&gadget->dev, &dev_attr_suspended); in composite_dev_prepare()
2220 cdev->req->complete = composite_setup_complete; in composite_dev_prepare()
2221 cdev->req->context = cdev; in composite_dev_prepare()
2222 gadget->ep0->driver_data = cdev; in composite_dev_prepare()
2224 cdev->driver = composite; in composite_dev_prepare()
2228 * more than 100mA from USB must report itself as bus-powered in in composite_dev_prepare()
2236 * drivers will zero ep->driver_data. in composite_dev_prepare()
2241 kfree(cdev->req->buf); in composite_dev_prepare()
2243 usb_ep_free_request(gadget->ep0, cdev->req); in composite_dev_prepare()
2244 cdev->req = NULL; in composite_dev_prepare()
2253 cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL); in composite_os_desc_req_prepare()
2254 if (!cdev->os_desc_req) { in composite_os_desc_req_prepare()
2255 ret = -ENOMEM; in composite_os_desc_req_prepare()
2259 cdev->os_desc_req->buf = kmalloc(USB_COMP_EP0_OS_DESC_BUFSIZ, in composite_os_desc_req_prepare()
2261 if (!cdev->os_desc_req->buf) { in composite_os_desc_req_prepare()
2262 ret = -ENOMEM; in composite_os_desc_req_prepare()
2263 usb_ep_free_request(ep0, cdev->os_desc_req); in composite_os_desc_req_prepare()
2266 cdev->os_desc_req->context = cdev; in composite_os_desc_req_prepare()
2267 cdev->os_desc_req->complete = composite_setup_complete; in composite_os_desc_req_prepare()
2277 list_for_each_entry_safe(uc, tmp, &cdev->gstrings, list) { in composite_dev_cleanup()
2278 list_del(&uc->list); in composite_dev_cleanup()
2281 if (cdev->os_desc_req) { in composite_dev_cleanup()
2282 if (cdev->os_desc_pending) in composite_dev_cleanup()
2283 usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req); in composite_dev_cleanup()
2285 kfree(cdev->os_desc_req->buf); in composite_dev_cleanup()
2286 cdev->os_desc_req->buf = NULL; in composite_dev_cleanup()
2287 usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req); in composite_dev_cleanup()
2288 cdev->os_desc_req = NULL; in composite_dev_cleanup()
2290 if (cdev->req) { in composite_dev_cleanup()
2291 if (cdev->setup_pending) in composite_dev_cleanup()
2292 usb_ep_dequeue(cdev->gadget->ep0, cdev->req); in composite_dev_cleanup()
2294 kfree(cdev->req->buf); in composite_dev_cleanup()
2295 cdev->req->buf = NULL; in composite_dev_cleanup()
2296 usb_ep_free_request(cdev->gadget->ep0, cdev->req); in composite_dev_cleanup()
2297 cdev->req = NULL; in composite_dev_cleanup()
2299 cdev->next_string_id = 0; in composite_dev_cleanup()
2300 device_remove_file(&cdev->gadget->dev, &dev_attr_suspended); in composite_dev_cleanup()
2305 * In that case, the dispose() callback is used to notify the in composite_dev_cleanup()
2306 * backend that the EPs are no longer in use. in composite_dev_cleanup()
2312 &cdev->gadget->ep_list, ep_list) { in composite_dev_cleanup()
2313 if (ep->ops->dispose) in composite_dev_cleanup()
2314 ep->ops->dispose(ep); in composite_dev_cleanup()
2322 struct usb_composite_driver *composite = to_cdriver(gdriver); in composite_bind() local
2323 int status = -ENOMEM; in composite_bind()
2329 spin_lock_init(&cdev->lock); in composite_bind()
2330 cdev->gadget = gadget; in composite_bind()
2332 INIT_LIST_HEAD(&cdev->configs); in composite_bind()
2333 INIT_LIST_HEAD(&cdev->gstrings); in composite_bind()
2335 status = composite_dev_prepare(composite, cdev); in composite_bind()
2339 /* composite gadget needs to assign strings for whole device (like in composite_bind()
2343 status = composite->bind(cdev); in composite_bind()
2347 if (cdev->use_os_string) { in composite_bind()
2348 status = composite_os_desc_req_prepare(cdev, gadget->ep0); in composite_bind()
2353 update_unchanged_dev_desc(&cdev->desc, composite->dev); in composite_bind()
2356 if (composite->needs_serial && !cdev->desc.iSerialNumber) in composite_bind()
2359 INFO(cdev, "%s ready\n", composite->name); in composite_bind()
2367 /*-------------------------------------------------------------------------*/
2378 if (cdev->config) { in composite_suspend()
2379 list_for_each_entry(f, &cdev->config->functions, list) { in composite_suspend()
2380 if (f->suspend) in composite_suspend()
2381 f->suspend(f); in composite_suspend()
2384 if (cdev->driver->suspend) in composite_suspend()
2385 cdev->driver->suspend(cdev); in composite_suspend()
2387 cdev->suspended = 1; in composite_suspend()
2403 if (cdev->driver->resume) in composite_resume()
2404 cdev->driver->resume(cdev); in composite_resume()
2405 if (cdev->config) { in composite_resume()
2406 list_for_each_entry(f, &cdev->config->functions, list) { in composite_resume()
2407 if (f->resume) in composite_resume()
2408 f->resume(f); in composite_resume()
2411 maxpower = cdev->config->MaxPower ? in composite_resume()
2412 cdev->config->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW; in composite_resume()
2413 if (gadget->speed < USB_SPEED_SUPER) in composite_resume()
2424 cdev->suspended = 0; in composite_resume()
2427 /*-------------------------------------------------------------------------*/
2446 * usb_composite_probe() - register a composite driver
2451 * This function is used to register drivers using the composite driver
2458 * while it was binding. That would usually be done in order to wait for
2465 if (!driver || !driver->dev || !driver->bind) in usb_composite_probe()
2466 return -EINVAL; in usb_composite_probe()
2468 if (!driver->name) in usb_composite_probe()
2469 driver->name = "composite"; in usb_composite_probe()
2471 driver->gadget_driver = composite_driver_template; in usb_composite_probe()
2472 gadget_driver = &driver->gadget_driver; in usb_composite_probe()
2474 gadget_driver->function = (char *) driver->name; in usb_composite_probe()
2475 gadget_driver->driver.name = driver->name; in usb_composite_probe()
2476 gadget_driver->max_speed = driver->max_speed; in usb_composite_probe()
2483 * usb_composite_unregister() - unregister a composite driver
2486 * This function is used to unregister drivers using the composite
2491 usb_gadget_unregister_driver(&driver->gadget_driver); in usb_composite_unregister()
2496 * usb_composite_setup_continue() - Continue with the control transfer
2497 * @cdev: the composite device who's control transfer was kept waiting
2500 * with the control transfer's data/status stage in case it had requested to
2502 * can request the composite framework to delay the setup request's data/status
2508 struct usb_request *req = cdev->req; in usb_composite_setup_continue()
2512 spin_lock_irqsave(&cdev->lock, flags); in usb_composite_setup_continue()
2514 if (cdev->delayed_status == 0) { in usb_composite_setup_continue()
2517 } else if (--cdev->delayed_status == 0) { in usb_composite_setup_continue()
2519 req->length = 0; in usb_composite_setup_continue()
2520 req->context = cdev; in usb_composite_setup_continue()
2523 DBG(cdev, "ep_queue --> %d\n", value); in usb_composite_setup_continue()
2524 req->status = 0; in usb_composite_setup_continue()
2525 composite_setup_complete(cdev->gadget->ep0, req); in usb_composite_setup_continue()
2529 spin_unlock_irqrestore(&cdev->lock, flags); in usb_composite_setup_continue()
2535 return kasprintf(GFP_KERNEL, "%s %s with %s", init_utsname()->sysname, in composite_default_mfr()
2536 init_utsname()->release, gadget->name); in composite_default_mfr()
2542 struct usb_device_descriptor *desc = &cdev->desc; in usb_composite_overwrite_options()
2543 struct usb_gadget_strings *gstr = cdev->driver->strings[0]; in usb_composite_overwrite_options()
2544 struct usb_string *dev_str = gstr->strings; in usb_composite_overwrite_options()
2546 if (covr->idVendor) in usb_composite_overwrite_options()
2547 desc->idVendor = cpu_to_le16(covr->idVendor); in usb_composite_overwrite_options()
2549 if (covr->idProduct) in usb_composite_overwrite_options()
2550 desc->idProduct = cpu_to_le16(covr->idProduct); in usb_composite_overwrite_options()
2552 if (covr->bcdDevice) in usb_composite_overwrite_options()
2553 desc->bcdDevice = cpu_to_le16(covr->bcdDevice); in usb_composite_overwrite_options()
2555 if (covr->serial_number) { in usb_composite_overwrite_options()
2556 desc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id; in usb_composite_overwrite_options()
2557 dev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number; in usb_composite_overwrite_options()
2559 if (covr->manufacturer) { in usb_composite_overwrite_options()
2560 desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; in usb_composite_overwrite_options()
2561 dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer; in usb_composite_overwrite_options()
2564 desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; in usb_composite_overwrite_options()
2565 cdev->def_manufacturer = composite_default_mfr(cdev->gadget); in usb_composite_overwrite_options()
2566 dev_str[USB_GADGET_MANUFACTURER_IDX].s = cdev->def_manufacturer; in usb_composite_overwrite_options()
2569 if (covr->product) { in usb_composite_overwrite_options()
2570 desc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id; in usb_composite_overwrite_options()
2571 dev_str[USB_GADGET_PRODUCT_IDX].s = covr->product; in usb_composite_overwrite_options()