diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-10 02:20:03 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-10 05:14:01 -0400 |
commit | 2358b7763ee6673c0d08ddf9dcfe96e982e9b26f (patch) | |
tree | 33c69d226ba54a28222071360e4f4cd17d5fce2b /drivers/regulator/max8997.c | |
parent | 0fa310ccabfe9034017e1b6780052d36fbd9f38f (diff) |
regulator: max8997: Use simple equation to get selector
It's more efficient to get the best selector by simple equation.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8997.c')
-rw-r--r-- | drivers/regulator/max8997.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 89c93d891140..db09244bb3ed 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -415,7 +415,7 @@ static inline int max8997_get_voltage_proper_val( | |||
415 | const struct voltage_map_desc *desc, | 415 | const struct voltage_map_desc *desc, |
416 | int min_vol, int max_vol) | 416 | int min_vol, int max_vol) |
417 | { | 417 | { |
418 | int i = 0; | 418 | int i; |
419 | 419 | ||
420 | if (desc == NULL) | 420 | if (desc == NULL) |
421 | return -EINVAL; | 421 | return -EINVAL; |
@@ -423,9 +423,10 @@ static inline int max8997_get_voltage_proper_val( | |||
423 | if (max_vol < desc->min || min_vol > desc->max) | 423 | if (max_vol < desc->min || min_vol > desc->max) |
424 | return -EINVAL; | 424 | return -EINVAL; |
425 | 425 | ||
426 | while (desc->min + desc->step * i < min_vol && | 426 | if (min_vol < desc->min) |
427 | desc->min + desc->step * i < desc->max) | 427 | min_vol = desc->min; |
428 | i++; | 428 | |
429 | i = DIV_ROUND_UP(min_vol - desc->min, desc->step); | ||
429 | 430 | ||
430 | if (desc->min + desc->step * i > max_vol) | 431 | if (desc->min + desc->step * i > max_vol) |
431 | return -EINVAL; | 432 | return -EINVAL; |