Skip to content

Commit 9cf0280

Browse files
committed
PM: wakeup: Update after recent wakeup source removal ordering change
After a recent change, wakeup_source_activate() will warn that the given wakeup source is "unregistered" after its timer has been shut down in wakeup_source_remove() which may be somewhat confusing, so change the warning message to say that the wakeup source is "unusable". Accordingly, rename wakeup_source_not_registered() to wakeup_source_not_usable() and update the comment in it to also mention the removal of the wakeup source. Also restore the comment in wakeup_source_remove() regarding the warning in wakeup_source_activate() that may trigger after shutting down the wakeup source timer. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/12788103.O9o76ZdvQC@rafael.j.wysocki
1 parent 352899f commit 9cf0280

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

drivers/base/power/wakeup.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ static void wakeup_source_remove(struct wakeup_source *ws)
189189
if (WARN_ON(!ws))
190190
return;
191191

192+
/*
193+
* After shutting down the timer, wakeup_source_activate() will warn if
194+
* the given wakeup source is passed to it.
195+
*/
192196
timer_shutdown_sync(&ws->timer);
197+
193198
raw_spin_lock_irqsave(&events_lock, flags);
194199
list_del_rcu(&ws->entry);
195200
raw_spin_unlock_irqrestore(&events_lock, flags);
@@ -500,14 +505,14 @@ int device_set_wakeup_enable(struct device *dev, bool enable)
500505
EXPORT_SYMBOL_GPL(device_set_wakeup_enable);
501506

502507
/**
503-
* wakeup_source_not_registered - validate the given wakeup source.
508+
* wakeup_source_not_usable - validate the given wakeup source.
504509
* @ws: Wakeup source to be validated.
505510
*/
506-
static bool wakeup_source_not_registered(struct wakeup_source *ws)
511+
static bool wakeup_source_not_usable(struct wakeup_source *ws)
507512
{
508513
/*
509-
* Use timer struct to check if the given source is initialized
510-
* by wakeup_source_add.
514+
* Use the timer struct to check if the given wakeup source has been
515+
* initialized by wakeup_source_add() and it is not going away.
511516
*/
512517
return ws->timer.function != pm_wakeup_timer_fn;
513518
}
@@ -552,8 +557,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
552557
{
553558
unsigned int cec;
554559

555-
if (WARN_ONCE(wakeup_source_not_registered(ws),
556-
"unregistered wakeup source\n"))
560+
if (WARN_ONCE(wakeup_source_not_usable(ws), "unusable wakeup source\n"))
557561
return;
558562

559563
ws->active = true;

0 commit comments

Comments
 (0)