Skip to contentSkip to conversation

regulator: Fix set and get current limit for wm831x_buckv

PATCH Applied Axel Lin 2 participants 2 messages Mar 15, 2012 – Mar 26, 2012

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: Fix set and get current limit for wm831x_buckv

WM831X_DC1_HC_THR_MASK is 0x0070.
We need to do proper shift for setting and getting current limit.

---
 drivers/regulator/wm831x-dcdc.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/regulator/wm831x-dcdc.c +4 -2
index 4904a40..3044001 100644
@@ -386,7 +386,8 @@ static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
 	if (i == ARRAY_SIZE(wm831x_dcdc_ilim))
 		return -EINVAL;
 
-	return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK, i);
+	return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK,
+			       i << WM831X_DC1_HC_THR_SHIFT);
 }
 
 static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
@@ -400,7 +401,8 @@ static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
 	if (val < 0)
 		return val;
 
-	return wm831x_dcdc_ilim[val & WM831X_DC1_HC_THR_MASK];
+	val = (val & WM831X_DC1_HC_THR_MASK) >> WM831X_DC1_HC_THR_SHIFT;
+	return wm831x_dcdc_ilim[val];
 }
 
 static struct regulator_ops wm831x_buckv_ops = {
Signature · 1 line
1.7.5.4
Applied
#1 lore raw
Quoted 2 lines · Axel Lin

WM831X_DC1_HC_THR_MASK is 0x0070.
We need to do proper shift for setting and getting current limit.

Applied, thanks.