linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: anatop: Fix wrong mask used in anatop_get_voltage_sel
@ 2012-07-16 16:10 Axel Lin
  2012-08-01 20:07 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-07-16 16:10 UTC (permalink / raw)
  To: Mark Brown
  Cc: Nancy Chen, Ying-Chun Liu (PaulLiu), Liam Girdwood, linux-kernel

The mask used in anatop_get_voltage_sel does not match the mask used in
anatop_set_voltage_sel.
We need to do left shift anatop_reg->vol_bit_shift bits for the correct mask.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/anatop-regulator.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index e9c2085..ce0fe72 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -64,14 +64,15 @@ static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector)
 static int anatop_get_voltage_sel(struct regulator_dev *reg)
 {
 	struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
-	u32 val;
+	u32 val, mask;
 
 	if (!anatop_reg->control_reg)
 		return -ENOTSUPP;
 
 	val = anatop_read_reg(anatop_reg->mfd, anatop_reg->control_reg);
-	val = (val & ((1 << anatop_reg->vol_bit_width) - 1)) >>
+	mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
 		anatop_reg->vol_bit_shift;
+	val = (val & mask) >> anatop_reg->vol_bit_shift;
 
 	return val - anatop_reg->min_bit_val;
 }
-- 
1.7.9.5




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

* Re: [PATCH] regulator: anatop: Fix wrong mask used in anatop_get_voltage_sel
  2012-07-16 16:10 [PATCH] regulator: anatop: Fix wrong mask used in anatop_get_voltage_sel Axel Lin
@ 2012-08-01 20:07 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-08-01 20:07 UTC (permalink / raw)
  To: Axel Lin; +Cc: Nancy Chen, Ying-Chun Liu (PaulLiu), Liam Girdwood, linux-kernel

On Tue, Jul 17, 2012 at 12:10:42AM +0800, Axel Lin wrote:
> The mask used in anatop_get_voltage_sel does not match the mask used in
> anatop_set_voltage_sel.
> We need to do left shift anatop_reg->vol_bit_shift bits for the correct mask.

Applied, thanks.

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

end of thread, other threads:[~2012-08-01 20:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-16 16:10 [PATCH] regulator: anatop: Fix wrong mask used in anatop_get_voltage_sel Axel Lin
2012-08-01 20:07 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).