aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/configfs.c
diff options
context:
space:
mode:
authorKevin Hilman <khilman@linaro.org>2015-09-10 13:26:56 -0700
committerKevin Hilman <khilman@linaro.org>2015-09-10 13:26:56 -0700
commit070565aed13c16e108f35bcedb8ad22782683735 (patch)
tree8b3de1bf2101c8c1c93822f5583c5838fef8c8cc /drivers/usb/gadget/configfs.c
parent829e8333fe5de8b1f43c042d213fe45358e4ee4d (diff)
parent3ac97f2411ad66f872bd0fe401ad94af5ff4d7d3 (diff)
Merge branch 'android-3.18' of https://android.googlesource.com/kernel/common into linux-linaro-lsk-v3.18-android
* 'android-3.18' of https://android.googlesource.com/kernel/common: (26 commits) net: fix crash in tcp_nuke_addr() net: xt_qtaguid/xt_socket: fix refcount underflow and crash net: fix iterating over hashtable in tcp_nuke_addr() nf: IDLETIMER: fix lockdep warning ANDROID: usb: gadget: create F_midi device usb: gadget: midi: avoid redundant f_midi_set_alt() call usb: gadget: f_midi: fix error recovery path usb: gadget: f_midi: fix segfault when reading empty id usb: gadget: fix misspelling of current function in string usb: gadget: midi: f_midi_alloc() can be static usb: gadget: f_midi: add configfs support usb: gadget: f_midi: use usb_gstrings_attach usb: gadget: f_midi: remove compatibility layer usb: gadget: f_midi: convert to new function interface with backward compatibility usb: gadget: f_midi: check kstrdup() return value usb: gadget: f_midi: enable use of the index parameter usb: gadget: configfs: Fix interfaces array NULL-termination usb: gadget: Add device attribute to determine gadget state usb: phy: fix dual role sysfs build if kernel modules are supported ion: Handle the memory mapping correctly on x86 ... Conflicts: drivers/usb/gadget/Kconfig Linaro commit 0fdc146d0ee1 (HACK: usb: gadget: fix android composite driver build) removed some Kconfig options causing add/remove conflicts with AOSP commits adding new options. Resolution: take both sides (removals and new additions)
Diffstat (limited to 'drivers/usb/gadget/configfs.c')
-rw-r--r--drivers/usb/gadget/configfs.c85
1 files changed, 52 insertions, 33 deletions
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 1157a532a34d..a8c90eb085f7 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1646,6 +1646,54 @@ static struct device_attribute *android_usb_attributes[] = {
&dev_attr_state,
NULL
};
+
+static int android_device_create(struct gadget_info *gi)
+{
+ struct device_attribute **attrs;
+ struct device_attribute *attr;
+
+ 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);
+
+ dev_set_drvdata(android_device, gi);
+
+ attrs = android_usb_attributes;
+ while ((attr = *attrs++)) {
+ int err;
+
+ err = device_create_file(android_device, attr);
+ if (err) {
+ device_destroy(android_device->class,
+ android_device->devt);
+ return err;
+ }
+ }
+
+ return 0;
+}
+
+static void android_device_destroy(void)
+{
+ 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);
+}
+#else
+static inline int android_device_create(struct gadget_info *gi)
+{
+ return 0;
+}
+
+static inline void android_device_destroy(void)
+{
+}
#endif
static struct config_group *gadgets_make(
@@ -1695,25 +1743,11 @@ static struct config_group *gadgets_make(
gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL);
gi->composite.name = gi->composite.gadget_driver.function;
-#ifdef CONFIG_USB_CONFIGFS_UEVENT
- INIT_WORK(&gi->work, android_work);
- android_device = device_create(android_class, NULL,
- MKDEV(0, 0), NULL, "android0");
- if (IS_ERR(android_device))
+ if (!gi->composite.gadget_driver.function)
goto err;
- dev_set_drvdata(android_device, gi);
-
- attrs = android_usb_attributes;
- while ((attr = *attrs++)) {
- err = device_create_file(android_device, attr);
- if (err)
- goto err1;
- }
-#endif
-
- if (!gi->composite.gadget_driver.function)
- goto err1;
+ if (android_device_create(gi) < 0)
+ goto err;
#ifdef CONFIG_USB_OTG
gi->otg.bLength = sizeof(struct usb_otg_descriptor);
@@ -1725,15 +1759,6 @@ static struct config_group *gadgets_make(
&gadget_root_type);
return &gi->group;
-err1:
-#ifdef CONFIG_USB_CONFIGFS_UEVENT
- attrs = android_usb_attributes;
- while ((attr = *attrs++))
- device_remove_file(android_device, attr);
-
- device_destroy(android_device->class,
- android_device->devt);
-#endif
err:
kfree(gi);
return ERR_PTR(-ENOMEM);
@@ -1745,13 +1770,7 @@ static void gadgets_drop(struct config_group *group, struct config_item *item)
struct device_attribute *attr;
config_item_put(item);
-
-#ifdef CONFIG_USB_CONFIGFS_UEVENT
- attrs = android_usb_attributes;
- while ((attr = *attrs++))
- device_remove_file(android_device, attr);
- device_destroy(android_device->class, android_device->devt);
-#endif
+ android_device_destroy();
}
static struct configfs_group_operations gadgets_ops = {