aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2018-01-11 03:18:59 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-01-11 12:50:54 -0500
commit0026cef067d2962ed064b974e07f017233d5bd5a (patch)
treeaf16c9124b91cfae4af7620c662364a8832bfe59
parent0a99d767a9b0aae6e0fd983c889c793e4c91684c (diff)
PM / wakeup: Print warn if device gets enabled as wakeup source during sleep
In general, wakeup settings are not supposed to be changed during any of the system wide PM phases. The reason is simply that it would break guarantees provided by the PM core, to properly act on active wakeup sources. However, there are exceptions to when, in particular, disabling a device as wakeup source makes sense. For example, in cases when a driver realizes that its device is dead during system suspend. For these scenarios, we don't need to care about acting on the wakeup source correctly, because a dead device shouldn't deliver wakeup signals. To this reasoning and to help users to properly manage wakeup settings, let's print a warning in cases someone calls device_wakeup_enable() during system sleep. Suggested-by: Rafael J. Wysocki <rafael@kernel.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> [ rjw: Message to be printed ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/base/power/wakeup.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index e73a081c6397..ea01621ed769 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -19,6 +19,11 @@
19 19
20#include "power.h" 20#include "power.h"
21 21
22#ifndef CONFIG_SUSPEND
23suspend_state_t pm_suspend_target_state;
24#define pm_suspend_target_state (PM_SUSPEND_ON)
25#endif
26
22/* 27/*
23 * If set, the suspend/hibernate code will abort transitions to a sleep state 28 * If set, the suspend/hibernate code will abort transitions to a sleep state
24 * if wakeup events are registered during or immediately before the transition. 29 * if wakeup events are registered during or immediately before the transition.
@@ -268,6 +273,9 @@ int device_wakeup_enable(struct device *dev)
268 if (!dev || !dev->power.can_wakeup) 273 if (!dev || !dev->power.can_wakeup)
269 return -EINVAL; 274 return -EINVAL;
270 275
276 if (pm_suspend_target_state != PM_SUSPEND_ON)
277 dev_dbg(dev, "Suspicious %s() during system transition!\n", __func__);
278
271 ws = wakeup_source_register(dev_name(dev)); 279 ws = wakeup_source_register(dev_name(dev));
272 if (!ws) 280 if (!ws)
273 return -ENOMEM; 281 return -ENOMEM;