diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-09-22 09:35:31 -0700 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2016-04-01 10:52:53 +0530 |
commit | ab64a1d71d83d910a7bc1d3bea00d8da2b21b610 (patch) | |
tree | 01b42aca185b437c788e84350376a284172d907a | |
parent | fdba5906018c939cd7dc7d7f1825438d0c4840fe (diff) |
PM / OPP: of_property_count_u32_elems() can return errors
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>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/base/power/opp.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 1ab069e330aa..94e05c0e0d66 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -892,10 +892,17 @@ static int opp_get_microvolt(struct dev_pm_opp *opp, struct device *dev) 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 */ + if (!of_find_property(opp->np, "opp-microvolt", NULL)) 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", |