lkml.org 
[lkml]   [2015]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] PM / OPP: of_property_count_u32_elems() can return errors
Date
of_property_count_u32_elems() will never return 0, but a -ve error value
of a positive count. And so the current !count check is wrong.

Also, a missing "opp-microvolt" property isn't a problem and so we need
to do of_find_property() separately to confirm that.

Fixes: 274659029c9d ("PM / OPP: Add support to parse "operating-points-v2" bindings")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
For 4.3.

drivers/base/power/opp.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 28cd75c535b0..2048164d6c53 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -889,13 +889,22 @@ static int _opp_add_dynamic(struct device *dev, unsigned long freq,
/* TODO: Support multiple regulators */
static int opp_get_microvolt(struct dev_pm_opp *opp, struct device *dev)
{
+ struct property *prop;
u32 microvolt[3] = {0};
int count, ret;

- count = of_property_count_u32_elems(opp->np, "opp-microvolt");
- if (!count)
+ /* Missing property isn't a problem, but an invalid entry is */
+ prop = of_find_property(opp->np, "opp-microvolt", NULL);
+ if (!prop)
return 0;

+ count = of_property_count_u32_elems(opp->np, "opp-microvolt");
+ if (count < 0) {
+ dev_err(dev, "%s: Invalid opp-microvolt property (%d)\n",
+ __func__, count);
+ return count;
+ }
+
/* There can be one or three elements here */
if (count != 1 && count != 3) {
dev_err(dev, "%s: Invalid number of elements in opp-microvolt property (%d)\n",
--
2.4.0


\
 
 \ /
  Last update: 2015-09-17 19:21    [W:0.054 / U:2.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site