Loading drivers/usb/gadget/configfs.c +30 −16 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ void acc_disconnect(void); static struct class *android_class; static struct device *android_device; static int index; static int gadget_index; struct device *create_function_device(char *name) { Loading Loading @@ -1425,21 +1426,21 @@ static void android_work(struct work_struct *data) spin_unlock_irqrestore(&cdev->lock, flags); if (status[0]) { kobject_uevent_env(&android_device->kobj, kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, connected); pr_info("%s: sent uevent %s\n", __func__, connected[0]); uevent_sent = true; } if (status[1]) { kobject_uevent_env(&android_device->kobj, kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, configured); pr_info("%s: sent uevent %s\n", __func__, configured[0]); uevent_sent = true; } if (status[2]) { kobject_uevent_env(&android_device->kobj, kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, disconnected); pr_info("%s: sent uevent %s\n", __func__, disconnected[0]); uevent_sent = true; Loading Loading @@ -1600,23 +1601,28 @@ static int android_device_create(struct gadget_info *gi) { struct device_attribute **attrs; struct device_attribute *attr; char str[10]; INIT_WORK(&gi->work, android_work); android_device = device_create(android_class, NULL, MKDEV(0, 0), NULL, "android0"); if (IS_ERR(android_device)) return PTR_ERR(android_device); snprintf(str, sizeof(str), "android%d", gadget_index - 1); pr_debug("Creating android device %s\n", str); gi->dev = device_create(android_class, NULL, MKDEV(0, 0), NULL, str); if (IS_ERR(gi->dev)) return PTR_ERR(gi->dev); dev_set_drvdata(android_device, gi); dev_set_drvdata(gi->dev, gi); if (gadget_index == 1) android_device = gi->dev; attrs = android_usb_attributes; while ((attr = *attrs++)) { int err; err = device_create_file(android_device, attr); err = device_create_file(gi->dev, attr); if (err) { device_destroy(android_device->class, android_device->devt); device_destroy(gi->dev->class, gi->dev->devt); return err; } } Loading @@ -1624,15 +1630,15 @@ static int android_device_create(struct gadget_info *gi) return 0; } static void android_device_destroy(void) static void android_device_destroy(struct device *dev) { struct device_attribute **attrs; struct device_attribute *attr; attrs = android_usb_attributes; while ((attr = *attrs++)) device_remove_file(android_device, attr); device_destroy(android_device->class, android_device->devt); device_remove_file(dev, attr); device_destroy(dev->class, dev->devt); } #else static inline int android_device_create(struct gadget_info *gi) Loading @@ -1640,7 +1646,7 @@ static inline int android_device_create(struct gadget_info *gi) return 0; } static inline void android_device_destroy(void) static inline void android_device_destroy(struct device *dev) { } #endif Loading Loading @@ -1696,6 +1702,8 @@ static struct config_group *gadgets_make( if (!gi->composite.gadget_driver.function) goto err; gadget_index++; pr_debug("Creating gadget index %d\n", gadget_index); if (android_device_create(gi) < 0) goto err; Loading @@ -1708,8 +1716,14 @@ static struct config_group *gadgets_make( static void gadgets_drop(struct config_group *group, struct config_item *item) { struct gadget_info *gi; gi = container_of(to_config_group(item), struct gadget_info, group); config_item_put(item); android_device_destroy(); if (gi->dev) { android_device_destroy(gi->dev); gi->dev = NULL; } } static struct configfs_group_operations gadgets_ops = { Loading Loading
drivers/usb/gadget/configfs.c +30 −16 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ void acc_disconnect(void); static struct class *android_class; static struct device *android_device; static int index; static int gadget_index; struct device *create_function_device(char *name) { Loading Loading @@ -1425,21 +1426,21 @@ static void android_work(struct work_struct *data) spin_unlock_irqrestore(&cdev->lock, flags); if (status[0]) { kobject_uevent_env(&android_device->kobj, kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, connected); pr_info("%s: sent uevent %s\n", __func__, connected[0]); uevent_sent = true; } if (status[1]) { kobject_uevent_env(&android_device->kobj, kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, configured); pr_info("%s: sent uevent %s\n", __func__, configured[0]); uevent_sent = true; } if (status[2]) { kobject_uevent_env(&android_device->kobj, kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, disconnected); pr_info("%s: sent uevent %s\n", __func__, disconnected[0]); uevent_sent = true; Loading Loading @@ -1600,23 +1601,28 @@ static int android_device_create(struct gadget_info *gi) { struct device_attribute **attrs; struct device_attribute *attr; char str[10]; INIT_WORK(&gi->work, android_work); android_device = device_create(android_class, NULL, MKDEV(0, 0), NULL, "android0"); if (IS_ERR(android_device)) return PTR_ERR(android_device); snprintf(str, sizeof(str), "android%d", gadget_index - 1); pr_debug("Creating android device %s\n", str); gi->dev = device_create(android_class, NULL, MKDEV(0, 0), NULL, str); if (IS_ERR(gi->dev)) return PTR_ERR(gi->dev); dev_set_drvdata(android_device, gi); dev_set_drvdata(gi->dev, gi); if (gadget_index == 1) android_device = gi->dev; attrs = android_usb_attributes; while ((attr = *attrs++)) { int err; err = device_create_file(android_device, attr); err = device_create_file(gi->dev, attr); if (err) { device_destroy(android_device->class, android_device->devt); device_destroy(gi->dev->class, gi->dev->devt); return err; } } Loading @@ -1624,15 +1630,15 @@ static int android_device_create(struct gadget_info *gi) return 0; } static void android_device_destroy(void) static void android_device_destroy(struct device *dev) { struct device_attribute **attrs; struct device_attribute *attr; attrs = android_usb_attributes; while ((attr = *attrs++)) device_remove_file(android_device, attr); device_destroy(android_device->class, android_device->devt); device_remove_file(dev, attr); device_destroy(dev->class, dev->devt); } #else static inline int android_device_create(struct gadget_info *gi) Loading @@ -1640,7 +1646,7 @@ static inline int android_device_create(struct gadget_info *gi) return 0; } static inline void android_device_destroy(void) static inline void android_device_destroy(struct device *dev) { } #endif Loading Loading @@ -1696,6 +1702,8 @@ static struct config_group *gadgets_make( if (!gi->composite.gadget_driver.function) goto err; gadget_index++; pr_debug("Creating gadget index %d\n", gadget_index); if (android_device_create(gi) < 0) goto err; Loading @@ -1708,8 +1716,14 @@ static struct config_group *gadgets_make( static void gadgets_drop(struct config_group *group, struct config_item *item) { struct gadget_info *gi; gi = container_of(to_config_group(item), struct gadget_info, group); config_item_put(item); android_device_destroy(); if (gi->dev) { android_device_destroy(gi->dev); gi->dev = NULL; } } static struct configfs_group_operations gadgets_ops = { Loading