Commit 73f4f3d3 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: tps6524x: set_current_limit should select the maximum current in specific range

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 422294de
...@@ -502,15 +502,13 @@ static int set_current_limit(struct regulator_dev *rdev, int min_uA, ...@@ -502,15 +502,13 @@ static int set_current_limit(struct regulator_dev *rdev, int min_uA,
if (info->n_ilimsels == 1) if (info->n_ilimsels == 1)
return -EINVAL; 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] && if (min_uA <= info->ilimsels[i] &&
max_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) static int get_current_limit(struct regulator_dev *rdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment