mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 15:31:14 +07:00
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>
This commit is contained in:
parent
369cf602f3
commit
f509fd46c1
@ -187,21 +187,18 @@ static int da9055_buck_set_current_limit(struct regulator_dev *rdev, int min_uA,
|
||||
{
|
||||
struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
|
||||
struct da9055_regulator_info *info = regulator->info;
|
||||
int i, val = 0;
|
||||
int i;
|
||||
|
||||
if (min_uA > da9055_current_limits[DA9055_MAX_UA] ||
|
||||
max_uA < da9055_current_limits[DA9055_MIN_UA])
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(da9055_current_limits); i++) {
|
||||
if (min_uA <= da9055_current_limits[i]) {
|
||||
val = i;
|
||||
break;
|
||||
}
|
||||
for (i = ARRAY_SIZE(da9055_current_limits) - 1; i >= 0; i--) {
|
||||
if ((min_uA <= da9055_current_limits[i]) &&
|
||||
(da9055_current_limits[i] <= max_uA))
|
||||
return da9055_reg_update(regulator->da9055,
|
||||
DA9055_REG_BUCK_LIM,
|
||||
info->mode.mask,
|
||||
i << info->mode.shift);
|
||||
}
|
||||
|
||||
return da9055_reg_update(regulator->da9055, DA9055_REG_BUCK_LIM,
|
||||
info->mode.mask, val << info->mode.shift);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int da9055_list_voltage(struct regulator_dev *rdev, unsigned selector)
|
||||
|
Loading…
Reference in New Issue
Block a user