From patchwork Thu Nov 27 14:14:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 41619 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3FA352486D for ; Thu, 27 Nov 2014 14:14:19 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id y19sf3083298wgg.7 for ; Thu, 27 Nov 2014 06:14:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=V2Ianp6Woeui8IbW4EdqnSogoC6zfix0NlDrW46VOqM=; b=aWcME3s77EE79NtXx0Noc96FmbKMxQzMFUt1suDlvRIlDqsgVS6kKtxk6nqx39+9nj uEGvFvYRLRxIeFJh+h0x1ek3uUiEFPY7GCtz2F0lAkuajdZDDuv7NOiSgYN8eWoB7jRO a6Hx1tK/nL4BcKZE3iQl/LIXd3ksTADAbwQBVkNMxhCRRgmTYOBzEqjSpLv9E86GiGZe 88Ou8TpxQDfl1Yt5uWVafjgGX/Q8SVT5xCwF6l5v6ZbUK1dUpWSpP/GCsrtgE7jyitBb frHCJQUgOlrU4smYD5IyVlcml5j0uxpk10yiU+HpvP1NCCJ/jK8LNgRmwPnc09pvl/Do qQtA== X-Gm-Message-State: ALoCoQlwvl262gDfO3/vZhmfgl+8CmQHBHVrk0PxDtIkB1QPmFJLPa0ZdMI1VU0xUH9HMpnv7oOt X-Received: by 10.112.154.194 with SMTP id vq2mr5175994lbb.10.1417097658534; Thu, 27 Nov 2014 06:14:18 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.10.39 with SMTP id f7ls791099lab.75.gmail; Thu, 27 Nov 2014 06:14:18 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr38824606lbc.23.1417097658225; Thu, 27 Nov 2014 06:14:18 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id kb3si7365037lbc.130.2014.11.27.06.14.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 06:14:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so4174644lab.22 for ; Thu, 27 Nov 2014 06:14:18 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr39364392laa.71.1417097658106; Thu, 27 Nov 2014 06:14:18 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp803893lbc; Thu, 27 Nov 2014 06:14:17 -0800 (PST) X-Received: by 10.181.28.3 with SMTP id jk3mr30297391wid.14.1417097657232; Thu, 27 Nov 2014 06:14:17 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com. [209.85.212.178]) by mx.google.com with ESMTPS id cz10si13295621wib.49.2014.11.27.06.14.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 06:14:17 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; Received: by mail-wi0-f178.google.com with SMTP id hi2so8462867wib.5 for ; Thu, 27 Nov 2014 06:14:17 -0800 (PST) X-Received: by 10.194.110.4 with SMTP id hw4mr60158469wjb.102.1417097656932; Thu, 27 Nov 2014 06:14:16 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id mc10sm25428355wic.24.2014.11.27.06.14.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Nov 2014 06:14:15 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Kevin Hilman , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Dmitry Torokhov , Sylwester Nawrocki , Amit Daniel Kachhap , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH] PM / Domains: Add pm_genpd_lookup() API to lookup domain by device node Date: Thu, 27 Nov 2014 15:14:13 +0100 Message-Id: <1417097653-22599-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In a step to move away from using genpd's name based APIs, such as the pm_genpd_add_subdomain_names(), provide an API to lookup an already initialized generic PM domain by its device node. This API would typically be a called from SOC specific code, to fetch a handle to the domain. Especially convenient to configure subdomains and when the hierarchy of the domains are described in DT. Do note, before pm_genpd_init() is invoked to initialize a generic PM domain, it's the callers responsibility to assign the new ->dev_node pointer in the struct generic_pm_domain, to enable pm_genpd_lookup() to find the domain. Signed-off-by: Ulf Hansson --- The background to why I propose this patch comes from a discussion around the below patchset: https://lkml.org/lkml/2014/11/24/290 --- drivers/base/power/domain.c | 26 ++++++++++++++++++++++++++ include/linux/pm_domain.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 735c473..34555eb 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -75,6 +75,32 @@ struct generic_pm_domain *dev_to_genpd(struct device *dev) return pd_to_genpd(dev->pm_domain); } +/** + * pm_genpd_lookup - Fetch a generic PM domain object by device node + * @node: Device node to a corresponding genpd. + * + * Returns a valid pointer to struct generic_pm_domain on success or ERR_PTR() + * on failure. + */ +struct generic_pm_domain *pm_genpd_lookup(struct device_node *node) +{ + struct generic_pm_domain *genpd = ERR_PTR(-ENOENT), *gpd; + + if (IS_ERR_OR_NULL(node)) + return ERR_PTR(-EINVAL); + + mutex_lock(&gpd_list_lock); + list_for_each_entry(gpd, &gpd_list, gpd_list_node) { + if (gpd->dev_node == node) { + genpd = gpd; + break; + } + } + mutex_unlock(&gpd_list_lock); + return genpd; +} +EXPORT_SYMBOL_GPL(pm_genpd_lookup); + static int genpd_stop_dev(struct generic_pm_domain *genpd, struct device *dev) { return GENPD_DEV_TIMED_CALLBACK(genpd, int, stop, dev, diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 8cbd32e..322cb7c 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -53,6 +53,7 @@ struct generic_pm_domain { struct dev_power_governor *gov; struct work_struct power_off_work; const char *name; + struct device_node *dev_node; /* Device node for the PM domain */ unsigned int in_progress; /* Number of devices being suspended now */ atomic_t sd_count; /* Number of subdomains with power "on" */ enum gpd_status status; /* Current state of the domain */ @@ -126,6 +127,7 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) } extern struct generic_pm_domain *dev_to_genpd(struct device *dev); +extern struct generic_pm_domain *pm_genpd_lookup(struct device_node *node); extern int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, struct gpd_timing_data *td);