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: 10151203 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 2DAD3602B3 for ; Tue, 9 Jan 2018 09:03:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2592A288C6 for ; Tue, 9 Jan 2018 09:03:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A407288CF; Tue, 9 Jan 2018 09:03:55 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 B8292288C6 for ; Tue, 9 Jan 2018 09:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751355AbeAIJDw (ORCPT ); Tue, 9 Jan 2018 04:03:52 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40065 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751352AbeAIJDs (ORCPT ); Tue, 9 Jan 2018 04:03:48 -0500 Received: by mail-lf0-f68.google.com with SMTP id u2so634416lff.7 for ; Tue, 09 Jan 2018 01:03:47 -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=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=PD3Xr7GuJ3wN85LplGvoSEtImFnlYpNpWNkXP0W7v3TFocXzJqRyI29BhVzhmG/ZXk wOwYY/i5uKVWuVyFgY/jncVJ3el8OTtgSklKvwX4pW++bWNtma4BEKsogi4spGObgGVf At+3oWH+WHvAE64ze5dIG4laBg32wzh76Kk51Rfcn2oa5MaeM1PyHyLJz+69Ijjn/VjC hJBukibdmvRFN1l+IFm1tjKbMeujDRfh3obtKCo8T6hQUAr67ef7YP5Wa3/qs9EJtDYL lmiau20Cbzwo7Brl0s93hqTIcLL7gmV6haq6aXYrZJ2cetlNl0ePPckL5lxMvwUEgDO1 u2gg== X-Gm-Message-State: AKGB3mJ5+bzsvNEcfL2xlvpLzmSu67y1oQGYY0OHI74FeI6gh2sk3iSs VoBjRGMSHFjsJ/j6mKE4ox7x9Q== 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) 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> 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 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(-) 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);