From patchwork Wed Nov 8 15:15:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 118277 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5413738qgn; Wed, 8 Nov 2017 07:15:45 -0800 (PST) X-Received: by 10.46.15.1 with SMTP id 1mr348247ljp.157.1510154145186; Wed, 08 Nov 2017 07:15:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510154145; cv=none; d=google.com; s=arc-20160816; b=cl0C7kEeKlU1mf/ZkeS2WLkeMwppxX0V+CyWN4PprQ8dqLCv7v2Il+nGf5kNhqr6Ok 2PAyRF3ej0aA9koyJpJ5XQhwzDrY03lUgCUQ1T1IJXGxtBQkoZNbt08cRJv+AvVT1Abt 0uD7cN4h5PF5lOvPw3AqAxPYg6lYRP67BihkxeMBYk4FA89I5r0dl5kXl5/iQPaI5vvY SBpK6EcZBCIR3N5d8RCWe5UiRolqJkvVm72GFf4Lp9JtUo7l7e0625Rynlpc4AjSCWVk pfmjaA73shwTVXgjuXOLEklHb8DcHfJjC7rhP2Wz8ZqlisHOuTb/Nl9YxuQgH3aP3NR+ eSBg== 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=8jESEoVsoZambVbCBs/N9o/7umIkg3CQS8R4zgHizG4=; b=0Eecv47IwQ73Er6Nb8TtpylkSWLFmnRhsdO4x2Qwqbzj8SYzJsC7RB6ufwjyjFrZfy isibX9waUWWJvYtzitlxjc+G14p5+VqU+BzVlRNyblbLQvVI2gz36tXa4ZoXGKmBlY/5 kHLAMdNQrCQKcLaCmk+zgTU3IJnlTu68Ssd5uTMPbANRsKhzDf5tNumfakYolfYEVXHj khHIf7BBY1H70hsLKhEh8yzl3jmOovgBC2XvMWAyk2xproMOylMOU7n6cZDsdCldagXZ fCnbLveO0elHub9Op3km9iI/FOWSn822qrLvMeEfPSQTX1okHAoAHtL179eKUILF4tq+ V3nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MCM5fhwQ; 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 j7sor742289lfk.70.2017.11.08.07.15.45 for (Google Transport Security); Wed, 08 Nov 2017 07:15:45 -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=MCM5fhwQ; 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=8jESEoVsoZambVbCBs/N9o/7umIkg3CQS8R4zgHizG4=; b=MCM5fhwQi2IxTVP0yGJD0NdKdrfkTeUJwLCg2/yLfxia4j98yuRJusu67LNgI9S7ts PcKyo8imYXRERVI8s6MOO3X7HUzNjzA8ssXNouJJ4N8eh0Bvk8pb3NaR3exIiLcWUd0l 8x0Yt0kWyERxwjgWP4MXA4aqnWrhyrADbMc7c= 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=8jESEoVsoZambVbCBs/N9o/7umIkg3CQS8R4zgHizG4=; b=Sbx48u6ggXpW6FH93UVgPe28lXe5P34mlvGf/RouSvkM0QpfQ4iERJtFu3FqWMprDe tG2UC43zYshyA1uwuh+kw8DUYwt6ztudkcj1r9DiHT8ee6G++TPPQ7Imi9URI2yF5Qaj JCxWdR2fq41GCDJ68uT+dehxiTO9y8W5SfchzoKV/XRJSncrSVu2ycA9QBqNb8NNPdz4 rJHy0GKBfZG9XtBkSzi436GKXv081NwrvkTMh+K/A8Z904G6VQ23q6cTB3oZ021VSFPo KMR7r1N4oP2pikGcSdyX5hDhcT48b1arG1LGN19Bj8+uUlMLZBlxoxiBVBoaFn97UFds YaIA== X-Gm-Message-State: AJaThX4keX5/6y8QIz/NVlB+hQ939WzaYVbKW8IQbbfuewhCs7Lrc2Jz MEdeXXOfT1bA85p4gH+tC0Xdd6rg X-Google-Smtp-Source: AGs4zMb/YGEW0gQjPq6acA9WflRProPqoLWat49xioF13CztpGYf/67dKIeT8U/1EDxs9aiCIfwCLA== X-Received: by 10.25.145.88 with SMTP id y24mr315845lfj.135.1510154144846; Wed, 08 Nov 2017 07:15:44 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n131sm713846lfn.29.2017.11.08.07.15.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Nov 2017 07:15:44 -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 1/3] PM / core: Re-factor some code dealing with parents in __device_suspend() Date: Wed, 8 Nov 2017 16:15:32 +0100 Message-Id: <1510154134-1248-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org> References: <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 --- drivers/base/power/main.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) -- 2.7.4 Reviewed-by: Geert Uytterhoeven 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); }