summaryrefslogtreecommitdiff
path: root/drivers/base/power
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2017-11-13 18:46:41 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-12-05 03:59:58 +0300
commit1172ee31259b51a9b2d83b05f01161fd5938b15d (patch)
tree4294d385cc7b25f4c968fd14bc7058a6ff1e9975 /drivers/base/power
parent47acbd77e6e481abf2f41d3a99cb3762f296b2e6 (diff)
downloadlinux-1172ee31259b51a9b2d83b05f01161fd5938b15d.tar.xz
PM / core: Re-factor some code dealing with parents in __device_suspend()
Let's make the code a bit more readable by moving some of the code, which deals with adjustments for parent devices in __device_suspend(), into its own function. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/power')
-rw-r--r--drivers/base/power/main.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 73ec6796d9e1..c0d5f4a3611d 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1479,6 +1479,22 @@ static int legacy_suspend(struct device *dev, pm_message_t state,
return error;
}
+static void dpm_propagate_to_parent(struct device *dev)
+{
+ struct device *parent = dev->parent;
+
+ if (!parent)
+ return;
+
+ spin_lock_irq(&parent->power.lock);
+
+ parent->power.direct_complete = false;
+ if (dev->power.wakeup_path && !parent->power.ignore_children)
+ parent->power.wakeup_path = true;
+
+ spin_unlock_irq(&parent->power.lock);
+}
+
static void dpm_clear_suppliers_direct_complete(struct device *dev)
{
struct device_link *link;
@@ -1590,19 +1606,8 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
End:
if (!error) {
- struct device *parent = dev->parent;
-
dev->power.is_suspended = true;
- if (parent) {
- spin_lock_irq(&parent->power.lock);
-
- dev->parent->power.direct_complete = false;
- if (dev->power.wakeup_path
- && !dev->parent->power.ignore_children)
- dev->parent->power.wakeup_path = true;
-
- spin_unlock_irq(&parent->power.lock);
- }
+ dpm_propagate_to_parent(dev);
dpm_clear_suppliers_direct_complete(dev);
}