From patchwork Fri Jun 29 11:04:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10496147 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 849FD6022E for ; Fri, 29 Jun 2018 11:04:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A0029889 for ; Fri, 29 Jun 2018 11:04:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B333298B8; Fri, 29 Jun 2018 11:04:55 +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=ham 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 E96F429889 for ; Fri, 29 Jun 2018 11:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934686AbeF2LEv (ORCPT ); Fri, 29 Jun 2018 07:04:51 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40194 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932078AbeF2LEt (ORCPT ); Fri, 29 Jun 2018 07:04:49 -0400 Received: by mail-lj1-f196.google.com with SMTP id a6-v6so6988127ljj.7 for ; Fri, 29 Jun 2018 04:04:49 -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=+IVmNs6WjTGEnYxR2SJvpLhr4W9jz2jhg1z//SWxo+0=; b=LjQU0EAfPEnJvxP+AfC26VVvE2JFRXe2Ikc9PW7Izhsi1AoDlE/Xq3A09ktDRe2WXv lKDnX8vcrbxWfGnC41CfFRS1tIGhamXxoIrDutBrjaYIKIsmcPKvb8Azxv+tU8RNEZ7z Gfqm80fcJ7u1SirEsITI9L67+jC8C2ofYAKqg= 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=+IVmNs6WjTGEnYxR2SJvpLhr4W9jz2jhg1z//SWxo+0=; b=XxwCphXgmZjtOet5i7nHgfbpzGE0T6ZOcqcJO0BqIT2lvbP4yG4HI55hEgMZQWBKru XyP/bpCSC6XbmRl2EAXFUu2ztr9YWtZ1QODtEHSqw+HP5rs9noKhurwjTlcMXv521uMO tuJwjVhgWDXbVJ5+zFa50kFJSBQgt2fOgMPq+HCmFGDZNVlTJBtWojpFdYJOsrhTEwIu mgFdQQvdD2i33QWmqdBP2vJYjttJPYEZQhy5+xF9WKtAhOneNjV2XUr8JMU7orAcRip4 vG3e1HReos/eSAFaTaYn6pW0mJppCu0niXBinwDaXAi5OTgWcWkKBj3YBLbWX+O/JMxP DIkA== X-Gm-Message-State: APt69E1hgjCgejCErEe97yc7+Qf2rDYY6JIpvVofK8I6wzNiAJibSt0s 3Mx1pXYYhp8Q5iW5ZAd2IGyoCA== X-Google-Smtp-Source: AAOMgpcaU6YDlw7pKH/AB1I3YtnJZypBhQL8fqo+Tx7ieHY7ICx9dNGh/9pbATnNcW9pOEdONDxBcg== X-Received: by 2002:a2e:5142:: with SMTP id b2-v6mr9457394lje.30.1530270288265; Fri, 29 Jun 2018 04:04:48 -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 89-v6sm508359lfs.32.2018.06.29.04.04.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 04:04:47 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Lucas Stach , Viresh Kumar , Kevin Hilman , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/3] PM / Domains: Introduce option to attach a device by name to genpd Date: Fri, 29 Jun 2018 13:04:31 +0200 Message-Id: <20180629110432.5179-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629110432.5179-1-ulf.hansson@linaro.org> References: <20180629110432.5179-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 For the multiple PM domain case, let's introduce a new function called genpd_dev_pm_attach_by_name(). This allows a device to be associated with its PM domain through genpd, by using a name based lookup. Note that, genpd_dev_pm_attach_by_name() shall only be called by the driver core / PM core, similar to how the existing dev_pm_domain_attach_by_id() makes use of genpd_dev_pm_attach_by_id(). However, this is implemented by following changes on top. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 24 ++++++++++++++++++++++++ include/linux/pm_domain.h | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index c298de8a8308..a70e4b7a3b14 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2372,6 +2372,30 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); +/** + * genpd_dev_pm_attach_by_name - Associate a device with one of its PM domains. + * @dev: The device used to lookup the PM domain. + * @name: The name of the PM domain. + * + * Parse device's OF node to find a PM domain specifier using the + * power-domain-names DT property. For further description see + * genpd_dev_pm_attach_by_id(). + */ +struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name) +{ + int index; + + if (!dev->of_node) + return NULL; + + index = of_property_match_string(dev->of_node, "power-domain-names", + name); + if (index < 0) + return NULL; + + return genpd_dev_pm_attach_by_id(dev, index); +} + static const struct of_device_id idle_state_match[] = { { .compatible = "domain-idle-state", }, { } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index cb8d84090cfb..03e14a38462d 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -239,6 +239,8 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev, int genpd_dev_pm_attach(struct device *dev); struct device *genpd_dev_pm_attach_by_id(struct device *dev, unsigned int index); +struct device *genpd_dev_pm_attach_by_name(struct device *dev, + char *name); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ static inline int of_genpd_add_provider_simple(struct device_node *np, struct generic_pm_domain *genpd) @@ -290,6 +292,12 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev, return NULL; } +static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev, + char *name) +{ + return NULL; +} + static inline struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) {