From: Dima Zavin Date: Wed, 14 Sep 2011 22:12:45 +0000 (-0700) Subject: usb: gadget: android: always update the sw_connected state X-Git-Tag: firefly_0821_release~7613^2~309 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f85cf4f97dc037a3c8b309b3d0bdc55b3f7498cd;p=firefly-linux-kernel-4.4.55.git usb: gadget: android: always update the sw_connected state If we go through connected->configured->disconnected cycle very quickly, it is possible that we may not generate a disconnect uevent to userspace. Connected+configured could have happened before the work item got executed, and thus would not have updated the sw_connected state. On the disconnect, it would have noticed that a config is no longer there but since sw_connected was still 0, it would not have sent the disconnect event. Change-Id: Id71175f784e3e1cf3f828bd8b24fceea1078a06b Signed-off-by: Dima Zavin --- diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index 8ff997261e01..d109bfb02f38 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -167,12 +167,11 @@ static void android_work(struct work_struct *data) unsigned long flags; spin_lock_irqsave(&cdev->lock, flags); - if (cdev->config) { + if (cdev->config) uevent_envp = configured; - } else if (dev->connected != dev->sw_connected) { - dev->sw_connected = dev->connected; - uevent_envp = dev->sw_connected ? connected : disconnected; - } + else if (dev->connected != dev->sw_connected) + uevent_envp = dev->connected ? connected : disconnected; + dev->sw_connected = dev->connected; spin_unlock_irqrestore(&cdev->lock, flags); if (uevent_envp) {