From patchwork Mon Nov 13 15:46:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 118812 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1944077qgn; Mon, 13 Nov 2017 07:46:51 -0800 (PST) X-Received: by 10.46.84.4 with SMTP id i4mr1340513ljb.60.1510588011589; Mon, 13 Nov 2017 07:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510588011; cv=none; d=google.com; s=arc-20160816; b=RiYt08UdH9srHb8qBZhE3t2TqOxa8HWt1uxDOlXY3uWB1QWTv1HlpNnuDoENu0a+jE qlR1Rjj6J5P914p3r3nKB/EelWj/8h1+vLDhYRz5Ps373v/oymvpAwQf4Pxn3zr5OfRL ibcf2uYbS55B5rB/ihrxhgjYvnxO/cdz7gGXRioqvKFA+Qx992MhS9httF1AT/jJmCwR VLz73U5xNVGu0trerf0dl/4XckOrK08hupy7RmZ6WsLuQTDpLDmpO8xa3CjSi9yRFZAn eiHnAIkNV0FNN4KKkRuwno7ylaQk/c/0y/WyOlyfwcVgPPrOuIyv7xnz7avvdSWwq1sC kLLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Z6bveg9k5fuh6Zc3zXkVbIClpgXuD92B/ZJ5LBm0oEA=; b=tkW4ajQCpAtXu3lQA+JwHdg74Qs5hMnhV8vuTbjq/wNk7ri862njRi4xff4658tCQz An23zFjElpElWlRMnroSNU8h4kQZMYztp9zlAUF9hQKPvlci7m38FWLHQ0Z0caBmNwUe E7Hm+R3IZhljBwL2Iyd6071tRYQJnut4p7H/gVTReXtQmtFo9/iXoiiorndWLc9qKsKA YUTB1kQedeYdoDhWuId5H+1HJsuqSep0NcPSSPdxqLaoYFVdLGt+AXPGv2pZUliNCBIz Iy5EWVGf3KJZu7RHgLn9PfBTo8q9FBNbj2wRuWs/41JEl5A9fM4kiC38ziia1xlcLHt3 TUhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=axzqIC21; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t1sor1086658lfk.91.2017.11.13.07.46.51 for (Google Transport Security); Mon, 13 Nov 2017 07:46:51 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=axzqIC21; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z6bveg9k5fuh6Zc3zXkVbIClpgXuD92B/ZJ5LBm0oEA=; b=axzqIC21UUrAiobfexalgdfWCbtSEgQaDrD1hf3JbbXAKjwITCkzFbunvExsTpHLyN YWHVnv9Mo3NzWX+ammE2/SSx0gKDUAQOAyqbEKkRzKAvp6Yo00CwdpFAUbpuvbIYzDOR 7SFs28mkExJxZHGEWKxG2hxK/YgbvP62V4yRc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z6bveg9k5fuh6Zc3zXkVbIClpgXuD92B/ZJ5LBm0oEA=; b=OL6ZBMUjgiFFStb8/9iHiVqhBarMThWaqFlYtrDIfDoeMsUKpvp4KvAJO8KbEeShW7 1jzj5ErRXlaqILQaPAybCevq+73wCZzuyRD+VI2p0uQnp4R449KnikdtNXLGOIdhoqot /ZEcXZGBxZp/+DV7exf90nSCGP3MO3K4GvUtn58/mynvRpjVcu8OXcPbC68eURtqzzQw r/RhA/CudvWLNmjf5f3Y/5zrIQ8CV8YpbWbredJPh2f7S7Lp+oGtRRFaR5khKibS19Ge 9yHBOpBC4wrqqqEQXC7sFksbK5tWP+hyE9vdLoGaJxjyCODBkpHyF+kwnvpAgCFBAxCg 6oIg== X-Gm-Message-State: AJaThX5ybLYzlddLZVrhCdzFglJHUJAtoCcJMGyQhRSzVmB/sxkPHyzS 4qkmiRfYq4BbgzkJp5aQZvim7Ode X-Google-Smtp-Source: AGs4zMbOlCK49SxzKGM+sdyivoPsIgfIY8c7LAS+4Fir7yJoCxx/0qarD2Cn2MZ5kaBuiWI+vov4UQ== X-Received: by 10.25.193.81 with SMTP id r78mr2980762lff.187.1510588011263; Mon, 13 Nov 2017 07:46:51 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id m26sm177841ljb.61.2017.11.13.07.46.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Nov 2017 07:46:50 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Kevin Hilman , Viresh Kumar , Geert Uytterhoeven , Simon Horman , Niklas Soderlund , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 1/3] PM / core: Re-factor some code dealing with parents in __device_suspend() Date: Mon, 13 Nov 2017 16:46:41 +0100 Message-Id: <1510588003-16650-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510588003-16650-1-git-send-email-ulf.hansson@linaro.org> References: <1510588003-16650-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 Reviewed-by: Geert Uytterhoeven --- Changes in v2: - Added Geert's Reviewed-by tag. --- drivers/base/power/main.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) -- 2.7.4 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); }