public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFT] regulator: da9055: Fix return wrong selector in da9055_regulator_get_voltage_sel
@ 2012-11-20  4:39 Axel Lin
  2012-11-20  4:51 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-11-20  4:39 UTC (permalink / raw)
  To: Mark Brown; +Cc: David Dajun Chen, Ashish Jangam, Liam Girdwood, linux-kernel

We do "selector += info->volt.v_offset" in da9055_regulator_set_voltage_bits()
to take care of voltage range that does not start with 0 offset.
Thus in da9055_regulator_get_voltage_sel() we should do corresponding
"sel -= volt.v_offset" before returning selector.
Otherwise, we pass wrong selector for list_voltage callback.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/da9055-regulator.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c
index 79c5665..dbcb43d 100644
--- a/drivers/regulator/da9055-regulator.c
+++ b/drivers/regulator/da9055-regulator.c
@@ -232,10 +232,9 @@ static int da9055_regulator_get_voltage_sel(struct regulator_dev *rdev)
 		return ret;
 
 	sel = (ret & volt.v_mask);
-	if (sel <= volt.v_offset)
-		return 0;
-	else
-		return sel;
+	sel -= volt.v_offset;
+
+	return sel;
 }
 
 static int da9055_regulator_set_voltage_bits(struct regulator_dev *rdev,
-- 
1.7.9.5




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

* Re: [PATCH RFT] regulator: da9055: Fix return wrong selector in da9055_regulator_get_voltage_sel
  2012-11-20  4:39 [PATCH RFT] regulator: da9055: Fix return wrong selector in da9055_regulator_get_voltage_sel Axel Lin
@ 2012-11-20  4:51 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-11-20  4:51 UTC (permalink / raw)
  To: Axel Lin; +Cc: David Dajun Chen, Ashish Jangam, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 531 bytes --]

On Tue, Nov 20, 2012 at 12:39:07PM +0800, Axel Lin wrote:
> We do "selector += info->volt.v_offset" in da9055_regulator_set_voltage_bits()
> to take care of voltage range that does not start with 0 offset.
> Thus in da9055_regulator_get_voltage_sel() we should do corresponding
> "sel -= volt.v_offset" before returning selector.
> Otherwise, we pass wrong selector for list_voltage callback.

No, we should just be using raw register values as the selectors and
fixing this in list_voltage() by returning 0 for invalid selectors.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-11-20  4:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-20  4:39 [PATCH RFT] regulator: da9055: Fix return wrong selector in da9055_regulator_get_voltage_sel Axel Lin
2012-11-20  4:51 ` Mark Brown

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