Lines Matching refs:gi

244 	struct gadget_info *gi = to_gadget_info(item);  in gadget_dev_desc_UDC_show()  local
248 mutex_lock(&gi->lock); in gadget_dev_desc_UDC_show()
249 udc_name = gi->composite.gadget_driver.udc_name; in gadget_dev_desc_UDC_show()
251 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_show()
256 static int unregister_gadget(struct gadget_info *gi) in unregister_gadget() argument
260 if (!gi->composite.gadget_driver.udc_name) in unregister_gadget()
263 ret = usb_gadget_unregister_driver(&gi->composite.gadget_driver); in unregister_gadget()
266 kfree(gi->composite.gadget_driver.udc_name); in unregister_gadget()
267 gi->composite.gadget_driver.udc_name = NULL; in unregister_gadget()
274 struct gadget_info *gi = to_gadget_info(item); in gadget_dev_desc_UDC_store() local
287 mutex_lock(&gi->lock); in gadget_dev_desc_UDC_store()
290 ret = unregister_gadget(gi); in gadget_dev_desc_UDC_store()
295 if (gi->composite.gadget_driver.udc_name) { in gadget_dev_desc_UDC_store()
299 gi->composite.gadget_driver.udc_name = name; in gadget_dev_desc_UDC_store()
300 ret = usb_gadget_register_driver(&gi->composite.gadget_driver); in gadget_dev_desc_UDC_store()
302 gi->composite.gadget_driver.udc_name = NULL; in gadget_dev_desc_UDC_store()
306 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_store()
310 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_store()
325 struct gadget_info *gi = to_gadget_info(item); in gadget_dev_desc_max_speed_store() local
327 mutex_lock(&gi->lock); in gadget_dev_desc_max_speed_store()
330 if (gi->composite.gadget_driver.udc_name) in gadget_dev_desc_max_speed_store()
334 gi->composite.max_speed = USB_SPEED_SUPER_PLUS; in gadget_dev_desc_max_speed_store()
336 gi->composite.max_speed = USB_SPEED_SUPER; in gadget_dev_desc_max_speed_store()
338 gi->composite.max_speed = USB_SPEED_HIGH; in gadget_dev_desc_max_speed_store()
340 gi->composite.max_speed = USB_SPEED_FULL; in gadget_dev_desc_max_speed_store()
342 gi->composite.max_speed = USB_SPEED_LOW; in gadget_dev_desc_max_speed_store()
346 gi->composite.gadget_driver.max_speed = gi->composite.max_speed; in gadget_dev_desc_max_speed_store()
348 mutex_unlock(&gi->lock); in gadget_dev_desc_max_speed_store()
351 mutex_unlock(&gi->lock); in gadget_dev_desc_max_speed_store()
402 struct gadget_info *gi = to_gadget_info(item); in gadget_info_attr_release() local
404 WARN_ON(!list_empty(&gi->cdev.configs)); in gadget_info_attr_release()
405 WARN_ON(!list_empty(&gi->string_list)); in gadget_info_attr_release()
406 WARN_ON(!list_empty(&gi->available_func)); in gadget_info_attr_release()
407 kfree(gi->composite.gadget_driver.function); in gadget_info_attr_release()
408 kfree(gi->composite.gadget_driver.driver.name); in gadget_info_attr_release()
409 kfree(gi); in gadget_info_attr_release()
431 struct gadget_info *gi = cfg_to_gadget_info(cfg); in config_usb_cfg_link() local
439 mutex_lock(&gi->lock); in config_usb_cfg_link()
446 if (gi->composite.gadget_driver.udc_name) { in config_usb_cfg_link()
451 list_for_each_entry(iter, &gi->available_func, cfs_list) { in config_usb_cfg_link()
479 mutex_unlock(&gi->lock); in config_usb_cfg_link()
488 struct gadget_info *gi = cfg_to_gadget_info(cfg); in config_usb_cfg_unlink() local
500 mutex_lock(&gi->lock); in config_usb_cfg_unlink()
501 if (gi->composite.gadget_driver.udc_name) in config_usb_cfg_unlink()
502 unregister_gadget(gi); in config_usb_cfg_unlink()
503 WARN_ON(gi->composite.gadget_driver.udc_name); in config_usb_cfg_unlink()
509 mutex_unlock(&gi->lock); in config_usb_cfg_unlink()
513 mutex_unlock(&gi->lock); in config_usb_cfg_unlink()
605 struct gadget_info *gi; in function_make() local
643 gi = container_of(group, struct gadget_info, functions_group); in function_make()
645 mutex_lock(&gi->lock); in function_make()
646 list_add_tail(&fi->cfs_list, &gi->available_func); in function_make()
647 mutex_unlock(&gi->lock); in function_make()
656 struct gadget_info *gi; in function_drop() local
658 gi = container_of(group, struct gadget_info, functions_group); in function_drop()
660 mutex_lock(&gi->lock); in function_drop()
662 mutex_unlock(&gi->lock); in function_drop()
700 struct gadget_info *gi; in config_desc_make() local
707 gi = container_of(group, struct gadget_info, configs_group); in config_desc_make()
751 ret = usb_add_config_only(&gi->cdev, &cfg->c); in config_desc_make()
915 struct gadget_info *gi; in gadget_language_make() local
931 gi = container_of(group, struct gadget_info, strings_group); in gadget_language_make()
933 list_for_each_entry(gs, &gi->string_list, list) { in gadget_language_make()
942 list_add_tail(&new->list, &gi->string_list); in gadget_language_make()
985 struct gadget_info *gi = webusb_item_to_gadget_info(item); in webusb_use_store() local
993 mutex_lock(&gi->lock); in webusb_use_store()
994 gi->use_webusb = use; in webusb_use_store()
995 mutex_unlock(&gi->lock); in webusb_use_store()
1009 struct gadget_info *gi = webusb_item_to_gadget_info(item); in webusb_bcdVersion_store() local
1021 mutex_lock(&gi->lock); in webusb_bcdVersion_store()
1022 gi->bcd_webusb_version = bcdVersion; in webusb_bcdVersion_store()
1023 mutex_unlock(&gi->lock); in webusb_bcdVersion_store()
1037 struct gadget_info *gi = webusb_item_to_gadget_info(item); in webusb_bVendorCode_store() local
1045 mutex_lock(&gi->lock); in webusb_bVendorCode_store()
1046 gi->b_webusb_vendor_code = b_vendor_code; in webusb_bVendorCode_store()
1047 mutex_unlock(&gi->lock); in webusb_bVendorCode_store()
1060 struct gadget_info *gi = webusb_item_to_gadget_info(item); in webusb_landingPage_store() local
1069 if (l > sizeof(gi->landing_page)) { in webusb_landingPage_store()
1088 mutex_lock(&gi->lock); in webusb_landingPage_store()
1090 memcpy_and_pad(gi->landing_page, sizeof(gi->landing_page), page, l, 0); in webusb_landingPage_store()
1091 mutex_unlock(&gi->lock); in webusb_landingPage_store()
1130 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_use_store() local
1138 mutex_lock(&gi->lock); in os_desc_use_store()
1139 gi->use_os_desc = use; in os_desc_use_store()
1140 mutex_unlock(&gi->lock); in os_desc_use_store()
1154 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_b_vendor_code_store() local
1162 mutex_lock(&gi->lock); in os_desc_b_vendor_code_store()
1163 gi->b_vendor_code = b_vendor_code; in os_desc_b_vendor_code_store()
1164 mutex_unlock(&gi->lock); in os_desc_b_vendor_code_store()
1171 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_qw_sign_show() local
1174 res = utf16s_to_utf8s((wchar_t *) gi->qw_sign, OS_STRING_QW_SIGN_LEN, in os_desc_qw_sign_show()
1184 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_qw_sign_store() local
1191 mutex_lock(&gi->lock); in os_desc_qw_sign_store()
1193 UTF16_LITTLE_ENDIAN, (wchar_t *) gi->qw_sign, in os_desc_qw_sign_store()
1197 mutex_unlock(&gi->lock); in os_desc_qw_sign_store()
1216 struct gadget_info *gi = os_desc_item_to_gadget_info(os_desc_ci); in os_desc_link() local
1217 struct usb_composite_dev *cdev = &gi->cdev; in os_desc_link()
1222 mutex_lock(&gi->lock); in os_desc_link()
1243 mutex_unlock(&gi->lock); in os_desc_link()
1250 struct gadget_info *gi = os_desc_item_to_gadget_info(os_desc_ci); in os_desc_unlink() local
1251 struct usb_composite_dev *cdev = &gi->cdev; in os_desc_unlink()
1253 mutex_lock(&gi->lock); in os_desc_unlink()
1254 if (gi->composite.gadget_driver.udc_name) in os_desc_unlink()
1255 unregister_gadget(gi); in os_desc_unlink()
1257 WARN_ON(gi->composite.gadget_driver.udc_name); in os_desc_unlink()
1258 mutex_unlock(&gi->lock); in os_desc_unlink()
1575 static void purge_configs_funcs(struct gadget_info *gi) in purge_configs_funcs() argument
1579 list_for_each_entry(c, &gi->cdev.configs, list) { in purge_configs_funcs()
1589 dev_dbg(&gi->cdev.gadget->dev, in purge_configs_funcs()
1605 configfs_attach_gadget_strings(struct gadget_info *gi) in configfs_attach_gadget_strings() argument
1617 list_for_each(iter, &gi->string_list) in configfs_attach_gadget_strings()
1629 list_for_each_entry(language, &gi->string_list, list) { in configfs_attach_gadget_strings()
1665 us = usb_gstrings_attach(&gi->cdev, gadget_strings, nstrings); in configfs_attach_gadget_strings()
1668 list_for_each_entry(language, &gi->string_list, list) { in configfs_attach_gadget_strings()
1682 struct gadget_info *gi = container_of(composite, in configfs_composite_bind() local
1684 struct usb_composite_dev *cdev = &gi->cdev; in configfs_composite_bind()
1691 gi->unbind = 0; in configfs_composite_bind()
1700 if (list_empty(&gi->cdev.configs)) { in configfs_composite_bind()
1702 gi->composite.name); in configfs_composite_bind()
1707 list_for_each_entry(c, &gi->cdev.configs, list) { in configfs_composite_bind()
1714 gi->composite.name); in configfs_composite_bind()
1720 if (!list_empty(&gi->string_list)) { in configfs_composite_bind()
1721 s = configfs_attach_gadget_strings(gi); in configfs_composite_bind()
1727 gi->cdev.desc.iManufacturer = s[USB_GADGET_MANUFACTURER_IDX].id; in configfs_composite_bind()
1728 gi->cdev.desc.iProduct = s[USB_GADGET_PRODUCT_IDX].id; in configfs_composite_bind()
1729 gi->cdev.desc.iSerialNumber = s[USB_GADGET_SERIAL_IDX].id; in configfs_composite_bind()
1731 gi->cdev.usb_strings = s; in configfs_composite_bind()
1734 if (gi->use_webusb) { in configfs_composite_bind()
1736 cdev->bcd_webusb_version = gi->bcd_webusb_version; in configfs_composite_bind()
1737 cdev->b_webusb_vendor_code = gi->b_webusb_vendor_code; in configfs_composite_bind()
1738 memcpy(cdev->landing_page, gi->landing_page, WEBUSB_URL_RAW_MAX_LENGTH); in configfs_composite_bind()
1741 if (gi->use_os_desc) { in configfs_composite_bind()
1743 cdev->b_vendor_code = gi->b_vendor_code; in configfs_composite_bind()
1744 memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); in configfs_composite_bind()
1761 list_for_each_entry(c, &gi->cdev.configs, list) { in configfs_composite_bind()
1783 s = usb_gstrings_attach(&gi->cdev, cfg->gstrings, 1); in configfs_composite_bind()
1815 purge_configs_funcs(gi); in configfs_composite_bind()
1824 struct gadget_info *gi; in configfs_composite_unbind() local
1830 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_unbind()
1831 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_unbind()
1832 gi->unbind = 1; in configfs_composite_unbind()
1833 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_unbind()
1837 purge_configs_funcs(gi); in configfs_composite_unbind()
1840 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_unbind()
1845 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_unbind()
1852 struct gadget_info *gi; in configfs_composite_setup() local
1860 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_setup()
1861 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_setup()
1863 if (!cdev || gi->unbind) { in configfs_composite_setup()
1864 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_setup()
1869 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_setup()
1876 struct gadget_info *gi; in configfs_composite_disconnect() local
1883 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_disconnect()
1884 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_disconnect()
1886 if (!cdev || gi->unbind) { in configfs_composite_disconnect()
1887 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_disconnect()
1892 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_disconnect()
1898 struct gadget_info *gi; in configfs_composite_reset() local
1905 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_reset()
1906 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_reset()
1908 if (!cdev || gi->unbind) { in configfs_composite_reset()
1909 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_reset()
1914 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_reset()
1920 struct gadget_info *gi; in configfs_composite_suspend() local
1927 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_suspend()
1928 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_suspend()
1930 if (!cdev || gi->unbind) { in configfs_composite_suspend()
1931 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_suspend()
1936 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_suspend()
1942 struct gadget_info *gi; in configfs_composite_resume() local
1949 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_resume()
1950 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_resume()
1952 if (!cdev || gi->unbind) { in configfs_composite_resume()
1953 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_resume()
1958 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_resume()
1983 struct gadget_info *gi; in gadgets_make() local
1985 gi = kzalloc(sizeof(*gi), GFP_KERNEL); in gadgets_make()
1986 if (!gi) in gadgets_make()
1989 config_group_init_type_name(&gi->group, name, &gadget_root_type); in gadgets_make()
1991 config_group_init_type_name(&gi->functions_group, "functions", in gadgets_make()
1993 configfs_add_default_group(&gi->functions_group, &gi->group); in gadgets_make()
1995 config_group_init_type_name(&gi->configs_group, "configs", in gadgets_make()
1997 configfs_add_default_group(&gi->configs_group, &gi->group); in gadgets_make()
1999 config_group_init_type_name(&gi->strings_group, "strings", in gadgets_make()
2001 configfs_add_default_group(&gi->strings_group, &gi->group); in gadgets_make()
2003 config_group_init_type_name(&gi->os_desc_group, "os_desc", in gadgets_make()
2005 configfs_add_default_group(&gi->os_desc_group, &gi->group); in gadgets_make()
2007 config_group_init_type_name(&gi->webusb_group, "webusb", in gadgets_make()
2009 configfs_add_default_group(&gi->webusb_group, &gi->group); in gadgets_make()
2011 gi->composite.bind = configfs_do_nothing; in gadgets_make()
2012 gi->composite.unbind = configfs_do_nothing; in gadgets_make()
2013 gi->composite.suspend = NULL; in gadgets_make()
2014 gi->composite.resume = NULL; in gadgets_make()
2015 gi->composite.max_speed = USB_SPEED_SUPER_PLUS; in gadgets_make()
2017 spin_lock_init(&gi->spinlock); in gadgets_make()
2018 mutex_init(&gi->lock); in gadgets_make()
2019 INIT_LIST_HEAD(&gi->string_list); in gadgets_make()
2020 INIT_LIST_HEAD(&gi->available_func); in gadgets_make()
2022 composite_init_dev(&gi->cdev); in gadgets_make()
2023 gi->cdev.desc.bLength = USB_DT_DEVICE_SIZE; in gadgets_make()
2024 gi->cdev.desc.bDescriptorType = USB_DT_DEVICE; in gadgets_make()
2025 gi->cdev.desc.bcdDevice = cpu_to_le16(get_default_bcdDevice()); in gadgets_make()
2027 gi->composite.gadget_driver = configfs_driver_template; in gadgets_make()
2029 gi->composite.gadget_driver.driver.name = kasprintf(GFP_KERNEL, in gadgets_make()
2031 if (!gi->composite.gadget_driver.driver.name) in gadgets_make()
2034 gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL); in gadgets_make()
2035 gi->composite.name = gi->composite.gadget_driver.function; in gadgets_make()
2037 if (!gi->composite.gadget_driver.function) in gadgets_make()
2040 return &gi->group; in gadgets_make()
2043 kfree(gi->composite.gadget_driver.driver.name); in gadgets_make()
2045 kfree(gi); in gadgets_make()
2076 struct gadget_info *gi = to_gadget_info(item); in unregister_gadget_item() local
2078 mutex_lock(&gi->lock); in unregister_gadget_item()
2079 unregister_gadget(gi); in unregister_gadget_item()
2080 mutex_unlock(&gi->lock); in unregister_gadget_item()