Skip to content

Commit

Permalink
regulator: wm831x-dcdc: set_current_limit should select the maximum c…
Browse files Browse the repository at this point in the history
…urrent in specific range

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Aug 28, 2012
1 parent cb44cde commit 422294d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/regulator/wm831x-dcdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,15 @@ static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
u16 reg = dcdc->base + WM831X_DCDC_CONTROL_2;
int i;

for (i = 0; i < ARRAY_SIZE(wm831x_dcdc_ilim); i++) {
for (i = ARRAY_SIZE(wm831x_dcdc_ilim) - 1; i >= 0; i--) {
if ((min_uA <= wm831x_dcdc_ilim[i]) &&
(wm831x_dcdc_ilim[i] <= max_uA))
break;
return wm831x_set_bits(wm831x, reg,
WM831X_DC1_HC_THR_MASK,
i << WM831X_DC1_HC_THR_SHIFT);
}
if (i == ARRAY_SIZE(wm831x_dcdc_ilim))
return -EINVAL;

return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK,
i << WM831X_DC1_HC_THR_SHIFT);
return -EINVAL;
}

static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
Expand Down

0 comments on commit 422294d

Please sign in to comment.