• Home
  • Raw
  • Download

Lines Matching refs:gi

262 	struct gadget_info *gi = to_gadget_info(item);  in gadget_dev_desc_UDC_show()  local
266 mutex_lock(&gi->lock); in gadget_dev_desc_UDC_show()
267 udc_name = gi->composite.gadget_driver.udc_name; in gadget_dev_desc_UDC_show()
269 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_show()
274 static int unregister_gadget(struct gadget_info *gi) in unregister_gadget() argument
278 if (!gi->composite.gadget_driver.udc_name) in unregister_gadget()
281 ret = usb_gadget_unregister_driver(&gi->composite.gadget_driver); in unregister_gadget()
284 kfree(gi->composite.gadget_driver.udc_name); in unregister_gadget()
285 gi->composite.gadget_driver.udc_name = NULL; in unregister_gadget()
292 struct gadget_info *gi = to_gadget_info(item); in gadget_dev_desc_UDC_store() local
305 mutex_lock(&gi->lock); in gadget_dev_desc_UDC_store()
308 ret = unregister_gadget(gi); in gadget_dev_desc_UDC_store()
313 if (gi->composite.gadget_driver.udc_name) { in gadget_dev_desc_UDC_store()
317 gi->composite.gadget_driver.udc_name = name; in gadget_dev_desc_UDC_store()
318 ret = usb_gadget_probe_driver(&gi->composite.gadget_driver); in gadget_dev_desc_UDC_store()
320 gi->composite.gadget_driver.udc_name = NULL; in gadget_dev_desc_UDC_store()
324 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_store()
328 mutex_unlock(&gi->lock); in gadget_dev_desc_UDC_store()
343 struct gadget_info *gi = to_gadget_info(item); in gadget_dev_desc_max_speed_store() local
345 mutex_lock(&gi->lock); in gadget_dev_desc_max_speed_store()
348 if (gi->composite.gadget_driver.udc_name) in gadget_dev_desc_max_speed_store()
352 gi->composite.max_speed = USB_SPEED_SUPER_PLUS; in gadget_dev_desc_max_speed_store()
354 gi->composite.max_speed = USB_SPEED_SUPER; in gadget_dev_desc_max_speed_store()
356 gi->composite.max_speed = USB_SPEED_HIGH; in gadget_dev_desc_max_speed_store()
358 gi->composite.max_speed = USB_SPEED_FULL; in gadget_dev_desc_max_speed_store()
360 gi->composite.max_speed = USB_SPEED_LOW; in gadget_dev_desc_max_speed_store()
364 gi->composite.gadget_driver.max_speed = gi->composite.max_speed; in gadget_dev_desc_max_speed_store()
366 mutex_unlock(&gi->lock); in gadget_dev_desc_max_speed_store()
369 mutex_unlock(&gi->lock); in gadget_dev_desc_max_speed_store()
420 struct gadget_info *gi = to_gadget_info(item); in gadget_info_attr_release() local
422 WARN_ON(!list_empty(&gi->cdev.configs)); in gadget_info_attr_release()
423 WARN_ON(!list_empty(&gi->string_list)); in gadget_info_attr_release()
424 WARN_ON(!list_empty(&gi->available_func)); in gadget_info_attr_release()
425 kfree(gi->composite.gadget_driver.function); in gadget_info_attr_release()
426 kfree(gi); in gadget_info_attr_release()
449 struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev); in config_usb_cfg_link() local
457 mutex_lock(&gi->lock); in config_usb_cfg_link()
464 if (gi->composite.gadget_driver.udc_name) { in config_usb_cfg_link()
469 list_for_each_entry(iter, &gi->available_func, cfs_list) { in config_usb_cfg_link()
497 mutex_unlock(&gi->lock); in config_usb_cfg_link()
507 struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev); in config_usb_cfg_unlink() local
519 mutex_lock(&gi->lock); in config_usb_cfg_unlink()
520 if (gi->composite.gadget_driver.udc_name) in config_usb_cfg_unlink()
521 unregister_gadget(gi); in config_usb_cfg_unlink()
522 WARN_ON(gi->composite.gadget_driver.udc_name); in config_usb_cfg_unlink()
528 mutex_unlock(&gi->lock); in config_usb_cfg_unlink()
532 mutex_unlock(&gi->lock); in config_usb_cfg_unlink()
619 struct gadget_info *gi; in function_make() local
656 gi = container_of(group, struct gadget_info, functions_group); in function_make()
658 mutex_lock(&gi->lock); in function_make()
659 list_add_tail(&fi->cfs_list, &gi->available_func); in function_make()
660 mutex_unlock(&gi->lock); in function_make()
669 struct gadget_info *gi; in function_drop() local
671 gi = container_of(group, struct gadget_info, functions_group); in function_drop()
673 mutex_lock(&gi->lock); in function_drop()
675 mutex_unlock(&gi->lock); in function_drop()
713 struct gadget_info *gi; in config_desc_make() local
720 gi = container_of(group, struct gadget_info, configs_group); in config_desc_make()
762 ret = usb_add_config_only(&gi->cdev, &cfg->c); in config_desc_make()
836 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_use_store() local
840 mutex_lock(&gi->lock); in os_desc_use_store()
843 gi->use_os_desc = use; in os_desc_use_store()
846 mutex_unlock(&gi->lock); in os_desc_use_store()
860 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_b_vendor_code_store() local
864 mutex_lock(&gi->lock); in os_desc_b_vendor_code_store()
867 gi->b_vendor_code = b_vendor_code; in os_desc_b_vendor_code_store()
870 mutex_unlock(&gi->lock); in os_desc_b_vendor_code_store()
877 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_qw_sign_show() local
880 res = utf16s_to_utf8s((wchar_t *) gi->qw_sign, OS_STRING_QW_SIGN_LEN, in os_desc_qw_sign_show()
890 struct gadget_info *gi = os_desc_item_to_gadget_info(item); in os_desc_qw_sign_store() local
897 mutex_lock(&gi->lock); in os_desc_qw_sign_store()
899 UTF16_LITTLE_ENDIAN, (wchar_t *) gi->qw_sign, in os_desc_qw_sign_store()
903 mutex_unlock(&gi->lock); in os_desc_qw_sign_store()
928 struct gadget_info *gi = container_of(to_config_group(os_desc_ci), in os_desc_link() local
930 struct usb_composite_dev *cdev = &gi->cdev; in os_desc_link()
935 mutex_lock(&gi->lock); in os_desc_link()
956 mutex_unlock(&gi->lock); in os_desc_link()
963 struct gadget_info *gi = container_of(to_config_group(os_desc_ci), in os_desc_unlink() local
965 struct usb_composite_dev *cdev = &gi->cdev; in os_desc_unlink()
967 mutex_lock(&gi->lock); in os_desc_unlink()
968 if (gi->composite.gadget_driver.udc_name) in os_desc_unlink()
969 unregister_gadget(gi); in os_desc_unlink()
971 WARN_ON(gi->composite.gadget_driver.udc_name); in os_desc_unlink()
972 mutex_unlock(&gi->lock); in os_desc_unlink()
1292 static void purge_configs_funcs(struct gadget_info *gi) in purge_configs_funcs() argument
1296 list_for_each_entry(c, &gi->cdev.configs, list) { in purge_configs_funcs()
1306 dev_dbg(&gi->cdev.gadget->dev, in purge_configs_funcs()
1325 struct gadget_info *gi = container_of(composite, in configfs_composite_bind() local
1327 struct usb_composite_dev *cdev = &gi->cdev; in configfs_composite_bind()
1334 gi->unbind = 0; in configfs_composite_bind()
1343 if (list_empty(&gi->cdev.configs)) { in configfs_composite_bind()
1345 gi->composite.name); in configfs_composite_bind()
1350 list_for_each_entry(c, &gi->cdev.configs, list) { in configfs_composite_bind()
1357 gi->composite.name); in configfs_composite_bind()
1363 if (!list_empty(&gi->string_list)) { in configfs_composite_bind()
1367 list_for_each_entry(gs, &gi->string_list, list) { in configfs_composite_bind()
1369 gi->gstrings[i] = &gs->stringtab_dev; in configfs_composite_bind()
1377 gi->gstrings[i] = NULL; in configfs_composite_bind()
1378 s = usb_gstrings_attach(&gi->cdev, gi->gstrings, in configfs_composite_bind()
1385 gi->cdev.desc.iManufacturer = s[USB_GADGET_MANUFACTURER_IDX].id; in configfs_composite_bind()
1386 gi->cdev.desc.iProduct = s[USB_GADGET_PRODUCT_IDX].id; in configfs_composite_bind()
1387 gi->cdev.desc.iSerialNumber = s[USB_GADGET_SERIAL_IDX].id; in configfs_composite_bind()
1390 if (gi->use_os_desc) { in configfs_composite_bind()
1392 cdev->b_vendor_code = gi->b_vendor_code; in configfs_composite_bind()
1393 memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); in configfs_composite_bind()
1410 list_for_each_entry(c, &gi->cdev.configs, list) { in configfs_composite_bind()
1429 s = usb_gstrings_attach(&gi->cdev, cfg->gstrings, 1); in configfs_composite_bind()
1461 purge_configs_funcs(gi); in configfs_composite_bind()
1470 struct gadget_info *gi = container_of(data, struct gadget_info, work); in android_work() local
1471 struct usb_composite_dev *cdev = &gi->cdev; in android_work()
1484 if (gi->connected != gi->sw_connected) { in android_work()
1485 if (gi->connected) in android_work()
1489 gi->sw_connected = gi->connected; in android_work()
1494 kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, connected); in android_work()
1500 kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, configured); in android_work()
1506 kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, disconnected); in android_work()
1513 gi->connected, gi->sw_connected, cdev->config); in android_work()
1521 struct gadget_info *gi; in configfs_composite_unbind() local
1527 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_unbind()
1528 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_unbind()
1529 gi->unbind = 1; in configfs_composite_unbind()
1530 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_unbind()
1534 purge_configs_funcs(gi); in configfs_composite_unbind()
1537 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_unbind()
1542 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_unbind()
1551 struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev); in android_setup() local
1556 if (!gi->connected) { in android_setup()
1557 gi->connected = 1; in android_setup()
1558 schedule_work(&gi->work); in android_setup()
1561 list_for_each_entry(fi, &gi->available_func, cfs_list) { in android_setup()
1575 spin_lock_irqsave(&gi->spinlock, flags); in android_setup()
1577 spin_unlock_irqrestore(&gi->spinlock, flags); in android_setup()
1583 schedule_work(&gi->work); in android_setup()
1596 struct gadget_info *gi; in configfs_composite_setup() local
1604 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_setup()
1605 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_setup()
1607 if (!cdev || gi->unbind) { in configfs_composite_setup()
1608 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_setup()
1613 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_setup()
1622 struct gadget_info *gi; in configfs_composite_disconnect() local
1637 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_disconnect()
1638 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_disconnect()
1640 if (!cdev || gi->unbind) { in configfs_composite_disconnect()
1641 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_disconnect()
1646 gi->connected = 0; in configfs_composite_disconnect()
1647 schedule_work(&gi->work); in configfs_composite_disconnect()
1650 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_disconnect()
1656 struct gadget_info *gi; in configfs_composite_reset() local
1663 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_reset()
1664 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_reset()
1666 if (!cdev || gi->unbind) { in configfs_composite_reset()
1667 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_reset()
1672 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_reset()
1678 struct gadget_info *gi; in configfs_composite_suspend() local
1685 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_suspend()
1686 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_suspend()
1688 if (!cdev || gi->unbind) { in configfs_composite_suspend()
1689 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_suspend()
1694 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_suspend()
1700 struct gadget_info *gi; in configfs_composite_resume() local
1707 gi = container_of(cdev, struct gadget_info, cdev); in configfs_composite_resume()
1708 spin_lock_irqsave(&gi->spinlock, flags); in configfs_composite_resume()
1710 if (!cdev || gi->unbind) { in configfs_composite_resume()
1711 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_resume()
1716 spin_unlock_irqrestore(&gi->spinlock, flags); in configfs_composite_resume()
1775 static int android_device_create(struct gadget_info *gi) in android_device_create() argument
1780 INIT_WORK(&gi->work, android_work); in android_device_create()
1781 gi->dev = device_create(android_class, NULL, in android_device_create()
1783 if (IS_ERR(gi->dev)) in android_device_create()
1784 return PTR_ERR(gi->dev); in android_device_create()
1786 dev_set_drvdata(gi->dev, gi); in android_device_create()
1788 android_device = gi->dev; in android_device_create()
1794 err = device_create_file(gi->dev, attr); in android_device_create()
1796 device_destroy(gi->dev->class, in android_device_create()
1797 gi->dev->devt); in android_device_create()
1805 static void android_device_destroy(struct gadget_info *gi) in android_device_destroy() argument
1812 device_remove_file(gi->dev, attr); in android_device_destroy()
1813 device_destroy(gi->dev->class, gi->dev->devt); in android_device_destroy()
1816 static inline int android_device_create(struct gadget_info *gi) in android_device_create() argument
1821 static inline void android_device_destroy(struct gadget_info *gi) in android_device_destroy() argument
1830 struct gadget_info *gi; in gadgets_make() local
1832 gi = kzalloc(sizeof(*gi), GFP_KERNEL); in gadgets_make()
1833 if (!gi) in gadgets_make()
1836 config_group_init_type_name(&gi->group, name, &gadget_root_type); in gadgets_make()
1838 config_group_init_type_name(&gi->functions_group, "functions", in gadgets_make()
1840 configfs_add_default_group(&gi->functions_group, &gi->group); in gadgets_make()
1842 config_group_init_type_name(&gi->configs_group, "configs", in gadgets_make()
1844 configfs_add_default_group(&gi->configs_group, &gi->group); in gadgets_make()
1846 config_group_init_type_name(&gi->strings_group, "strings", in gadgets_make()
1848 configfs_add_default_group(&gi->strings_group, &gi->group); in gadgets_make()
1850 config_group_init_type_name(&gi->os_desc_group, "os_desc", in gadgets_make()
1852 configfs_add_default_group(&gi->os_desc_group, &gi->group); in gadgets_make()
1854 gi->composite.bind = configfs_do_nothing; in gadgets_make()
1855 gi->composite.unbind = configfs_do_nothing; in gadgets_make()
1856 gi->composite.suspend = NULL; in gadgets_make()
1857 gi->composite.resume = NULL; in gadgets_make()
1858 gi->composite.max_speed = USB_SPEED_SUPER_PLUS; in gadgets_make()
1860 spin_lock_init(&gi->spinlock); in gadgets_make()
1861 mutex_init(&gi->lock); in gadgets_make()
1862 INIT_LIST_HEAD(&gi->string_list); in gadgets_make()
1863 INIT_LIST_HEAD(&gi->available_func); in gadgets_make()
1865 composite_init_dev(&gi->cdev); in gadgets_make()
1866 gi->cdev.desc.bLength = USB_DT_DEVICE_SIZE; in gadgets_make()
1867 gi->cdev.desc.bDescriptorType = USB_DT_DEVICE; in gadgets_make()
1868 gi->cdev.desc.bcdDevice = cpu_to_le16(get_default_bcdDevice()); in gadgets_make()
1870 gi->composite.gadget_driver = configfs_driver_template; in gadgets_make()
1872 gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL); in gadgets_make()
1873 gi->composite.name = gi->composite.gadget_driver.function; in gadgets_make()
1875 if (!gi->composite.gadget_driver.function) in gadgets_make()
1878 if (android_device_create(gi) < 0) in gadgets_make()
1881 return &gi->group; in gadgets_make()
1884 kfree(gi); in gadgets_make()
1890 struct gadget_info *gi; in gadgets_drop() local
1892 gi = container_of(to_config_group(item), struct gadget_info, group); in gadgets_drop()
1894 android_device_destroy(gi); in gadgets_drop()
1919 struct gadget_info *gi = to_gadget_info(item); in unregister_gadget_item() local
1921 mutex_lock(&gi->lock); in unregister_gadget_item()
1922 unregister_gadget(gi); in unregister_gadget_item()
1923 mutex_unlock(&gi->lock); in unregister_gadget_item()