usb:gadget: wait for a while before clean ep0 request
authorjzhuan5 <jin.can.zhuang@intel.com>
Thu, 24 May 2012 18:10:32 +0000 (14:10 -0400)
committerbuildbot <buildbot@intel.com>
Mon, 28 May 2012 15:50:11 +0000 (08:50 -0700)
BZ: 37568

after disconnecting pullup, any flying request should be completed or
any potential request should be added within 50ms. 50ms should be enough
considering the interrupt maximun interval. so sleeping for 50ms and
dequeuing ep0 should be able to cleanup the request in ep0.

Change-Id: I9e131cd1217ec748be7a013894ce7c63ef4214a3
Signed-off-by: jzhuan5 <jin.can.zhuang@intel.com>
Reviewed-on: http://android.intel.com:8080/50022
Reviewed-by: Tang, Richard <richard.tang@intel.com>
Reviewed-by: Wu, Hao <hao.wu@intel.com>
Reviewed-by: Meng, Zhe <zhe.meng@intel.com>
Tested-by: Meng, Zhe <zhe.meng@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/usb/gadget/android.c
drivers/usb/gadget/composite.c

index 62e6ed6..782dc1e 100644 (file)
@@ -883,6 +883,13 @@ static ssize_t enable_store(struct device *pdev, struct device_attribute *attr,
                dev->enabled = true;
        } else if (!enabled && dev->enabled) {
                usb_gadget_disconnect(cdev->gadget);
+
+               /* As connection is disconnected here,
+               * any flying request should be completed or potential
+               * request should be added within 50ms.
+               */
+               msleep(50);
+
                /* Cancel pending control requests */
                usb_ep_dequeue(cdev->gadget->ep0, cdev->req);
                usb_remove_config(cdev, &android_config_driver);
index 2014df7..e343e2a 100644 (file)
@@ -977,14 +977,6 @@ int usb_remove_config(struct usb_composite_dev *cdev,
 {
        unsigned long flags;
 
-       /* As connection is disconnected here,
-       * if there's no request on ep0IN, no more request completion
-       * will happen on ep0IN.
-       * otherwise, there's one request on ep0IN, let's wait until
-       * it's completed! 50 ms should be more than enough.
-       */
-       msleep(50);
-
        spin_lock_irqsave(&cdev->lock, flags);
 
        if (cdev->config == config)