aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/wakeup.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 77262009f89d..7b5ad9a5a6b6 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -351,6 +351,20 @@ int device_set_wakeup_enable(struct device *dev, bool enable)
351} 351}
352EXPORT_SYMBOL_GPL(device_set_wakeup_enable); 352EXPORT_SYMBOL_GPL(device_set_wakeup_enable);
353 353
354/**
355 * wakeup_source_not_registered - validate the given wakeup source.
356 * @ws: Wakeup source to be validated.
357 */
358static bool wakeup_source_not_registered(struct wakeup_source *ws)
359{
360 /*
361 * Use timer struct to check if the given source is initialized
362 * by wakeup_source_add.
363 */
364 return ws->timer.function != pm_wakeup_timer_fn ||
365 ws->timer.data != (unsigned long)ws;
366}
367
354/* 368/*
355 * The functions below use the observation that each wakeup event starts a 369 * The functions below use the observation that each wakeup event starts a
356 * period in which the system should not be suspended. The moment this period 370 * period in which the system should not be suspended. The moment this period
@@ -391,6 +405,10 @@ static void wakeup_source_activate(struct wakeup_source *ws)
391{ 405{
392 unsigned int cec; 406 unsigned int cec;
393 407
408 if (WARN_ONCE(wakeup_source_not_registered(ws),
409 "unregistered wakeup source\n"))
410 return;
411
394 /* 412 /*
395 * active wakeup source should bring the system 413 * active wakeup source should bring the system
396 * out of PM_SUSPEND_FREEZE state 414 * out of PM_SUSPEND_FREEZE state