Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1216590
| Path | csiph.com!xmission!news.glorb.com!diesel.cu.mi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Viresh Kumar <viresh.kumar@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | [PATCH V2 Resend 1/5] PM / OPP: reuse of_parse_phandle() |
| Date | Tue, 01 Sep 2015 07:00:02 +0200 |
| Message-ID | <q3LPQ-4Iw-19@gated-at.bofh.it> (permalink) |
| References | <q3LPP-4Iw-3@gated-at.bofh.it> |
| X-Original-To | Rafael Wysocki <rjw@rjwysocki.net>, sboyd@codeaurora.org |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Repz7hXfgzZQS48Zn9v5BXsLEZUMleZjazlbyEmClZo=; b=Wsk2eRLJ8ZLC+abNqHEgvfBtyeAFukIHfVnOW97QBE0AKbvQoEhBzJZn0+7lSXS64f rbfLoVcdOvbOtT4zhM48DEIsgQUaYYBsn38PBqW1F+Wqdx2+oKTqAblBfq1hQMgBt5oN lu+rmZbMZRYe97Tqo4uyHcO8G5KPO7XX9zp816vDbJuXi/sXHU8heBxLXXz4iipw6i08 1+9Owyv/S8y8i/e/0Bmq1DteO4/LsN4+jTc9DlTvWIsgouVb7M9NXJjyxyF5u7zHJWns wwySKzMe/9hChcAyqHHa1D5bHWW9IBgq7urJYNdci+zQEwU/v64tE2xXRp/xhCPMyp5X jsjg== |
| X-Gm-Message-State | ALoCoQn5qh2fG/R968YCHlYEkrOh2myoOMsf5Xg2W09XyIo1RJssKJKO9yQSlgmwzhFVfs7Dxqv7 |
| X-Received | by 10.66.237.97 with SMTP id vb1mr43279318pac.139.1441083530343; Mon, 31 Aug 2015 21:58:50 -0700 (PDT) |
| X-Mailer | git-send-email 2.4.0 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 180 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, nm@ti.com, khilman@linaro.org, Viresh Kumar <viresh.kumar@linaro.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Len Brown <len.brown@intel.com>, linux-kernel@vger.kernel.org (open list), Pavel Machek <pavel@ucw.cz> |
| X-Original-Date | Tue, 1 Sep 2015 10:28:32 +0530 |
| X-Original-Message-ID | <be1d2761b6c83004b35c8f9e410baa1d019d4b96.1441083292.git.viresh.kumar@linaro.org> |
| X-Original-References | <cover.1441083292.git.viresh.kumar@linaro.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1216590 |
Show key headers only | View raw
We already have a better API to get the opp descriptor block's node from
cpu-node. Lets reuse that instead of creating our own routines for the
same stuff. That cleans the code a lot.
This also kills a check we had earlier (as we are using the generic API
now). Earlier we used to check if the operating-points-v2 property
contained multiple phandles instead of a single phandle.
Killing this check isn't an issue because, we only parse the first entry
with of_parse_phandle(). So, if a user passes multiple phandles, its
really his problem :)
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/base/power/opp.c | 71 ++++++++++++------------------------------------
1 file changed, 17 insertions(+), 54 deletions(-)
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index bb703b5ebaff..d1fe99e08988 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1253,69 +1253,33 @@ void of_cpumask_free_opp_table(cpumask_var_t cpumask)
}
EXPORT_SYMBOL_GPL(of_cpumask_free_opp_table);
-/* Returns opp descriptor node from its phandle. Caller must do of_node_put() */
-static struct device_node *
-_of_get_opp_desc_node_from_prop(struct device *dev, const struct property *prop)
-{
- struct device_node *opp_np;
-
- opp_np = of_find_node_by_phandle(be32_to_cpup(prop->value));
- if (!opp_np) {
- dev_err(dev, "%s: Prop: %s contains invalid opp desc phandle\n",
- __func__, prop->name);
- return ERR_PTR(-EINVAL);
- }
-
- return opp_np;
-}
-
-/* Returns opp descriptor node for a device. Caller must do of_node_put() */
+/* Returns opp descriptor node for a device, caller must do of_node_put() */
static struct device_node *_of_get_opp_desc_node(struct device *dev)
{
- const struct property *prop;
-
- prop = of_find_property(dev->of_node, "operating-points-v2", NULL);
- if (!prop)
- return ERR_PTR(-ENODEV);
- if (!prop->value)
- return ERR_PTR(-ENODATA);
-
/*
* TODO: Support for multiple OPP tables.
*
* There should be only ONE phandle present in "operating-points-v2"
* property.
*/
- if (prop->length != sizeof(__be32)) {
- dev_err(dev, "%s: Invalid opp desc phandle\n", __func__);
- return ERR_PTR(-EINVAL);
- }
- return _of_get_opp_desc_node_from_prop(dev, prop);
+ return of_parse_phandle(dev->of_node, "operating-points-v2", 0);
}
/* Initializes OPP tables based on new bindings */
static int _of_init_opp_table_v2(struct device *dev,
- const struct property *prop)
+ struct device_node *opp_np)
{
- struct device_node *opp_np, *np;
+ struct device_node *np;
struct device_opp *dev_opp;
int ret = 0, count = 0;
- if (!prop->value)
- return -ENODATA;
-
- /* Get opp node */
- opp_np = _of_get_opp_desc_node_from_prop(dev, prop);
- if (IS_ERR(opp_np))
- return PTR_ERR(opp_np);
-
dev_opp = _managed_opp(opp_np);
if (dev_opp) {
/* OPPs are already managed */
if (!_add_list_dev(dev, dev_opp))
ret = -ENOMEM;
- goto put_opp_np;
+ return ret;
}
/* We have opp-list node now, iterate over it and add OPPs */
@@ -1331,10 +1295,8 @@ static int _of_init_opp_table_v2(struct device *dev,
}
/* There should be one of more OPP defined */
- if (WARN_ON(!count)) {
- ret = -ENOENT;
- goto put_opp_np;
- }
+ if (WARN_ON(!count))
+ return -ENOENT;
dev_opp = _find_device_opp(dev);
if (WARN_ON(IS_ERR(dev_opp))) {
@@ -1345,13 +1307,10 @@ static int _of_init_opp_table_v2(struct device *dev,
dev_opp->np = opp_np;
dev_opp->shared_opp = of_property_read_bool(opp_np, "opp-shared");
- of_node_put(opp_np);
return 0;
free_table:
of_free_opp_table(dev);
-put_opp_np:
- of_node_put(opp_np);
return ret;
}
@@ -1418,14 +1377,15 @@ static int _of_init_opp_table_v1(struct device *dev)
*/
int of_init_opp_table(struct device *dev)
{
- const struct property *prop;
+ struct device_node *opp_np;
+ int ret;
/*
* OPPs have two version of bindings now. The older one is deprecated,
* try for the new binding first.
*/
- prop = of_find_property(dev->of_node, "operating-points-v2", NULL);
- if (!prop) {
+ opp_np = _of_get_opp_desc_node(dev);
+ if (!opp_np) {
/*
* Try old-deprecated bindings for backward compatibility with
* older dtbs.
@@ -1433,7 +1393,10 @@ int of_init_opp_table(struct device *dev)
return _of_init_opp_table_v1(dev);
}
- return _of_init_opp_table_v2(dev, prop);
+ ret = _of_init_opp_table_v2(dev, opp_np);
+ of_node_put(opp_np);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(of_init_opp_table);
@@ -1522,7 +1485,7 @@ int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask)
/* Get OPP descriptor node */
np = _of_get_opp_desc_node(cpu_dev);
- if (IS_ERR(np)) {
+ if (!np) {
dev_dbg(cpu_dev, "%s: Couldn't find opp node: %ld\n", __func__,
PTR_ERR(np));
return -ENOENT;
@@ -1546,7 +1509,7 @@ int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask)
/* Get OPP descriptor node */
tmp_np = _of_get_opp_desc_node(tcpu_dev);
- if (IS_ERR(tmp_np)) {
+ if (!tmp_np) {
dev_err(tcpu_dev, "%s: Couldn't find opp node: %ld\n",
__func__, PTR_ERR(tmp_np));
ret = PTR_ERR(tmp_np);
--
2.4.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH V2 Resend 1/5] PM / OPP: reuse of_parse_phandle() Viresh Kumar <viresh.kumar@linaro.org> - 2015-09-01 07:00 +0200 Re: [PATCH V2 Resend 1/5] PM / OPP: reuse of_parse_phandle() Stephen Boyd <sboyd@codeaurora.org> - 2015-09-02 00:50 +0200
csiph-web