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: 10048649 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DAD0B60247 for ; Wed, 8 Nov 2017 15:15:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDC9628EDA for ; Wed, 8 Nov 2017 15:15:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C26FB2A63E; Wed, 8 Nov 2017 15:15:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 771C528EDA for ; Wed, 8 Nov 2017 15:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752491AbdKHPPr (ORCPT ); Wed, 8 Nov 2017 10:15:47 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:53708 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752648AbdKHPPq (ORCPT ); Wed, 8 Nov 2017 10:15:46 -0500 Received: by mail-lf0-f65.google.com with SMTP id l23so3542739lfk.10 for ; Wed, 08 Nov 2017 07:15:45 -0800 (PST) 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=TWvemcJXZzbAFqWkvKLfhYR/u8kwT9e/CtDaJxGZcQK7JU27tlsMvGelXyEelayCov rqZmrR8jonP8LINut5CQaLe37xieFUhkWBTMjPQjEKft7CjDq9OUOzS1gN8fzrMKh+Qo ULyIw+7xOUjJ5HqmLdjh8LUrNSBXVDbJ3SwlffMDs7O0Zwrp3LKLfYRTyVyRYJswC2pu 00717PBzTjLZ0UqKxi3McptTg68QdmGhfBNUo5WmSPo+maYgTzghjn1zbwRAYSqWfZi/ K3W7mOTfGujKftRv54yBS6hM5RKJdq7i8KxetKUYC8MQ+S6/Krmp7xeS1wOomRMqz9Gw QDNw== X-Gm-Message-State: AJaThX7+/5jVrKmNYFL8JgunngjKvjKvgSQMEpWDTZEcVKDEYM0SvKx6 OJxD07JU8XiHaoz8rUtQwmD3CQ== 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) 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> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); }