usb: gadget: android: dump the uevents sent when changing states
authorDima Zavin <dima@android.com>
Wed, 14 Sep 2011 18:52:45 +0000 (11:52 -0700)
committerDima Zavin <dima@android.com>
Wed, 14 Sep 2011 20:43:22 +0000 (13:43 -0700)
Change-Id: If5011e39f400b3aca036a890b8b932a7606a7ac2
Signed-off-by: Dima Zavin <dima@android.com>
drivers/usb/gadget/android.c

index a7d5b19dc1614d7a5a893bc49df0f6bb58a2747c..8ff997261e0185f495c28464dbc9c69a326cbc60 100644 (file)
@@ -163,22 +163,24 @@ static void android_work(struct work_struct *data)
        char *disconnected[2] = { "USB_STATE=DISCONNECTED", NULL };
        char *connected[2]    = { "USB_STATE=CONNECTED", NULL };
        char *configured[2]   = { "USB_STATE=CONFIGURED", NULL };
+       char **uevent_envp = NULL;
        unsigned long flags;
 
        spin_lock_irqsave(&cdev->lock, flags);
         if (cdev->config) {
-               spin_unlock_irqrestore(&cdev->lock, flags);
-               kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE,
-                                                       configured);
-               return;
-       }
-       if (dev->connected != dev->sw_connected) {
+               uevent_envp = configured;
+       } else if (dev->connected != dev->sw_connected) {
                dev->sw_connected = dev->connected;
-               spin_unlock_irqrestore(&cdev->lock, flags);
-               kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE,
-                               dev->sw_connected ? connected : disconnected);
+               uevent_envp = dev->sw_connected ? connected : disconnected;
+       }
+       spin_unlock_irqrestore(&cdev->lock, flags);
+
+       if (uevent_envp) {
+               kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, uevent_envp);
+               pr_info("%s: sent uevent %s\n", __func__, uevent_envp[0]);
        } else {
-               spin_unlock_irqrestore(&cdev->lock, flags);
+               pr_info("%s: did not send uevent (%d %d %p)\n", __func__,
+                        dev->connected, dev->sw_connected, cdev->config);
        }
 }