diff options
author | Dima Zavin <dima@android.com> | 2011-12-02 13:58:48 +0800 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2012-02-14 14:27:42 -0800 |
commit | a7f85ec55f7ef95352eeafc0a7f309117603e1db (patch) | |
tree | 22091254649a3a60e333011b40ea8e0705438c98 /drivers/usb | |
parent | 8c641ffdae6150fa6e8b3fe898c9f0fbe3643b2a (diff) |
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 <dima@android.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/android.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index f4cdee263323..d36d2150b58d 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) { |