PM / wakeup: Export wakeup_count instead of event_count via sysfs
authorRavi Chandra Sadineni <ravisadineni@chromium.org>
Sat, 2 Jun 2018 02:32:15 +0000 (19:32 -0700)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 6 Jun 2018 07:23:36 +0000 (09:23 +0200)
Currently we export event_count instead of wakeup_count via the
per-device wakeup_count sysfs attribute. Change it to wakeup_count
to make it more meaningful.

wakeup_count increments only when events_check_enabled is set,
that is whenever writes the current wakeup count to
/sys/power/wakeup_count.  Also events_check_enabled is cleared on
every resume. User space is expected to write to this just before
suspend.  This way pm_wakeup_event(), when called from IRQs handles,
will increment wakeup_count only if we are in system-wide
suspend-resume cycle and should give a fair approximation of how many
times a device may have triggered a wakeup from system suspend.

event_count on the other hand will increment every time
pm_wakeup_event() is called irrespective of whether we are in a
suspend-resume cycle and some drivers call it on every interrupt
which makes it less useful for system wakeup tracking.

Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
[ rjw: Subject & changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/sysfs.c

index 0f651efc58a1ad8352f2f97e0c310332cdd4b174..d713738ce7967cdb8003166fc17bf63116d3b629 100644 (file)
@@ -353,7 +353,7 @@ static ssize_t wakeup_count_show(struct device *dev,
 
        spin_lock_irq(&dev->power.lock);
        if (dev->power.wakeup) {
-               count = dev->power.wakeup->event_count;
+               count = dev->power.wakeup->wakeup_count;
                enabled = true;
        }
        spin_unlock_irq(&dev->power.lock);