From ef4dd999adaa95b09d4f2ba4368e02570200089b Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Wed, 14 Sep 2011 11:53:11 -0700 Subject: [PATCH] usb: gadget: android: follow proper order on disconnect We should composite_disconnect *before* updating our internal state and sending uevent to userspace. Also, hold cdev->lock while updating internal state. Change-Id: If66a5a4f7d4a102a44aefc3ce4a154a5a1517dcf Signed-off-by: Dima Zavin --- drivers/usb/gadget/android.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index b7e4029..a7d5b19 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -1081,9 +1081,15 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) static void android_disconnect(struct usb_gadget *gadget) { struct android_dev *dev = _android_dev; + struct usb_composite_dev *cdev = get_gadget_data(gadget); + unsigned long flags; + + composite_disconnect(gadget); + + spin_lock_irqsave(&cdev->lock, flags); dev->connected = 0; schedule_work(&dev->work); - composite_disconnect(gadget); + spin_unlock_irqrestore(&cdev->lock, flags); } static int android_create_device(struct android_dev *dev) -- 2.7.4