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: 10440741 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 63D00602BF for ; Thu, 31 May 2018 11:03:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58FB8281D2 for ; Thu, 31 May 2018 11:03:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BFCA28783; Thu, 31 May 2018 11:03:15 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C79D928858 for ; Thu, 31 May 2018 11:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wFlAaWndxtPM8thyTYHYAejtq5LYuhqUA84BISG4/Fk=; b=AI1EZHOB9wk0CdseN1haNHfZqD R1J/Tm/pvUQGqaFjmIP9T32TDvvEni44arVQsn2xuhS/mhbzivp65ob2/dHAAxJuoT49vIaaRaHpO WeNtufqZ5WV6Ta4WYTMcllIHKwt6lTU2JwthOYdUNvFeSTLsvMJ79XzPEBKG5iGpKSk+ImWh8urlM /nR/8mkoBEYYqpgVQWDbny1Cg3GVX1z4vylaVwLN+zq69dWE1iixmqQkP37SJjwxYo4DN3XyUkP1j KwKteQl4JheIyg2uURhME7hx2Q0OtymC5M4fh+/BCDy61BJRPhMJbZIlhDnmwOH9nH7ag1yv/wALT jNFd9jfQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOLME-0004zr-JH; Thu, 31 May 2018 11:03:02 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOLJe-0003EA-SA for linux-arm-kernel@lists.infradead.org; Thu, 31 May 2018 11:00:28 +0000 Received: by mail-lf0-x242.google.com with SMTP id 36-v6so7161765lfr.11 for ; Thu, 31 May 2018 04:00:12 -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=RXKrqGArTcDS407/hhdPfxoECHqsKv+DMFo9jMWmjtzqQueGBbZHSap7dynfyEk28g EAdtaHKOX/KYWHcbWCSwGzcojBCWnTrQJcOpd3JvtZRAocrP1iJgk6cuAvXQ3zOojvsO 1qL1ArYPkKdnDrE+iYCbZSxcsDlq6AgY+nCjdCzJcmEHUlRvMWAYRAs+bsHh4WcvovJA mg8RaCrUNYBiuv9raiILbKxistJAT46s5hDrHvobvGqjIRvvE2vYT69QlLtvKzoNTSAG Nm2pYJQCe4688uNFVaooMTGKROHWTnNmfRxyolTQjdGehQ46nQvtFpblVQDUaw60qdt1 9Onw== X-Gm-Message-State: ALKqPweJN6juaEaQAZ5mAhLS6rMwoh6mMpgVvgQOXJSp+9jKSZTM2pHW WYubruwWxCVRqoH0H2lC3a36Ww== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180531_040022_950572_56C0EA60 X-CRM114-Status: GOOD ( 18.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Rajendra Nayak , Geert Uytterhoeven , Kevin Hilman , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jon Hunter , Todor Tomov , Viresh Kumar , linux-tegra@vger.kernel.org, Vincent Guittot , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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[] = {