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: 137359 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6441346lji; Thu, 31 May 2018 04:00:11 -0700 (PDT) X-Received: by 2002:a2e:1414:: with SMTP id u20-v6mr5077399ljd.134.1527764411129; Thu, 31 May 2018 04:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527764411; cv=none; d=google.com; s=arc-20160816; b=CT2JSQDver9fSpmhe6Fv7DteZh+sSX05fIigmbopwumoRLTJGwQKlGUZIIctAmM597 kCusvdu/J7SlA3er7EzDI/dJYB9ZvqxD4muJLm16tmAEx2rRBmXMPE5sen12RUzEvtuf hukUeqZ2v/VdmXwzWLdwCF1kL5Kf9t5zOTYZQrXjNeKk4ncwcwythYilmxYgeP3gPNBb 1WYGwlkzU0DCeNFEGptZJ4ziOyhEPkHlJbQeL6URzY0ZmyyNKCGeA+qR88TmPyGFci7B PK0yg2QE7KCN3OekH86Pd0w3K5iKA+CizYWoX/44kR4rO3FpSVQVTICpv8fOjMZlCUPA hSgA== 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=eylHfMyrO/9+jv2WsRax1wLQp9A/tGnl65WxWqbRgYM=; b=o+7U9W7zjIVCpZ8Vym9s4KCTCqZU9dON34inzsV3vgCgWHdNVyQY3YsQe+1fehh8ap lgYY2G1HY1Zur4wJarOtgCEawuE/AxMBojrOHaMiHR3m8YVwmjkbWdxhtdkNYWSYqLFq hLLxOaAesSxNUgCjvd8NihkwNa0kKG9UfeDoKKeRi+1OHwR0H/XX9gDCHiWAw7xlQAv/ 8HRaowRR59UhlC2ZMZHVoDx+VaCEqFe+jM9laPcOwq6cq/STVhmmfwQTwbtrO61kMlp7 f1ixzq4kF9Yfwka22kwGbaxxmGuHA6iOCShmgbj3TXTZZmfGOVw7s1fcyxhLHYPnm1VU LJdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q3s8vCs8; 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 i17-v6sor160236lfc.61.2018.05.31.04.00.11 for (Google Transport Security); Thu, 31 May 2018 04:00:11 -0700 (PDT) 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=Q3s8vCs8; 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=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=cE/Wp7ecmK8ULAmeLkhNNnm9cjCA9VjNfApFH270TYGmhdzGE/DRluDMwsxLZ85Ug1 FVPVHBzNTeB4blqsoXot8bk6T8XLo+oes4qc+vh5wmTiQYJKDxYE1PfZ+7YcoE9dtMLm mTH1o1b1oHWsgeAliDAWGuD0UIE2lnMhSiJRQlqTFpc5gfIUAKWpeDIdjOJ11ty964Ne H3KD9Sqq1+iVijrxOCGfHFjf2RgsNA3DFIpFOuMcnLo6XHZ+jjKaT1psBp+nPYAgrT17 gSxYGoYWJEY8FnyZ2ijwcsFgeGELPyMIYGs0kKB19+tsX1addkcVJ3g9U8RZwmFAFuzT Tgzw== X-Gm-Message-State: ALKqPwf6sYEGM9TvRSx3AntI1cxZd+lrm6PHXoMNlK+iqeuU/+Q6Yyvu O+LN3yeewOizGJw5nBVZzO36iZU0o2DsEA== 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) Return-Path: 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> 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(-) -- 2.17.0 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[] = {