regulator: tps6524x: 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>
This commit is contained in:
Axel Lin 2012-08-08 20:21:30 +08:00 committed by Mark Brown
parent 422294deee
commit 73f4f3d376
1 changed files with 4 additions and 6 deletions

View File

@ -502,15 +502,13 @@ static int set_current_limit(struct regulator_dev *rdev, int min_uA,
if (info->n_ilimsels == 1)
return -EINVAL;
for (i = 0; i < info->n_ilimsels; i++)
for (i = info->n_ilimsels - 1; i >= 0; i--) {
if (min_uA <= info->ilimsels[i] &&
max_uA >= info->ilimsels[i])
break;
return write_field(hw, &info->ilimsel, i);
}
if (i >= info->n_ilimsels)
return -EINVAL;
return write_field(hw, &info->ilimsel, i);
return -EINVAL;
}
static int get_current_limit(struct regulator_dev *rdev)