public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] PM / OPP: of_property_count_u32_elems() can return errors
@ 2015-09-22 16:35 Viresh Kumar
  2015-09-22 16:51 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2015-09-22 16:35 UTC (permalink / raw)
  To: Rafael Wysocki
  Cc: linaro-kernel, linux-pm, sboyd, nm, Viresh Kumar,
	Greg Kroah-Hartman, Len Brown, open list, Pavel Machek

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>
---
V1->V2:
- Dropped 'prop' variable.

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

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 28cd75c535b0..1194669c2bb5 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",
-- 
2.4.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] PM / OPP: of_property_count_u32_elems() can return errors
  2015-09-22 16:35 [PATCH V2] PM / OPP: of_property_count_u32_elems() can return errors Viresh Kumar
@ 2015-09-22 16:51 ` Stephen Boyd
  2015-09-25 21:40   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2015-09-22 16:51 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael Wysocki, linaro-kernel, linux-pm, nm, Greg Kroah-Hartman,
	Len Brown, open list, Pavel Machek

On 09/22, Viresh Kumar wrote:
> 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>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] PM / OPP: of_property_count_u32_elems() can return errors
  2015-09-22 16:51 ` Stephen Boyd
@ 2015-09-25 21:40   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2015-09-25 21:40 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Viresh Kumar, linaro-kernel, linux-pm, nm, Greg Kroah-Hartman,
	Len Brown, open list, Pavel Machek

On Tuesday, September 22, 2015 09:51:27 AM Stephen Boyd wrote:
> On 09/22, Viresh Kumar wrote:
> > 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>

Applied, thanks!

Rafael


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-25 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-22 16:35 [PATCH V2] PM / OPP: of_property_count_u32_elems() can return errors Viresh Kumar
2015-09-22 16:51 ` Stephen Boyd
2015-09-25 21:40   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox