Skip to content

Commit

Permalink
regulator: core: Ensure simple linear voltage mappings falls within t…
Browse files Browse the repository at this point in the history
…he 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>
  • Loading branch information
Axel Lin authored and Mark Brown committed May 14, 2012
1 parent 684ae39 commit ccfcb1c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ccfcb1c

Please sign in to comment.