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

regulator: core: Allow fixed voltage range in multiple linear ranges

Current code does not allow fixed voltage range in multiple linear ranges.
If someone does set range->uV_step == 0 in one of the linear ranges, we hit
divided by zero bug. This patch fixes this issue.
For fixed voltage range, return any selector means the same voltage.
Thus just return 0.
Signed-off-by: NAxel Lin <axel.lin@ingics.com>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 c36a1cdf
......@@ -2436,9 +2436,15 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
if (min_uV <= range->min_uV)
min_uV = range->min_uV;
ret = DIV_ROUND_UP(min_uV - range->min_uV, range->uV_step);
if (ret < 0)
return ret;
/* range->uV_step == 0 means fixed voltage range */
if (range->uV_step == 0) {
ret = 0;
} else {
ret = DIV_ROUND_UP(min_uV - range->min_uV,
range->uV_step);
if (ret < 0)
return ret;
}
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册