From ccfcb1c3cf5616ebd9c61e6c834af3b87fe6b7f7 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 14 May 2012 10:33:37 +0800 Subject: 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 Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, return -EINVAL; } - ret = (min_uV - rdev->desc->min_uV) / rdev->desc->uV_step; + ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); if (ret < 0) return ret; -- cgit v1.2.2