summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/runtime.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index ac54f65b6d63..af23eb327f57 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1106,6 +1106,22 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
if (status != RPM_ACTIVE && status != RPM_SUSPENDED)
return -EINVAL;
+ spin_lock_irq(&dev->power.lock);
+
+ /*
+ * Prevent PM-runtime from being enabled for the device or return an
+ * error if it is enabled already and working.
+ */
+ if (dev->power.runtime_error || dev->power.disable_depth)
+ dev->power.disable_depth++;
+ else
+ error = -EAGAIN;
+
+ spin_unlock_irq(&dev->power.lock);
+
+ if (error)
+ return error;
+
/*
* If the new status is RPM_ACTIVE, the suppliers can be activated
* upfront regardless of the current status, because next time
@@ -1124,12 +1140,6 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
spin_lock_irq(&dev->power.lock);
- if (!dev->power.runtime_error && !dev->power.disable_depth) {
- status = dev->power.runtime_status;
- error = -EAGAIN;
- goto out;
- }
-
if (dev->power.runtime_status == status || !parent)
goto out_set;
@@ -1182,6 +1192,8 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
device_links_read_unlock(idx);
}
+ pm_runtime_enable(dev);
+
return error;
}
EXPORT_SYMBOL_GPL(__pm_runtime_set_status);