• Home
  • Raw
  • Download

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

1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/usb/composite.h>
33 return -EINVAL; in check_user_usb_string()
36 return -EINVAL; in check_user_usb_string()
38 stringtab_dev->language = num; in check_user_usb_string()
59 struct usb_composite_driver composite; member
119 return -EOVERFLOW; in usb_string_copy()
123 return -ENOMEM; in usb_string_copy()
124 if (str[ret - 1] == '\n') in usb_string_copy()
125 str[ret - 1] = '\0'; in usb_string_copy()
136 to_gadget_info(item)->cdev.desc.__name); \
144 le16_to_cpup(&to_gadget_info(item)->cdev.desc.__name)); \
157 to_gadget_info(item)->cdev.desc._name = val; \
170 to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(&val); \
190 return -EINVAL; in is_valid_bcd()
192 return -EINVAL; in is_valid_bcd()
194 return -EINVAL; in is_valid_bcd()
196 return -EINVAL; in is_valid_bcd()
213 to_gadget_info(item)->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice); in gadget_dev_desc_bcdDevice_store()
230 to_gadget_info(item)->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB); in gadget_dev_desc_bcdUSB_store()
236 char *udc_name = to_gadget_info(item)->composite.gadget_driver.udc_name; in gadget_dev_desc_UDC_show()
245 if (!gi->composite.gadget_driver.udc_name) in unregister_gadget()
246 return -ENODEV; in unregister_gadget()
248 ret = usb_gadget_unregister_driver(&gi->composite.gadget_driver); in unregister_gadget()
251 kfree(gi->composite.gadget_driver.udc_name); in unregister_gadget()
252 gi->composite.gadget_driver.udc_name = NULL; in unregister_gadget()
264 return -EOVERFLOW; in gadget_dev_desc_UDC_store()
268 return -ENOMEM; in gadget_dev_desc_UDC_store()
269 if (name[len - 1] == '\n') in gadget_dev_desc_UDC_store()
270 name[len - 1] = '\0'; in gadget_dev_desc_UDC_store()
272 mutex_lock(&gi->lock); in gadget_dev_desc_UDC_store()
280 if (gi->composite.gadget_driver.udc_name) { in gadget_dev_desc_UDC_store()
281 ret = -EBUSY; in gadget_dev_desc_UDC_store()
284 gi->composite.gadget_driver.udc_name = name; in gadget_dev_desc_UDC_store()
285 ret = usb_gadget_probe_driver(&gi->composite.gadget_driver); in gadget_dev_desc_UDC_store()
287 gi->composite.gadget_driver.udc_name = NULL; in gadget_dev_desc_UDC_store()
291 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_store()
295 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_store()
346 WARN_ON(!list_empty(&gi->cdev.configs)); in gadget_info_attr_release()
347 WARN_ON(!list_empty(&gi->string_list)); in gadget_info_attr_release()
348 WARN_ON(!list_empty(&gi->available_func)); in gadget_info_attr_release()
349 kfree(gi->composite.gadget_driver.function); in gadget_info_attr_release()
361 WARN_ON(!list_empty(&cfg->c.functions)); in gadget_config_attr_release()
362 list_del(&cfg->c.list); in gadget_config_attr_release()
363 kfree(cfg->c.label); in gadget_config_attr_release()
372 struct usb_composite_dev *cdev = cfg->c.cdev; in config_usb_cfg_link()
382 mutex_lock(&gi->lock); in config_usb_cfg_link()
388 list_for_each_entry(a_fi, &gi->available_func, cfs_list) { in config_usb_cfg_link()
393 ret = -EINVAL; in config_usb_cfg_link()
397 list_for_each_entry(f, &cfg->func_list, list) { in config_usb_cfg_link()
398 if (f->fi == fi) { in config_usb_cfg_link()
399 ret = -EEXIST; in config_usb_cfg_link()
411 list_add_tail(&f->list, &cfg->func_list); in config_usb_cfg_link()
414 mutex_unlock(&gi->lock); in config_usb_cfg_link()
423 struct usb_composite_dev *cdev = cfg->c.cdev; in config_usb_cfg_unlink()
437 mutex_lock(&gi->lock); in config_usb_cfg_unlink()
438 if (gi->composite.gadget_driver.udc_name) in config_usb_cfg_unlink()
440 WARN_ON(gi->composite.gadget_driver.udc_name); in config_usb_cfg_unlink()
442 list_for_each_entry(f, &cfg->func_list, list) { in config_usb_cfg_unlink()
443 if (f->fi == fi) { in config_usb_cfg_unlink()
444 list_del(&f->list); in config_usb_cfg_unlink()
446 mutex_unlock(&gi->lock); in config_usb_cfg_unlink()
450 mutex_unlock(&gi->lock); in config_usb_cfg_unlink()
464 return sprintf(page, "%u\n", to_config_usb_cfg(item)->c.MaxPower); in gadget_config_desc_MaxPower_show()
476 return -ERANGE; in gadget_config_desc_MaxPower_store()
477 to_config_usb_cfg(item)->c.MaxPower = val; in gadget_config_desc_MaxPower_store()
485 to_config_usb_cfg(item)->c.bmAttributes); in gadget_config_desc_bmAttributes_show()
497 return -EINVAL; in gadget_config_desc_bmAttributes_store()
500 return -EINVAL; in gadget_config_desc_bmAttributes_store()
501 to_config_usb_cfg(item)->c.bmAttributes = val; in gadget_config_desc_bmAttributes_store()
528 spin_lock_init(&cdev->lock); in composite_init_dev()
529 INIT_LIST_HEAD(&cdev->configs); in composite_init_dev()
530 INIT_LIST_HEAD(&cdev->gstrings); in composite_init_dev()
546 return ERR_PTR(-ENAMETOOLONG); in function_make()
551 pr_err("Unable to locate . in FUNC.INSTANCE\n"); in function_make()
552 return ERR_PTR(-EINVAL); in function_make()
561 ret = config_item_set_name(&fi->group.cg_item, "%s", name); in function_make()
566 if (fi->set_inst_name) { in function_make()
567 ret = fi->set_inst_name(fi, instance_name); in function_make()
576 mutex_lock(&gi->lock); in function_make()
577 list_add_tail(&fi->cfs_list, &gi->available_func); in function_make()
578 mutex_unlock(&gi->lock); in function_make()
579 return &fi->group; in function_make()
591 mutex_lock(&gi->lock); in function_drop()
592 list_del(&fi->cfs_list); in function_drop()
593 mutex_unlock(&gi->lock); in function_drop()
618 kfree(cn->configuration); in gadget_config_name_attr_release()
620 list_del(&cn->list); in gadget_config_name_attr_release()
641 return ERR_PTR(-ENAMETOOLONG); in config_desc_make()
645 pr_err("Unable to locate . in name.bConfigurationValue\n"); in config_desc_make()
646 return ERR_PTR(-EINVAL); in config_desc_make()
653 return ERR_PTR(-EINVAL); in config_desc_make()
661 return ERR_PTR(-ENOMEM); in config_desc_make()
662 cfg->c.label = kstrdup(buf, GFP_KERNEL); in config_desc_make()
663 if (!cfg->c.label) { in config_desc_make()
664 ret = -ENOMEM; in config_desc_make()
667 cfg->c.bConfigurationValue = num; in config_desc_make()
668 cfg->c.MaxPower = CONFIG_USB_GADGET_VBUS_DRAW; in config_desc_make()
669 cfg->c.bmAttributes = USB_CONFIG_ATT_ONE; in config_desc_make()
670 INIT_LIST_HEAD(&cfg->string_list); in config_desc_make()
671 INIT_LIST_HEAD(&cfg->func_list); in config_desc_make()
673 config_group_init_type_name(&cfg->group, name, in config_desc_make()
676 config_group_init_type_name(&cfg->strings_group, "strings", in config_desc_make()
678 configfs_add_default_group(&cfg->strings_group, &cfg->group); in config_desc_make()
680 ret = usb_add_config_only(&gi->cdev, &cfg->c); in config_desc_make()
684 return &cfg->group; in config_desc_make()
686 kfree(cfg->c.label); in config_desc_make()
723 kfree(gs->manufacturer); in gadget_strings_attr_release()
724 kfree(gs->product); in gadget_strings_attr_release()
725 kfree(gs->serialnumber); in gadget_strings_attr_release()
727 list_del(&gs->list); in gadget_strings_attr_release()
742 return to_gadget_info(to_os_desc(item)->group.cg_item.ci_parent); in os_desc_item_to_gadget_info()
748 os_desc_item_to_gadget_info(item)->use_os_desc); in os_desc_use_show()
758 mutex_lock(&gi->lock); in os_desc_use_store()
761 gi->use_os_desc = use; in os_desc_use_store()
764 mutex_unlock(&gi->lock); in os_desc_use_store()
772 os_desc_item_to_gadget_info(item)->b_vendor_code); in os_desc_b_vendor_code_show()
782 mutex_lock(&gi->lock); in os_desc_b_vendor_code_store()
785 gi->b_vendor_code = b_vendor_code; in os_desc_b_vendor_code_store()
788 mutex_unlock(&gi->lock); in os_desc_b_vendor_code_store()
798 res = utf16s_to_utf8s((wchar_t *) gi->qw_sign, OS_STRING_QW_SIGN_LEN, in os_desc_qw_sign_show()
799 UTF16_LITTLE_ENDIAN, page, PAGE_SIZE - 1); in os_desc_qw_sign_show()
812 if (page[l - 1] == '\n') in os_desc_qw_sign_store()
813 --l; in os_desc_qw_sign_store()
815 mutex_lock(&gi->lock); in os_desc_qw_sign_store()
817 UTF16_LITTLE_ENDIAN, (wchar_t *) gi->qw_sign, in os_desc_qw_sign_store()
821 mutex_unlock(&gi->lock); in os_desc_qw_sign_store()
848 struct usb_composite_dev *cdev = &gi->cdev; in os_desc_link()
855 mutex_lock(&gi->lock); in os_desc_link()
856 list_for_each_entry(c, &cdev->configs, list) { in os_desc_link()
857 if (c == &c_target->c) in os_desc_link()
860 if (c != &c_target->c) { in os_desc_link()
861 ret = -EINVAL; in os_desc_link()
865 if (cdev->os_desc_config) { in os_desc_link()
866 ret = -EBUSY; in os_desc_link()
870 cdev->os_desc_config = &c_target->c; in os_desc_link()
874 mutex_unlock(&gi->lock); in os_desc_link()
883 struct usb_composite_dev *cdev = &gi->cdev; in os_desc_unlink()
885 mutex_lock(&gi->lock); in os_desc_unlink()
886 if (gi->composite.gadget_driver.udc_name) in os_desc_unlink()
888 cdev->os_desc_config = NULL; in os_desc_unlink()
889 WARN_ON(gi->composite.gadget_driver.udc_name); in os_desc_unlink()
890 mutex_unlock(&gi->lock); in os_desc_unlink()
913 return sprintf(page, "%d\n", to_usb_os_desc_ext_prop(item)->type); in ext_prop_type_show()
920 struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); in ext_prop_type_store()
924 if (desc->opts_mutex) in ext_prop_type_store()
925 mutex_lock(desc->opts_mutex); in ext_prop_type_store()
930 ret = -EINVAL; in ext_prop_type_store()
934 if ((ext_prop->type == USB_EXT_PROP_BINARY || in ext_prop_type_store()
935 ext_prop->type == USB_EXT_PROP_LE32 || in ext_prop_type_store()
936 ext_prop->type == USB_EXT_PROP_BE32) && in ext_prop_type_store()
940 ext_prop->data_len <<= 1; in ext_prop_type_store()
941 else if ((ext_prop->type == USB_EXT_PROP_UNICODE || in ext_prop_type_store()
942 ext_prop->type == USB_EXT_PROP_UNICODE_ENV || in ext_prop_type_store()
943 ext_prop->type == USB_EXT_PROP_UNICODE_LINK) && in ext_prop_type_store()
947 ext_prop->data_len >>= 1; in ext_prop_type_store()
948 ext_prop->type = type; in ext_prop_type_store()
952 if (desc->opts_mutex) in ext_prop_type_store()
953 mutex_unlock(desc->opts_mutex); in ext_prop_type_store()
960 int len = ext_prop->data_len; in ext_prop_data_show()
962 if (ext_prop->type == USB_EXT_PROP_UNICODE || in ext_prop_data_show()
963 ext_prop->type == USB_EXT_PROP_UNICODE_ENV || in ext_prop_data_show()
964 ext_prop->type == USB_EXT_PROP_UNICODE_LINK) in ext_prop_data_show()
966 memcpy(page, ext_prop->data, len); in ext_prop_data_show()
975 struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); in ext_prop_data_store()
979 if (page[len - 1] == '\n' || page[len - 1] == '\0') in ext_prop_data_store()
980 --len; in ext_prop_data_store()
983 return -ENOMEM; in ext_prop_data_store()
985 if (desc->opts_mutex) in ext_prop_data_store()
986 mutex_lock(desc->opts_mutex); in ext_prop_data_store()
987 kfree(ext_prop->data); in ext_prop_data_store()
988 ext_prop->data = new_data; in ext_prop_data_store()
989 desc->ext_prop_len -= ext_prop->data_len; in ext_prop_data_store()
990 ext_prop->data_len = len; in ext_prop_data_store()
991 desc->ext_prop_len += ext_prop->data_len; in ext_prop_data_store()
992 if (ext_prop->type == USB_EXT_PROP_UNICODE || in ext_prop_data_store()
993 ext_prop->type == USB_EXT_PROP_UNICODE_ENV || in ext_prop_data_store()
994 ext_prop->type == USB_EXT_PROP_UNICODE_LINK) { in ext_prop_data_store()
995 desc->ext_prop_len -= ext_prop->data_len; in ext_prop_data_store()
996 ext_prop->data_len <<= 1; in ext_prop_data_store()
997 ext_prop->data_len += 2; in ext_prop_data_store()
998 desc->ext_prop_len += ext_prop->data_len; in ext_prop_data_store()
1000 if (desc->opts_mutex) in ext_prop_data_store()
1001 mutex_unlock(desc->opts_mutex); in ext_prop_data_store()
1040 return ERR_PTR(-ENOMEM); in ext_prop_make()
1046 ext_prop_type->ct_item_ops = &ext_prop_ops; in ext_prop_make()
1047 ext_prop_type->ct_attrs = ext_prop_attrs; in ext_prop_make()
1048 ext_prop_type->ct_owner = desc->owner; in ext_prop_make()
1050 config_item_init_type_name(&ext_prop->item, name, ext_prop_type); in ext_prop_make()
1052 ext_prop->name = kstrdup(name, GFP_KERNEL); in ext_prop_make()
1053 if (!ext_prop->name) { in ext_prop_make()
1055 return ERR_PTR(-ENOMEM); in ext_prop_make()
1057 desc->ext_prop_len += 14; in ext_prop_make()
1058 ext_prop->name_len = 2 * strlen(ext_prop->name) + 2; in ext_prop_make()
1059 if (desc->opts_mutex) in ext_prop_make()
1060 mutex_lock(desc->opts_mutex); in ext_prop_make()
1061 desc->ext_prop_len += ext_prop->name_len; in ext_prop_make()
1062 list_add_tail(&ext_prop->entry, &desc->ext_prop); in ext_prop_make()
1063 ++desc->ext_prop_count; in ext_prop_make()
1064 if (desc->opts_mutex) in ext_prop_make()
1065 mutex_unlock(desc->opts_mutex); in ext_prop_make()
1067 return &ext_prop->item; in ext_prop_make()
1073 struct usb_os_desc *desc = to_usb_os_desc(&group->cg_item); in ext_prop_drop()
1075 if (desc->opts_mutex) in ext_prop_drop()
1076 mutex_lock(desc->opts_mutex); in ext_prop_drop()
1077 list_del(&ext_prop->entry); in ext_prop_drop()
1078 --desc->ext_prop_count; in ext_prop_drop()
1079 kfree(ext_prop->name); in ext_prop_drop()
1080 desc->ext_prop_len -= (ext_prop->name_len + ext_prop->data_len + 14); in ext_prop_drop()
1081 if (desc->opts_mutex) in ext_prop_drop()
1082 mutex_unlock(desc->opts_mutex); in ext_prop_drop()
1094 memcpy(page, to_usb_os_desc(item)->ext_compat_id, 8); in interf_grp_compatible_id_show()
1105 if (page[l - 1] == '\n') in interf_grp_compatible_id_store()
1106 --l; in interf_grp_compatible_id_store()
1107 if (desc->opts_mutex) in interf_grp_compatible_id_store()
1108 mutex_lock(desc->opts_mutex); in interf_grp_compatible_id_store()
1109 memcpy(desc->ext_compat_id, page, l); in interf_grp_compatible_id_store()
1111 if (desc->opts_mutex) in interf_grp_compatible_id_store()
1112 mutex_unlock(desc->opts_mutex); in interf_grp_compatible_id_store()
1120 memcpy(page, to_usb_os_desc(item)->ext_compat_id + 8, 8); in interf_grp_sub_compatible_id_show()
1131 if (page[l - 1] == '\n') in interf_grp_sub_compatible_id_store()
1132 --l; in interf_grp_sub_compatible_id_store()
1133 if (desc->opts_mutex) in interf_grp_sub_compatible_id_store()
1134 mutex_lock(desc->opts_mutex); in interf_grp_sub_compatible_id_store()
1135 memcpy(desc->ext_compat_id + 8, page, l); in interf_grp_sub_compatible_id_store()
1137 if (desc->opts_mutex) in interf_grp_sub_compatible_id_store()
1138 mutex_unlock(desc->opts_mutex); in interf_grp_sub_compatible_id_store()
1169 return ERR_PTR(-ENOMEM); in usb_os_desc_prepare_interf_dir()
1175 os_desc_type->ct_owner = owner; in usb_os_desc_prepare_interf_dir()
1179 interface_type->ct_group_ops = &interf_grp_ops; in usb_os_desc_prepare_interf_dir()
1180 interface_type->ct_attrs = interf_grp_attrs; in usb_os_desc_prepare_interf_dir()
1181 interface_type->ct_owner = owner; in usb_os_desc_prepare_interf_dir()
1183 while (n_interf--) { in usb_os_desc_prepare_interf_dir()
1187 d->owner = owner; in usb_os_desc_prepare_interf_dir()
1188 config_group_init_type_name(&d->group, "", interface_type); in usb_os_desc_prepare_interf_dir()
1189 config_item_set_name(&d->group.cg_item, "interface.%s", in usb_os_desc_prepare_interf_dir()
1191 configfs_add_default_group(&d->group, os_desc_group); in usb_os_desc_prepare_interf_dir()
1201 return -EINVAL; in configfs_do_nothing()
1204 int composite_dev_prepare(struct usb_composite_driver *composite,
1214 list_for_each_entry(c, &gi->cdev.configs, list) { in purge_configs_funcs()
1220 list_for_each_entry_safe(f, tmp, &c->functions, list) { in purge_configs_funcs()
1222 list_move_tail(&f->list, &cfg->func_list); in purge_configs_funcs()
1223 if (f->unbind) { in purge_configs_funcs()
1224 dev_dbg(&gi->cdev.gadget->dev, in purge_configs_funcs()
1226 f->name, f); in purge_configs_funcs()
1227 f->unbind(c, f); in purge_configs_funcs()
1230 c->next_interface_id = 0; in purge_configs_funcs()
1231 memset(c->interface, 0, sizeof(c->interface)); in purge_configs_funcs()
1232 c->superspeed_plus = 0; in purge_configs_funcs()
1233 c->superspeed = 0; in purge_configs_funcs()
1234 c->highspeed = 0; in purge_configs_funcs()
1235 c->fullspeed = 0; in purge_configs_funcs()
1242 struct usb_composite_driver *composite = to_cdriver(gdriver); in configfs_composite_bind() local
1243 struct gadget_info *gi = container_of(composite, in configfs_composite_bind()
1244 struct gadget_info, composite); in configfs_composite_bind()
1245 struct usb_composite_dev *cdev = &gi->cdev; in configfs_composite_bind()
1251 /* the gi->lock is hold by the caller */ in configfs_composite_bind()
1252 gi->unbind = 0; in configfs_composite_bind()
1253 cdev->gadget = gadget; in configfs_composite_bind()
1255 ret = composite_dev_prepare(composite, cdev); in configfs_composite_bind()
1259 ret = -EINVAL; in configfs_composite_bind()
1261 if (list_empty(&gi->cdev.configs)) { in configfs_composite_bind()
1262 pr_err("Need at least one configuration in %s.\n", in configfs_composite_bind()
1263 gi->composite.name); in configfs_composite_bind()
1268 list_for_each_entry(c, &gi->cdev.configs, list) { in configfs_composite_bind()
1272 if (list_empty(&cfg->func_list)) { in configfs_composite_bind()
1274 c->label, c->bConfigurationValue, in configfs_composite_bind()
1275 gi->composite.name); in configfs_composite_bind()
1281 if (!list_empty(&gi->string_list)) { in configfs_composite_bind()
1285 list_for_each_entry(gs, &gi->string_list, list) { in configfs_composite_bind()
1287 gi->gstrings[i] = &gs->stringtab_dev; in configfs_composite_bind()
1288 gs->stringtab_dev.strings = gs->strings; in configfs_composite_bind()
1289 gs->strings[USB_GADGET_MANUFACTURER_IDX].s = in configfs_composite_bind()
1290 gs->manufacturer; in configfs_composite_bind()
1291 gs->strings[USB_GADGET_PRODUCT_IDX].s = gs->product; in configfs_composite_bind()
1292 gs->strings[USB_GADGET_SERIAL_IDX].s = gs->serialnumber; in configfs_composite_bind()
1295 gi->gstrings[i] = NULL; in configfs_composite_bind()
1296 s = usb_gstrings_attach(&gi->cdev, gi->gstrings, in configfs_composite_bind()
1303 gi->cdev.desc.iManufacturer = s[USB_GADGET_MANUFACTURER_IDX].id; in configfs_composite_bind()
1304 gi->cdev.desc.iProduct = s[USB_GADGET_PRODUCT_IDX].id; in configfs_composite_bind()
1305 gi->cdev.desc.iSerialNumber = s[USB_GADGET_SERIAL_IDX].id; in configfs_composite_bind()
1308 if (gi->use_os_desc) { in configfs_composite_bind()
1309 cdev->use_os_string = true; in configfs_composite_bind()
1310 cdev->b_vendor_code = gi->b_vendor_code; in configfs_composite_bind()
1311 memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); in configfs_composite_bind()
1319 ret = -ENOMEM; in configfs_composite_bind()
1328 list_for_each_entry(c, &gi->cdev.configs, list) { in configfs_composite_bind()
1335 c->descriptors = otg_desc; in configfs_composite_bind()
1338 if (!list_empty(&cfg->string_list)) { in configfs_composite_bind()
1340 list_for_each_entry(cn, &cfg->string_list, list) { in configfs_composite_bind()
1341 cfg->gstrings[i] = &cn->stringtab_dev; in configfs_composite_bind()
1342 cn->stringtab_dev.strings = &cn->strings; in configfs_composite_bind()
1343 cn->strings.s = cn->configuration; in configfs_composite_bind()
1346 cfg->gstrings[i] = NULL; in configfs_composite_bind()
1347 s = usb_gstrings_attach(&gi->cdev, cfg->gstrings, 1); in configfs_composite_bind()
1352 c->iConfiguration = s[0].id; in configfs_composite_bind()
1355 list_for_each_entry_safe(f, tmp, &cfg->func_list, list) { in configfs_composite_bind()
1356 list_del(&f->list); in configfs_composite_bind()
1359 list_add(&f->list, &cfg->func_list); in configfs_composite_bind()
1363 usb_ep_autoconfig_reset(cdev->gadget); in configfs_composite_bind()
1365 if (cdev->use_os_string) { in configfs_composite_bind()
1366 ret = composite_os_desc_req_prepare(cdev, gadget->ep0); in configfs_composite_bind()
1371 usb_ep_autoconfig_reset(cdev->gadget); in configfs_composite_bind()
1387 /* the gi->lock is hold by the caller */ in configfs_composite_unbind()
1391 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_unbind()
1392 gi->unbind = 1; in configfs_composite_unbind()
1393 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_unbind()
1399 usb_ep_autoconfig_reset(cdev->gadget); in configfs_composite_unbind()
1400 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_unbind()
1401 cdev->gadget = NULL; in configfs_composite_unbind()
1403 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_unbind()
1419 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_setup()
1421 if (!cdev || gi->unbind) { in configfs_composite_setup()
1422 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_setup()
1427 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_setup()
1442 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_disconnect()
1444 if (!cdev || gi->unbind) { in configfs_composite_disconnect()
1445 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_disconnect()
1450 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_disconnect()
1464 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_suspend()
1466 if (!cdev || gi->unbind) { in configfs_composite_suspend()
1467 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_suspend()
1472 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_suspend()
1486 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_resume()
1488 if (!cdev || gi->unbind) { in configfs_composite_resume()
1489 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_resume()
1494 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_resume()
1511 .name = "configfs-gadget",
1524 return ERR_PTR(-ENOMEM); in gadgets_make()
1526 config_group_init_type_name(&gi->group, name, &gadget_root_type); in gadgets_make()
1528 config_group_init_type_name(&gi->functions_group, "functions", in gadgets_make()
1530 configfs_add_default_group(&gi->functions_group, &gi->group); in gadgets_make()
1532 config_group_init_type_name(&gi->configs_group, "configs", in gadgets_make()
1534 configfs_add_default_group(&gi->configs_group, &gi->group); in gadgets_make()
1536 config_group_init_type_name(&gi->strings_group, "strings", in gadgets_make()
1538 configfs_add_default_group(&gi->strings_group, &gi->group); in gadgets_make()
1540 config_group_init_type_name(&gi->os_desc_group, "os_desc", in gadgets_make()
1542 configfs_add_default_group(&gi->os_desc_group, &gi->group); in gadgets_make()
1544 gi->composite.bind = configfs_do_nothing; in gadgets_make()
1545 gi->composite.unbind = configfs_do_nothing; in gadgets_make()
1546 gi->composite.suspend = NULL; in gadgets_make()
1547 gi->composite.resume = NULL; in gadgets_make()
1548 gi->composite.max_speed = USB_SPEED_SUPER; in gadgets_make()
1550 spin_lock_init(&gi->spinlock); in gadgets_make()
1551 mutex_init(&gi->lock); in gadgets_make()
1552 INIT_LIST_HEAD(&gi->string_list); in gadgets_make()
1553 INIT_LIST_HEAD(&gi->available_func); in gadgets_make()
1555 composite_init_dev(&gi->cdev); in gadgets_make()
1556 gi->cdev.desc.bLength = USB_DT_DEVICE_SIZE; in gadgets_make()
1557 gi->cdev.desc.bDescriptorType = USB_DT_DEVICE; in gadgets_make()
1558 gi->cdev.desc.bcdDevice = cpu_to_le16(get_default_bcdDevice()); in gadgets_make()
1560 gi->composite.gadget_driver = configfs_driver_template; in gadgets_make()
1562 gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL); in gadgets_make()
1563 gi->composite.name = gi->composite.gadget_driver.function; in gadgets_make()
1565 if (!gi->composite.gadget_driver.function) in gadgets_make()
1568 return &gi->group; in gadgets_make()
1571 return ERR_PTR(-ENOMEM); in gadgets_make()
1603 mutex_lock(&gi->lock); in unregister_gadget_item()
1605 mutex_unlock(&gi->lock); in unregister_gadget_item()