@@ -146,7 +146,7 @@ void device_pm_remove(struct device *dev)
list_del_init(&dev->power.entry);
mutex_unlock(&dpm_list_mtx);
device_wakeup_disable(dev);
- pm_runtime_remove(dev);
+ pm_runtime_remove(dev, true);
}
/**
@@ -18,7 +18,7 @@ static inline void pm_runtime_early_init(struct device *dev)
}
extern void pm_runtime_init(struct device *dev);
-extern void pm_runtime_remove(struct device *dev);
+extern void pm_runtime_remove(struct device *dev, bool disable);
struct wake_irq {
struct device *dev;
@@ -84,7 +84,7 @@ static inline void pm_runtime_early_init(struct device *dev)
}
static inline void pm_runtime_init(struct device *dev) {}
-static inline void pm_runtime_remove(struct device *dev) {}
+static inline void pm_runtime_remove(struct device *dev, bool disable) {}
static inline int dpm_sysfs_add(struct device *dev) { return 0; }
static inline void dpm_sysfs_remove(struct device *dev) {}
@@ -132,7 +132,7 @@ static inline void device_pm_add(struct device *dev) {}
static inline void device_pm_remove(struct device *dev)
{
- pm_runtime_remove(dev);
+ pm_runtime_remove(dev, true);
}
static inline void device_pm_move_before(struct device *deva,
@@ -1393,15 +1393,20 @@ void pm_runtime_init(struct device *dev)
* pm_runtime_remove - Prepare for removing a device from device hierarchy.
* @dev: Device object being removed from device hierarchy.
*/
-void pm_runtime_remove(struct device *dev)
+void pm_runtime_remove(struct device *dev, bool disable)
{
- __pm_runtime_disable(dev, false);
-
- /* Change the status back to 'suspended' to match the initial status. */
- if (dev->power.runtime_status == RPM_ACTIVE)
- pm_runtime_set_suspended(dev);
- if (dev->power.irq_safe && dev->parent)
- pm_runtime_put(dev->parent);
+ if (disable)
+ __pm_runtime_disable(dev, false);
+
+ if (!pm_runtime_enabled(dev)) {
+ /* Restore initial runtime PM states. */
+ if (dev->power.runtime_status == RPM_ACTIVE)
+ pm_runtime_set_suspended(dev);
+ if (dev->power.irq_safe && dev->parent) {
+ pm_runtime_put(dev->parent);
+ dev->power.irq_safe = 0;
+ }
+ }
}
/**
There are additional execution paths besides the device removal, which needs to be able to restore initial states of runtime PM. To prepare for these changes, provide a parameter to pm_runtime_remove() to allow optional disabling of runtime PM and reset the irq_safe flag. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/base/power/main.c | 2 +- drivers/base/power/power.h | 6 +++--- drivers/base/power/runtime.c | 21 +++++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) -- 1.9.1