diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-04-26 05:33:09 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-04-26 05:33:09 -0400 |
commit | 22110faf8c8e980013790e6a5214de32b3303730 (patch) | |
tree | fb8239c3e4969cd43981eb10846802ca89b09224 /drivers | |
parent | 5dd12af05ca6b7d052c06a9ca4ff755fdfa25ae4 (diff) |
PM / Wakeup: Fix initialization of wakeup-related device sysfs files
It turns out that some PCI devices are only found to be
wakeup-capable during registration, in which case, when
device_set_wakeup_capable() is called, device_is_registered() already
returns 'true' for the given device, but dpm_sysfs_add() hasn't been
called for it yet. This leads to situations in which the device's
power.can_wakeup flag is not set as requested because of failing
wakeup_sysfs_add() and its wakeup-related sysfs files are not
created, although they should be present. This is a post-2.6.38
regression introduced by commit cb8f51bdadb7969139c2e39c2defd4cde98c1
(PM: Do not create wakeup sysfs files for devices that cannot wake
up).
To work around this problem initialize the device's power.entry
field to an empty list head and make device_set_wakeup_capable()
check if it is still empty before attempting to add the devices
wakeup-related sysfs files with wakeup_sysfs_add(). Namely, if
power.entry is still empty at this point, device_pm_add() hasn't been
called yet for the device and its wakeup-related files will be
created later, so device_set_wakeup_capable() doesn't have to create
them.
Reported-and-tested-by: Tino Keitel <tino.keitel@tikei.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/power/main.c | 1 | ||||
-rw-r--r-- | drivers/base/power/wakeup.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index fbc5b6e7c591..abe3ab709e87 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -63,6 +63,7 @@ void device_pm_init(struct device *dev) | |||
63 | dev->power.wakeup = NULL; | 63 | dev->power.wakeup = NULL; |
64 | spin_lock_init(&dev->power.lock); | 64 | spin_lock_init(&dev->power.lock); |
65 | pm_runtime_init(dev); | 65 | pm_runtime_init(dev); |
66 | INIT_LIST_HEAD(&dev->power.entry); | ||
66 | } | 67 | } |
67 | 68 | ||
68 | /** | 69 | /** |
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 4573c83df6dd..abbbd33e8d8a 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c | |||
@@ -258,7 +258,7 @@ void device_set_wakeup_capable(struct device *dev, bool capable) | |||
258 | if (!!dev->power.can_wakeup == !!capable) | 258 | if (!!dev->power.can_wakeup == !!capable) |
259 | return; | 259 | return; |
260 | 260 | ||
261 | if (device_is_registered(dev)) { | 261 | if (device_is_registered(dev) && !list_empty(&dev->power.entry)) { |
262 | if (capable) { | 262 | if (capable) { |
263 | if (wakeup_sysfs_add(dev)) | 263 | if (wakeup_sysfs_add(dev)) |
264 | return; | 264 | return; |