Skip to content

Commit

Permalink
PM / Wakeup: Replace pm_check_wakeup_events() with pm_wakeup_pending()
Browse files Browse the repository at this point in the history
To avoid confusion with the meaning and return value of
pm_check_wakeup_events() replace it with pm_wakeup_pending() that
will work the other way around (ie. return true when system-wide
power transition should be aborted).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Rafael J. Wysocki committed Dec 24, 2010
1 parent 1e75227 commit a2867e0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ static int dpm_prepare(pm_message_t state)
if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
pm_wakeup_event(dev, 0);

if (!pm_check_wakeup_events()) {
if (pm_wakeup_pending()) {
pm_runtime_put_sync(dev);
error = -EBUSY;
} else {
Expand Down
20 changes: 10 additions & 10 deletions drivers/base/power/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,26 +542,26 @@ static void pm_wakeup_update_hit_counts(void)
}

/**
* pm_check_wakeup_events - Check for new wakeup events.
* pm_wakeup_pending - Check if power transition in progress should be aborted.
*
* Compare the current number of registered wakeup events with its preserved
* value from the past to check if new wakeup events have been registered since
* the old value was stored. Check if the current number of wakeup events being
* processed is zero.
* value from the past and return true if new wakeup events have been registered
* since the old value was stored. Also return true if the current number of
* wakeup events being processed is different from zero.
*/
bool pm_check_wakeup_events(void)
bool pm_wakeup_pending(void)
{
unsigned long flags;
bool ret = true;
bool ret = false;

spin_lock_irqsave(&events_lock, flags);
if (events_check_enabled) {
ret = ((unsigned int)atomic_read(&event_count) == saved_count)
&& !atomic_read(&events_in_progress);
events_check_enabled = ret;
ret = ((unsigned int)atomic_read(&event_count) != saved_count)
|| atomic_read(&events_in_progress);
events_check_enabled = !ret;
}
spin_unlock_irqrestore(&events_lock, flags);
if (!ret)
if (ret)
pm_wakeup_update_hit_counts();
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions include/linux/suspend.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ extern int unregister_pm_notifier(struct notifier_block *nb);
/* drivers/base/power/wakeup.c */
extern bool events_check_enabled;

extern bool pm_check_wakeup_events(void);
extern bool pm_wakeup_pending(void);
extern bool pm_get_wakeup_count(unsigned int *count);
extern bool pm_save_wakeup_count(unsigned int count);
#else /* !CONFIG_PM_SLEEP */
Expand All @@ -309,7 +309,7 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)

#define pm_notifier(fn, pri) do { (void)(fn); } while (0)

static inline bool pm_check_wakeup_events(void) { return true; }
static inline bool pm_wakeup_pending(void) { return false; }
#endif /* !CONFIG_PM_SLEEP */

extern struct mutex pm_mutex;
Expand Down
4 changes: 2 additions & 2 deletions kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static int create_image(int platform_mode)
goto Enable_irqs;
}

if (hibernation_test(TEST_CORE) || !pm_check_wakeup_events())
if (hibernation_test(TEST_CORE) || pm_wakeup_pending())
goto Power_up;

in_suspend = 1;
Expand Down Expand Up @@ -516,7 +516,7 @@ int hibernation_platform_enter(void)

local_irq_disable();
sysdev_suspend(PMSG_HIBERNATE);
if (!pm_check_wakeup_events()) {
if (pm_wakeup_pending()) {
error = -EAGAIN;
goto Power_up;
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/power/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int try_to_freeze_tasks(bool sig_only)
if (!todo || time_after(jiffies, end_time))
break;

if (!pm_check_wakeup_events()) {
if (pm_wakeup_pending()) {
wakeup = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/power/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int suspend_enter(suspend_state_t state)

error = sysdev_suspend(PMSG_SUSPEND);
if (!error) {
if (!suspend_test(TEST_CORE) && pm_check_wakeup_events()) {
if (!(suspend_test(TEST_CORE) || pm_wakeup_pending())) {
error = suspend_ops->enter(state);
events_check_enabled = false;
}
Expand Down

0 comments on commit a2867e0

Please sign in to comment.