aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-01-31 05:06:50 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2011-03-14 19:43:13 -0400
commit378eef99ad45700aabfba2bd962516e5608b259a (patch)
treed9a0d584495e5b6ee764b6d740cece46f3b5ed1d /drivers/base
parent023d3779145ec6b7a0f38f19672a347b92feb74e (diff)
PM / Wakeup: Make pm_save_wakeup_count() work as documented
According to Documentation/ABI/testing/sysfs-power, the /sys/power/wakeup_count interface should only make the kernel react to wakeup events during suspend if the last write to it has been successful. However, if /sys/power/wakeup_count is written to two times in a row, where the first write is successful and the second is not, the kernel will still react to wakeup events during suspend due to a bug in pm_save_wakeup_count(). Fix the bug by making pm_save_wakeup_count() clear events_check_enabled unconditionally before checking if there are any new wakeup events registered since the previous read from /sys/power/wakeup_count. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/wakeup.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index e5e73b5efc8..07e08c3aece 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -616,25 +616,25 @@ bool pm_get_wakeup_count(unsigned int *count)
616 * 616 *
617 * If @count is equal to the current number of registered wakeup events and the 617 * If @count is equal to the current number of registered wakeup events and the
618 * current number of wakeup events being processed is zero, store @count as the 618 * current number of wakeup events being processed is zero, store @count as the
619 * old number of registered wakeup events to be used by pm_check_wakeup_events() 619 * old number of registered wakeup events for pm_check_wakeup_events(), enable
620 * and return true. Otherwise return false. 620 * wakeup events detection and return 'true'. Otherwise disable wakeup events
621 * detection and return 'false'.
621 */ 622 */
622bool pm_save_wakeup_count(unsigned int count) 623bool pm_save_wakeup_count(unsigned int count)
623{ 624{
624 unsigned int cnt, inpr; 625 unsigned int cnt, inpr;
625 bool ret = false;
626 626
627 events_check_enabled = false;
627 spin_lock_irq(&events_lock); 628 spin_lock_irq(&events_lock);
628 split_counters(&cnt, &inpr); 629 split_counters(&cnt, &inpr);
629 if (cnt == count && inpr == 0) { 630 if (cnt == count && inpr == 0) {
630 saved_count = count; 631 saved_count = count;
631 events_check_enabled = true; 632 events_check_enabled = true;
632 ret = true;
633 } 633 }
634 spin_unlock_irq(&events_lock); 634 spin_unlock_irq(&events_lock);
635 if (!ret) 635 if (!events_check_enabled)
636 pm_wakeup_update_hit_counts(); 636 pm_wakeup_update_hit_counts();
637 return ret; 637 return events_check_enabled;
638} 638}
639 639
640static struct dentry *wakeup_sources_stats_dentry; 640static struct dentry *wakeup_sources_stats_dentry;