All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>, linux-pm@vger.kernel.org
Cc: Kevin Hilman <khilman@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Simon Horman <horms@verge.net.au>,
	Niklas Soderlund <niklas.soderlund+renesas@ragnatech.se>,
	linux-renesas-soc@vger.kernel.org,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: [PATCH 1/3] PM / core: Re-factor some code dealing with parents in __device_suspend()
Date: Wed,  8 Nov 2017 16:15:32 +0100	[thread overview]
Message-ID: <1510154134-1248-2-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org>

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>
---
 drivers/base/power/main.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 6c6f1c7..8089e72 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1422,6 +1422,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;
@@ -1530,19 +1546,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);
 	}
 
-- 
2.7.4

  reply	other threads:[~2017-11-08 15:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 15:15 [PATCH 0/3] PM / core: Invent a WAKEUP_POWERED driver flag Ulf Hansson
2017-11-08 15:15 ` Ulf Hansson [this message]
2017-11-08 15:26   ` [PATCH 1/3] PM / core: Re-factor some code dealing with parents in __device_suspend() Geert Uytterhoeven
2017-11-08 15:15 ` [PATCH 2/3] PM / core: Add WAKEUP_POWERED driver flag Ulf Hansson
2017-11-08 15:32   ` Geert Uytterhoeven
2017-11-09  0:24   ` Rafael J. Wysocki
2017-11-09  8:44     ` Ulf Hansson
2017-11-09 11:40       ` Rafael J. Wysocki
2017-11-10  9:44         ` Ulf Hansson
2017-11-09  0:41   ` Rafael J. Wysocki
2017-11-09  8:53     ` Ulf Hansson
2017-11-09 11:51       ` Rafael J. Wysocki
2017-11-08 15:15 ` [PATCH 3/3] PM / Domains: Take WAKEUP_POWERED driver flag into account Ulf Hansson
2017-11-08 15:32   ` Geert Uytterhoeven
2017-11-08 15:41 ` [PATCH 0/3] PM / core: Invent a WAKEUP_POWERED driver flag Geert Uytterhoeven
2017-11-09  8:28   ` Ulf Hansson
2017-11-09  9:02     ` Geert Uytterhoeven
2017-11-09 10:08       ` Ulf Hansson
2017-11-09 10:14         ` Geert Uytterhoeven
2017-11-09 14:28           ` Ulf Hansson
2017-11-09 14:41             ` Geert Uytterhoeven
2017-11-09 16:31               ` Rafael J. Wysocki
2017-11-10  9:28                 ` Ulf Hansson
2017-11-09 11:59         ` Rafael J. Wysocki
2017-11-09 12:02           ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510154134-1248-2-git-send-email-ulf.hansson@linaro.org \
    --to=ulf.hansson@linaro.org \
    --cc=geert+renesas@glider.be \
    --cc=horms@verge.net.au \
    --cc=khilman@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.