aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/runtime.c
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2016-10-17 20:17:01 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-11-09 15:49:37 +0100
commita8636c89648ab12e59d8f3aa667ec76fc96fd643 (patch)
tree7a4faf0aa71ffacf89e27c878803cec2137356dc /drivers/base/power/runtime.c
parentnet: smsc911x: Synchronize the runtime PM status during system suspend (diff)
downloadlinux-dev-a8636c89648ab12e59d8f3aa667ec76fc96fd643.tar.xz
linux-dev-a8636c89648ab12e59d8f3aa667ec76fc96fd643.zip
PM / Runtime: Don't allow to suspend a device with an active child
When resuming a device in __pm_runtime_set_status(), the prerequisite is that its parent must already be active, else an error code is returned and the device's status remains suspended. When suspending a device there is no similar constraints being validated. Let's change this to make the behaviour consistent, by not allowing to suspend a device with an active child, unless it has been explicitly set to ignore its children. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to '')
-rw-r--r--drivers/base/power/runtime.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 117db71e84cb..60ebb04d8140 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1028,7 +1028,17 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
goto out_set;
if (status == RPM_SUSPENDED) {
- /* It always is possible to set the status to 'suspended'. */
+ /*
+ * It is invalid to suspend a device with an active child,
+ * unless it has been set to ignore its children.
+ */
+ if (!dev->power.ignore_children &&
+ atomic_read(&dev->power.child_count)) {
+ dev_err(dev, "runtime PM trying to suspend device but active child\n");
+ error = -EBUSY;
+ goto out;
+ }
+
if (parent) {
atomic_add_unless(&parent->power.child_count, -1, 0);
notify_parent = !parent->power.ignore_children;