From patchwork Fri Nov 28 10:38:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 41694 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9B94A25E46 for ; Fri, 28 Nov 2014 10:38:47 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id n15sf3938554lbi.0 for ; Fri, 28 Nov 2014 02:38:46 -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=eEhCbPpU513j1vY6HzuB0q9JgUy601aibizI/OcfdVs=; b=aCTV1cSf/XmNiLkYnNYWgKngtE4foQwbaAYNVnFdYM1kutYcIr/Yhrk8htWCjEph5N fyTSKThEYwbvxg308lOnVC6jAb1tcA6wOtsiGy9F6isrNQp242GPfcsTAGSt9OOUyH26 MPJlTtKCbDG0WgkbpHGjdSYtfmVL+OQ+dO3XK+DsqaVeuBEACRhAqkDBuscf0vVVLehP kQ0z2iAbFFdrG58YTqWNbirCOk98PAiDzfK3eVgrYYiBfBkVXYl5NUiab2mbqTv+F9QV y/a+XbEXdLjfwAa5q2IskXrN29i2RmOxc+pcr+/y56Hf7ZugTJoZRDWkyi61TMVNIgNv nNnw== X-Gm-Message-State: ALoCoQnWy28o6qq8ISX5afe8ETMtpCvOxsM9M4ScnGYPMLeH1xkPrdZf9A1Nwsd2Ut1NzkL+tf97 X-Received: by 10.112.17.65 with SMTP id m1mr195625lbd.16.1417171126560; Fri, 28 Nov 2014 02:38:46 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.202 with SMTP id y10ls358823lal.47.gmail; Fri, 28 Nov 2014 02:38:46 -0800 (PST) X-Received: by 10.152.27.227 with SMTP id w3mr15240544lag.24.1417171126152; Fri, 28 Nov 2014 02:38:46 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id zf6si9604720lbb.50.2014.11.28.02.38.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Nov 2014 02:38:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id hv19so826668lab.0 for ; Fri, 28 Nov 2014 02:38:46 -0800 (PST) X-Received: by 10.152.8.170 with SMTP id s10mr43088669laa.56.1417171125939; Fri, 28 Nov 2014 02:38:45 -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 ew9csp67160lbc; Fri, 28 Nov 2014 02:38:45 -0800 (PST) X-Received: by 10.152.21.227 with SMTP id y3mr11315617lae.50.1417171125444; Fri, 28 Nov 2014 02:38:45 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id ln11si837730lac.114.2014.11.28.02.38.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Nov 2014 02:38:45 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id ge10so733116lab.2 for ; Fri, 28 Nov 2014 02:38:45 -0800 (PST) X-Received: by 10.152.3.229 with SMTP id f5mr42162853laf.94.1417171125260; Fri, 28 Nov 2014 02:38:45 -0800 (PST) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id n6sm2498806laj.16.2014.11.28.02.38.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Nov 2014 02:38:44 -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 V2] PM / Domains: Add pm_genpd_lookup() API to lookup domain by firmware node Date: Fri, 28 Nov 2014 11:38:35 +0100 Message-Id: <1417171115-5789-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.41 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 firmware 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 ->fwnode pointer in the struct generic_pm_domain, to enable pm_genpd_lookup() to find the domain. Signed-off-by: Ulf Hansson --- Changes in v2: Change from using struct device_node to struct fwnode_handle. Updated commit header accordingly. --- drivers/base/power/domain.c | 27 +++++++++++++++++++++++++++ include/linux/pm_domain.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 735c473..2d881d5 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -75,6 +75,33 @@ 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 firmware node. + * @node: Firmware 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 fwnode_handle *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->fwnode == 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..aa01050 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -43,6 +43,8 @@ struct gpd_cpuidle_data { struct cpuidle_state *idle_state; }; +struct fwnode_handle; + struct generic_pm_domain { struct dev_pm_domain domain; /* PM domain operations */ struct list_head gpd_list_node; /* Node in the global PM domains list */ @@ -53,6 +55,7 @@ struct generic_pm_domain { struct dev_power_governor *gov; struct work_struct power_off_work; const char *name; + struct fwnode_handle *fwnode; /* Firware 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 +129,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 fwnode_handle *node); extern int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, struct gpd_timing_data *td);