Commit 4e1d67ed authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: lp872x: set_current_limit should select the maximum current in specific range

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 73f4f3d3
...@@ -374,8 +374,8 @@ static int lp8725_buck_set_current_limit(struct regulator_dev *rdev, ...@@ -374,8 +374,8 @@ static int lp8725_buck_set_current_limit(struct regulator_dev *rdev,
{ {
struct lp872x *lp = rdev_get_drvdata(rdev); struct lp872x *lp = rdev_get_drvdata(rdev);
enum lp872x_regulator_id buck = rdev_get_id(rdev); enum lp872x_regulator_id buck = rdev_get_id(rdev);
int i, max = ARRAY_SIZE(lp8725_buck_uA); int i;
u8 addr, val; u8 addr;
switch (buck) { switch (buck) {
case LP8725_ID_BUCK1: case LP8725_ID_BUCK1:
...@@ -388,17 +388,15 @@ static int lp8725_buck_set_current_limit(struct regulator_dev *rdev, ...@@ -388,17 +388,15 @@ static int lp8725_buck_set_current_limit(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
for (i = 0 ; i < max ; i++) for (i = ARRAY_SIZE(lp8725_buck_uA) - 1 ; i >= 0; i--) {
if (lp8725_buck_uA[i] >= min_uA && if (lp8725_buck_uA[i] >= min_uA &&
lp8725_buck_uA[i] <= max_uA) lp8725_buck_uA[i] <= max_uA)
break; return lp872x_update_bits(lp, addr,
LP8725_BUCK_CL_M,
if (i == max) i << LP8725_BUCK_CL_S);
return -EINVAL; }
val = i << LP8725_BUCK_CL_S;
return lp872x_update_bits(lp, addr, LP8725_BUCK_CL_M, val); return -EINVAL;
} }
static int lp8725_buck_get_current_limit(struct regulator_dev *rdev) static int lp8725_buck_get_current_limit(struct regulator_dev *rdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment