From patchwork Tue Jan 9 09:03:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123814 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3776244qgn; Tue, 9 Jan 2018 01:03:47 -0800 (PST) X-Received: by 10.25.20.168 with SMTP id 40mr2280954lfu.23.1515488627241; Tue, 09 Jan 2018 01:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515488627; cv=none; d=google.com; s=arc-20160816; b=HKCbJyAulh7jAXJu2eTteeY3zkZSrAhiZw1uOddzfYTixbXVbHD7A3zrKGr4jo6DwL D1O6igPXUeOAMExXUgQ75dIxf+8+8hGn6SOUeeZkmuvV9kGXrc7GGi4bAmoceDeolJ6s K43MFHuRNgQrc+wFOZbaJ0NDTodTzU6bd7Mz8/NE3MnH5fEB73mKVKe+5L4fvJMl+sHP OGxegOUz9rD9OLeXyK/XLukM4Imy6+ZFxOZjnmYFUoMpcI++fSa5087Rr9enw3pZks3a SNAuq+mz2fNNnGs9fmMRuG6yB5EpbTZ2PsklU4wZdpnzlQBsQlV0KF/rr8MBFEefyzFU enQQ== 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=aJuRAQa+4CeAaJhJ4zdvpuQfIkXpH6dapqumDg+HpVk=; b=xwmz1e3rnxGxGR0FIKQ6+ZetFe5qzBqZ3aYxLS7BDN24GLYxum2cSVxvyVRXyRjoye R4k7Rx9ENWdaTRSqLcAfH2m9A/bT8NDJ/JJ5Z3KZhC9+OedTyznbMOefJEajK885ToAe xwrIIb8MXjHYdfHz4+1s2M+15kMvXOW5sBfYf7rpzhttZMFaRiJuyvZfguJB2D9oDBUG k1+NymOvhpNiqQuWOvlzw9iEoLKZ2EE32WyqJRXu41HWL0okxPPgZEOkgZ+VBExN3vQN 0DbPTI6kGPbO6UxsN0i7SzRcN3kqR9//Gp5R8F26awVE3QYI+7DlvI9WW77jgvefaEeu 2siQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j+Ifu/J2; 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 r16sor2239583lje.14.2018.01.09.01.03.47 for (Google Transport Security); Tue, 09 Jan 2018 01:03:47 -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=j+Ifu/J2; 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=aJuRAQa+4CeAaJhJ4zdvpuQfIkXpH6dapqumDg+HpVk=; b=j+Ifu/J2Ruds+Q/v81HqbTvBExj8G5l//T5Us4mzmSsfmQLWDVj7tByhJz+K9RATEV jH0eiiICn44BPNw69lxCrE0DG1X0/u8JWLdpQtO+BmP8004CZEigiTR++Ugpn50Lax5k eWApdlx12vwPl0nnoq6V/ryZko1SFEtOJnS14= 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=aJuRAQa+4CeAaJhJ4zdvpuQfIkXpH6dapqumDg+HpVk=; b=jmueQa8JSWk7fZi9D/uC07MjpQSGCAXvQJqNyGeqtqI7mHxhgtPT0H5zHU6ZUETDyd zpIE9q8QjKrW1ZxzhK+9xoPahfdQefTkVk/PDbAoXG9eh1vq7SyKUdatlheYrdTa3Ep8 m2EcV3gKPClmBO8WTCuqxE8fo4ctGZA9kbIO0OuXoY+LBcSItM7fkSZ7ZiqvyF6z03A0 9+GtgFify4G4ManRg0jRcCG8IwqXmoSyoyzpKU0rogReUSksJ/WAIool8S1TUWWODC9/ dm9jjb4KyRwe61ga5+w4OgUNVwHVf+qIBH2hyxygi1HbJfymxzg3WkZ/l1flzu4cmK39 IZJw== X-Gm-Message-State: AKGB3mLiCLhsDl7xTZeYLDI4CsfVZNIz/VyUqLLyGnbpoJL6gfqoqpyN W2YyqRSdKXVs8dW8yZ9TNz6v9x5V X-Google-Smtp-Source: ACJfBouNLbcT50pDNS23Uvc1yeTXB/McRAaJQj2sycx+g2DsYNo5uO0gcH0OkxvmtQYsvRDYmp+TCA== X-Received: by 10.46.29.23 with SMTP id d23mr8314861ljd.114.1515488626913; Tue, 09 Jan 2018 01:03:46 -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 f78sm2745355lje.20.2018.01.09.01.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 01:03:46 -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 , Vincent Guittot , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH v4 1/2] PM / core: Re-structure code for clearing the direct_complete flag Date: Tue, 9 Jan 2018 10:03:39 +0100 Message-Id: <1515488620-10575-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515488620-10575-1-git-send-email-ulf.hansson@linaro.org> References: <1515488620-10575-1-git-send-email-ulf.hansson@linaro.org> To make the code more consistent, let's clear the parent's direct_complete flag along with clearing it for suppliers, instead of as currently, when propagating the wakeup_path flag to parents. While changing this, let's take the opportunity to rename the affected internal functions, to make them self-explanatory. Like this: dpm_clear_suppliers_direct_complete -> dpm_clear_superiors_direct_complete dpm_propagate_to_parent -> dpm_propagate_wakeup_to_parent Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index ebcec7e..720e36e 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1660,7 +1660,7 @@ static int legacy_suspend(struct device *dev, pm_message_t state, return error; } -static void dpm_propagate_to_parent(struct device *dev) +static void dpm_propagate_wakeup_to_parent(struct device *dev) { struct device *parent = dev->parent; @@ -1669,18 +1669,23 @@ static void dpm_propagate_to_parent(struct device *dev) 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) +static void dpm_clear_superiors_direct_complete(struct device *dev) { struct device_link *link; int idx; + if (dev->parent) { + spin_lock_irq(&dev->parent->power.lock); + dev->parent->power.direct_complete = false; + spin_unlock_irq(&dev->parent->power.lock); + } + idx = device_links_read_lock(); list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) { @@ -1791,8 +1796,8 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) if (device_may_wakeup(dev)) dev->power.wakeup_path = true; - dpm_propagate_to_parent(dev); - dpm_clear_suppliers_direct_complete(dev); + dpm_propagate_wakeup_to_parent(dev); + dpm_clear_superiors_direct_complete(dev); } device_unlock(dev);