提交 1e369bcd 编写于 作者: A Axel Lin 提交者: Mark Brown

regulator: da9052: Ensure setting current limit within specific range

Checking da9052_current_limits[row][i] <= max_uA is not enough, it is possible
da9052_current_limits[row][i] may less than the requested min_uA.
Signed-off-by: NAxel Lin <axel.lin@ingics.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 9489e9dc
...@@ -129,17 +129,17 @@ static int da9052_dcdc_set_current_limit(struct regulator_dev *rdev, int min_uA, ...@@ -129,17 +129,17 @@ static int da9052_dcdc_set_current_limit(struct regulator_dev *rdev, int min_uA,
else if (offset == 0) else if (offset == 0)
row = 1; row = 1;
if (min_uA > da9052_current_limits[row][DA9052_MAX_UA] ||
max_uA < da9052_current_limits[row][DA9052_MIN_UA])
return -EINVAL;
for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) { for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) {
if (da9052_current_limits[row][i] <= max_uA) { if ((min_uA <= da9052_current_limits[row][i]) &&
(da9052_current_limits[row][i] <= max_uA)) {
reg_val = i; reg_val = i;
break; break;
} }
} }
if (i < 0)
return -EINVAL;
/* Determine the even or odd position of the buck current limit /* Determine the even or odd position of the buck current limit
* register field * register field
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册