diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-08-08 08:22:35 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-28 14:00:26 -0400 |
commit | 4e1d67eddf70f815b77af5354aaa5e60084fde8b (patch) | |
tree | fd24c00e7ac30de131eb1b31bb8fbe0cf522d4e7 /drivers/regulator | |
parent | 73f4f3d37604ff7084e6157745610c8fb07d27b6 (diff) |
regulator: lp872x: set_current_limit should select the maximum current in specific range
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/lp872x.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 212c38eaba70..6199d0f6cca1 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c | |||
@@ -374,8 +374,8 @@ static int lp8725_buck_set_current_limit(struct regulator_dev *rdev, | |||
374 | { | 374 | { |
375 | struct lp872x *lp = rdev_get_drvdata(rdev); | 375 | struct lp872x *lp = rdev_get_drvdata(rdev); |
376 | enum lp872x_regulator_id buck = rdev_get_id(rdev); | 376 | enum lp872x_regulator_id buck = rdev_get_id(rdev); |
377 | int i, max = ARRAY_SIZE(lp8725_buck_uA); | 377 | int i; |
378 | u8 addr, val; | 378 | u8 addr; |
379 | 379 | ||
380 | switch (buck) { | 380 | switch (buck) { |
381 | case LP8725_ID_BUCK1: | 381 | case LP8725_ID_BUCK1: |
@@ -388,17 +388,15 @@ static int lp8725_buck_set_current_limit(struct regulator_dev *rdev, | |||
388 | return -EINVAL; | 388 | return -EINVAL; |
389 | } | 389 | } |
390 | 390 | ||
391 | for (i = 0 ; i < max ; i++) | 391 | for (i = ARRAY_SIZE(lp8725_buck_uA) - 1 ; i >= 0; i--) { |
392 | if (lp8725_buck_uA[i] >= min_uA && | 392 | if (lp8725_buck_uA[i] >= min_uA && |
393 | lp8725_buck_uA[i] <= max_uA) | 393 | lp8725_buck_uA[i] <= max_uA) |
394 | break; | 394 | return lp872x_update_bits(lp, addr, |
395 | 395 | LP8725_BUCK_CL_M, | |
396 | if (i == max) | 396 | i << LP8725_BUCK_CL_S); |
397 | return -EINVAL; | 397 | } |
398 | |||
399 | val = i << LP8725_BUCK_CL_S; | ||
400 | 398 | ||
401 | return lp872x_update_bits(lp, addr, LP8725_BUCK_CL_M, val); | 399 | return -EINVAL; |
402 | } | 400 | } |
403 | 401 | ||
404 | static int lp8725_buck_get_current_limit(struct regulator_dev *rdev) | 402 | static int lp8725_buck_get_current_limit(struct regulator_dev *rdev) |