From patchwork Thu May 31 10:59:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10440731 X-Patchwork-Delegate: rjw@sisk.pl 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 ED3F6602BF for ; Thu, 31 May 2018 11:01:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E51672911A for ; Thu, 31 May 2018 11:01:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39102925E; Thu, 31 May 2018 11:01:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 7BC9A29266 for ; Thu, 31 May 2018 11:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754691AbeEaLA6 (ORCPT ); Thu, 31 May 2018 07:00:58 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:37368 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754586AbeEaLAM (ORCPT ); Thu, 31 May 2018 07:00:12 -0400 Received: by mail-lf0-f67.google.com with SMTP id r2-v6so9089003lff.4 for ; Thu, 31 May 2018 04:00:11 -0700 (PDT) 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=eylHfMyrO/9+jv2WsRax1wLQp9A/tGnl65WxWqbRgYM=; b=Q3s8vCs8sJ+rMFaYeWFEe1HR97YFdU3B0ttZKsbP5H3AprT3sn2/XpRA9VITdFY138 eHS4NLSch/TcPPKNHi/QEYzySsaozO5VEPW2/xwTQYSDDwCFEocZ0H2MqgD0lQVk5JZG Y/YNxfsjMIuW4ki/rCAAnKDDl8/aMeamlK6y4= 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=eylHfMyrO/9+jv2WsRax1wLQp9A/tGnl65WxWqbRgYM=; b=kRDjNWdln5S3VK7LImlNx10QiYiYlzu0bpGEzl6Q4//B/q9jVKzch6ZDNdYpmwqMPr c9rxrClUIpbUSXFnWFmaq+BOKkrsCy2xeV2JX9HLG8b88FdtpP1XnzMMir1tTcGAT0wW B9Ik54xv0DkpbbL6xqKx0727WCdVmdKo5bv1JwrC7BOJNVgrNg/1/3OwZNQiSXVQI1eI XeIAxqs0S1xdWXFrP72PRRvSwndlUJBLqmMizNKSx9ln3fhqLlD5y4P+PZ36iARyGb2+ enRqFzlGk3ZynAFQVi5Lt5gRQIdMFRde956ewQMtowsZLpvguHV5PNi+Xw5GKHHtPss+ zXPA== X-Gm-Message-State: ALKqPwe9LQ4K8MtKavcNC7FS6Mb8lJk67RZpSQqZ/Dg+UiBPJowMAFyw H/j+OrCi1kdJ+ZauVRIH7aGcUA== X-Google-Smtp-Source: ADUXVKLrSr5wyw2yMUlV9FRYkbooKC5gewusQUuJJVyOmDsfgiaIpf6BJyC9wZByqujKM8zCb5Q1uA== X-Received: by 2002:a19:151d:: with SMTP id l29-v6mr4169149lfi.106.1527764410904; Thu, 31 May 2018 04:00:10 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b20-v6sm7454383ljf.51.2018.05.31.04.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 04:00:10 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH v3 3/5] PM / Domains: Split genpd_dev_pm_attach() Date: Thu, 31 May 2018 12:59:57 +0200 Message-Id: <20180531105959.14843-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531105959.14843-1-ulf.hansson@linaro.org> References: <20180531105959.14843-1-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To extend genpd to deal with allowing multiple PM domains per device, some of the code in genpd_dev_pm_attach() can be re-used. Let's prepare for this by moving some of the code into a sub-function. Signed-off-by: Ulf Hansson Acked-by: Jon Hunter Tested-by: Jon Hunter Reviewed-by: Viresh Kumar --- drivers/base/power/domain.c | 60 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 908c44779ae7..b1fcbf917974 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2221,38 +2221,15 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } -/** - * genpd_dev_pm_attach - Attach a device to its PM domain using DT. - * @dev: Device to attach. - * - * Parse device's OF node to find a PM domain specifier. If such is found, - * attaches the device to retrieved pm_domain ops. - * - * Returns 1 on successfully attached PM domain, 0 when the device don't need a - * PM domain or when multiple power-domains exists for it, else a negative error - * code. Note that if a power-domain exists for the device, but it cannot be - * found or turned on, then return -EPROBE_DEFER to ensure that the device is - * not probed and to re-try again later. - */ -int genpd_dev_pm_attach(struct device *dev) +static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, + unsigned int index) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; int ret; - if (!dev->of_node) - return 0; - - /* - * Devices with multiple PM domains must be attached separately, as we - * can only attach one PM domain per device. - */ - if (of_count_phandle_with_args(dev->of_node, "power-domains", - "#power-domain-cells") != 1) - return 0; - - ret = of_parse_phandle_with_args(dev->of_node, "power-domains", - "#power-domain-cells", 0, &pd_args); + ret = of_parse_phandle_with_args(np, "power-domains", + "#power-domain-cells", index, &pd_args); if (ret < 0) return ret; @@ -2290,6 +2267,35 @@ int genpd_dev_pm_attach(struct device *dev) return ret ? -EPROBE_DEFER : 1; } + +/** + * genpd_dev_pm_attach - Attach a device to its PM domain using DT. + * @dev: Device to attach. + * + * Parse device's OF node to find a PM domain specifier. If such is found, + * attaches the device to retrieved pm_domain ops. + * + * Returns 1 on successfully attached PM domain, 0 when the device don't need a + * PM domain or when multiple power-domains exists for it, else a negative error + * code. Note that if a power-domain exists for the device, but it cannot be + * found or turned on, then return -EPROBE_DEFER to ensure that the device is + * not probed and to re-try again later. + */ +int genpd_dev_pm_attach(struct device *dev) +{ + if (!dev->of_node) + return 0; + + /* + * Devices with multiple PM domains must be attached separately, as we + * can only attach one PM domain per device. + */ + if (of_count_phandle_with_args(dev->of_node, "power-domains", + "#power-domain-cells") != 1) + return 0; + + return __genpd_dev_pm_attach(dev, dev->of_node, 0); +} EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); static const struct of_device_id idle_state_match[] = {