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: 923318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Q3s8vCs8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40xPcz0jsZz9rxs for ; Thu, 31 May 2018 21:00:19 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754637AbeEaLAP (ORCPT ); Thu, 31 May 2018 07:00:15 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:39254 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754582AbeEaLAM (ORCPT ); Thu, 31 May 2018 07:00:12 -0400 Received: by mail-lf0-f68.google.com with SMTP id t134-v6so9102896lff.6 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=ePfWv3yTv8ml05gwR4ZUxANzh9Dqhh8CDIAhGQPPTm628eIImDHrr2VIxwuYc8+Gl6 ip6DW20MCDPzPJq6jVRr7zRFgYqN+NiBcsod2u8aOUo31G3g3G/Vr/WHazNdVfkqYL0l DHHdzpWOmqSR/IcJOGnGafBlC9QC5pqm23aVJeBH99NgcRzIVfJOMSWwHYYNeVixkFw8 9ERsQXGhNBquMpo23VUmvpcp3ywb+kKzMG4RxhSI8mZE6kLRICkyVVXnOwfSyafsSIvU U9sC5qFwAFxMsmxg6k2pZ0G3eEa6RZCl4Zd4bn98Qu4tkZZD74oiEvfRYnZKXC3lmggs MYFA== X-Gm-Message-State: ALKqPwdB+FY0Z16QKA0o8s33KoYqmIMvHu02QfMIyBcgOW5RuWvmAVa3 3bQ13bYhu4wxUCPd1stR/K9lYA== 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-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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[] = {