PM / sleep: unregister wakeup source when disabling device wakeup
authorZhang Rui <rui.zhang@intel.com>
Wed, 28 May 2014 07:23:35 +0000 (15:23 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 30 May 2014 11:39:29 +0000 (13:39 +0200)
When enabling a device' wakeup capability, a wakeup source
is created for the device automatically. But the wakeup source
is not unregistered when disabling the device' wakeup capability.

This results in zombie wakeup sources, after devices/drivers are unregistered.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/wakeup.c

index 2d56f41..eb1bd2e 100644 (file)
@@ -318,10 +318,16 @@ int device_init_wakeup(struct device *dev, bool enable)
 {
        int ret = 0;
 
+       if (!dev)
+               return -EINVAL;
+
        if (enable) {
                device_set_wakeup_capable(dev, true);
                ret = device_wakeup_enable(dev);
        } else {
+               if (dev->power.can_wakeup)
+                       device_wakeup_disable(dev);
+
                device_set_wakeup_capable(dev, false);
        }