@@ -234,13 +234,29 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime,
* @dev: Device to wait for.
* @async: If unset, wait only if the device's power.async_suspend flag is set.
*/
+static void _dpm_wait(struct device *dev, bool async)
+{
+ if (async || (pm_async_enabled && dev->power.async_suspend))
+ wait_for_completion(&dev->power.completion);
+}
+
static void dpm_wait(struct device *dev, bool async)
{
if (!dev)
return;
- if (async || (pm_async_enabled && dev->power.async_suspend))
- wait_for_completion(&dev->power.completion);
+ _dpm_wait(dev, async);
+}
+
+static void dpm_wait_for_parent(struct device *dev, bool async)
+{
+ if (dev && dev->parent) {
+ struct device *dev_p = dev->parent;
+
+ get_device(dev_p);
+ _dpm_wait(dev_p, async);
+ put_device(dev_p);
+ }
}
static int dpm_wait_fn(struct device *dev, void *async_ptr)
@@ -277,7 +293,7 @@ static void dpm_wait_for_suppliers(struct device *dev, bool async)
static void dpm_wait_for_superior(struct device *dev, bool async)
{
- dpm_wait(dev->parent, async);
+ dpm_wait_for_parent(dev, async);
dpm_wait_for_suppliers(dev, async);
}