usb: gadget: fix: Call usb_gadget_connect() for dummy_udc 34/88034/1
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Mon, 12 Sep 2016 18:54:59 +0000 (20:54 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Mon, 12 Sep 2016 20:21:45 +0000 (22:21 +0200)
Ugly hack which comes from Android removes a call
to usb_gadget_connect() in udc_bind_to_driver() to
prevent android/slp gadget from communication before
userspace explicitly enables it.

Mainline gadgets (like g_ffs) expect this function
to be called as they don't have any sysfs interface
to enable them later.

As for usb-host API tests we need to use dummy_hcd
and g_ffs let's call usb_gadget_connect() for all
dummy_udc's.

Change-Id: I782bbb51c54e0b87ff6ef976070b6d8870a1a745
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
drivers/usb/gadget/udc-core.c

index 58a8613..63b6a76 100644 (file)
@@ -342,8 +342,13 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
         * the call to usb_gadget_connect bellow to avoid enabling the
         * pullup before userspace is ready.
         *
-        * usb_gadget_connect(udc->gadget);
+        * HACK: Apart from android and slp gadget we would like to use
+        * also standard mainline gadgets with dummy_hcd. Those gadgets
+        * expects to be connected right after bind().
         */
+       if (strstr(dev_name(&udc->dev), "dummy_udc") != NULL)
+               usb_gadget_connect(udc->gadget);
+
 
        kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
        return 0;