Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4640049imm; Wed, 30 May 2018 09:09:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJAh0nKIcD81QyrhrQNM/SHU6Lz3iY6SE+eQCxNeWIhGmg64sR/KxPPcLovO2tmmKj5Tsgp X-Received: by 2002:a63:b041:: with SMTP id z1-v6mr2617322pgo.397.1527696588241; Wed, 30 May 2018 09:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527696588; cv=none; d=google.com; s=arc-20160816; b=BheEmU3HmrB27nC2mlifiH42qZa1zoLeBLFwauS9n3hQlSkCXKSFw6/COg1w7g1nAe H0vYeU0SpspnF9MovfJk9BG7mNcq3uShdubBqag9MfoonYwMmJ3L69hqctGKhDq9gJre CIGFz2fhTh6m7fo7U/1VjJBA6ZBPOXKem/I3ztugCFG2Jx/dOuBbDEGGOxgxOB8nofVD 0v9hVxO/IJz+0qvlSdenA4I51u1oOgr439XCy9J4QZH1i+GgUMWL77B/5ZGfPDw98el7 8Iq6U950C6uKzoGbERfeeJniUKCb8jLTyysdWtjb8/geg6wLjWwH/+vLKZvSjdWSjXL8 npdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=cwdLFLtZqW5UQW+9ycHf6HfPRP8cSwKsjFlrNOfe3tk=; b=C+h1K4FCdFVR07VAgOHfwP5NpZmvoTRlmf9aWv/4cS0wKBeV1MMHYYt4KsI+f/2W/w 4ua2HSMjitFqRmNrrrG/8PJF+DPC6wvu9ROBQ10jWHJ9Ugk1aRRcKlxErGl7eSEIs8NA 7FfTKwkyc/npBo3ScIuGxVwwQyi4N/QrHmSzqVdLo540E0IcQwjaZD/+8ns1ck8jjdmK w/bCCKbSPYnL8gjvIX6/8WFGrSQE9gRFHSEowD2WoUPwlz4KsKydj4C5BXv81X2eLhqS 9xV1KJvCA/mVHKC/G5GniUWjAD0099vruve8dPaG+yD+nggqm9fK2n53ArP7WAVodGa7 kacg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q19-v6si6351004pgn.392.2018.05.30.09.09.33; Wed, 30 May 2018 09:09:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753844AbeE3QIm (ORCPT + 99 others); Wed, 30 May 2018 12:08:42 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:10648 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753587AbeE3QIi (ORCPT ); Wed, 30 May 2018 12:08:38 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1, AES128-SHA) id ; Wed, 30 May 2018 09:08:50 -0700 Received: from HQMAIL101.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 30 May 2018 09:08:41 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 30 May 2018 09:08:41 -0700 Received: from [10.21.132.148] (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 30 May 2018 16:08:34 +0000 Subject: Re: [PATCH v2 7/9] PM / Domains: Split genpd_dev_pm_attach() To: Ulf Hansson , "Rafael J . Wysocki" , CC: Greg Kroah-Hartman , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , , , References: <20180529100421.31022-1-ulf.hansson@linaro.org> <20180529100421.31022-8-ulf.hansson@linaro.org> From: Jon Hunter Message-ID: <67a50209-5049-4345-693a-5fd08afd6bb8@nvidia.com> Date: Wed, 30 May 2018 17:08:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180529100421.31022-8-ulf.hansson@linaro.org> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/05/18 11:04, Ulf Hansson wrote: > 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 > --- > 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 12a20f21974d..2af99bfcbe3c 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[] = { Acked-by: Jon Hunter Tested-by: Jon Hunter Cheers Jon -- nvpublic