diff options
author | Axel Lin <axel.lin@ingics.com> | 2012-11-26 02:26:41 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-11-27 15:21:26 -0500 |
commit | f509fd46c164524d06a33b01a64f9bd2033e4825 (patch) | |
tree | 1c1cecd905481b8468a936c2510f787a9ee2d234 /drivers/regulator/da9055-regulator.c | |
parent | 369cf602f364a60c72b8258c21eca8793939328f (diff) |
regulator: da9055: Select maximum current in specific range for set_current_limit
Selecting the minimal value is only true for voltage regulators.
For current regulators the maximum in the given range should be
selected instead.
This issue was reported by Heiko Stuebner for gpio-regulator driver [1],
and the conclusion is to select the max current for current regulators [2].
[1] https://lkml.org/lkml/2012/8/5/162
[2] https://lkml.org/lkml/2012/8/6/183
This patch also ensures da9055_buck_set_current_limit return -EINVAL when the
supported current limit does not meet the request range.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/da9055-regulator.c')
-rw-r--r-- | drivers/regulator/da9055-regulator.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index 121564bb5415..db59ce7534cd 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c | |||
@@ -187,21 +187,18 @@ static int da9055_buck_set_current_limit(struct regulator_dev *rdev, int min_uA, | |||
187 | { | 187 | { |
188 | struct da9055_regulator *regulator = rdev_get_drvdata(rdev); | 188 | struct da9055_regulator *regulator = rdev_get_drvdata(rdev); |
189 | struct da9055_regulator_info *info = regulator->info; | 189 | struct da9055_regulator_info *info = regulator->info; |
190 | int i, val = 0; | 190 | int i; |
191 | |||
192 | if (min_uA > da9055_current_limits[DA9055_MAX_UA] || | ||
193 | max_uA < da9055_current_limits[DA9055_MIN_UA]) | ||
194 | return -EINVAL; | ||
195 | 191 | ||
196 | for (i = 0; i < ARRAY_SIZE(da9055_current_limits); i++) { | 192 | for (i = ARRAY_SIZE(da9055_current_limits) - 1; i >= 0; i--) { |
197 | if (min_uA <= da9055_current_limits[i]) { | 193 | if ((min_uA <= da9055_current_limits[i]) && |
198 | val = i; | 194 | (da9055_current_limits[i] <= max_uA)) |
199 | break; | 195 | return da9055_reg_update(regulator->da9055, |
200 | } | 196 | DA9055_REG_BUCK_LIM, |
197 | info->mode.mask, | ||
198 | i << info->mode.shift); | ||
201 | } | 199 | } |
202 | 200 | ||
203 | return da9055_reg_update(regulator->da9055, DA9055_REG_BUCK_LIM, | 201 | return -EINVAL; |
204 | info->mode.mask, val << info->mode.shift); | ||
205 | } | 202 | } |
206 | 203 | ||
207 | static int da9055_list_voltage(struct regulator_dev *rdev, unsigned selector) | 204 | static int da9055_list_voltage(struct regulator_dev *rdev, unsigned selector) |