aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-05-13 22:33:37 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-05-14 04:11:34 -0400
commitccfcb1c3cf5616ebd9c61e6c834af3b87fe6b7f7 (patch)
tree86e098faa2a9db347395fdf814b15593ec5ebd69
parent684ae39b91ee7fd2855c35be7f3bf226d42516a5 (diff)
regulator: core: Ensure simple linear voltage mappings falls within the specified range
Integer division may truncate the result. Use DIV_ROUND_UP to ensure simple linear voltage mappings falls within the specified range. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 5751f5ed47c0..8918271f9e85 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2047,7 +2047,7 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
2047 return -EINVAL; 2047 return -EINVAL;
2048 } 2048 }
2049 2049
2050 ret = (min_uV - rdev->desc->min_uV) / rdev->desc->uV_step; 2050 ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
2051 if (ret < 0) 2051 if (ret < 0)
2052 return ret; 2052 return ret;
2053 2053