regulator: core: Ensure simple linear voltage mappings falls within the specified range
PATCH 1/1 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 <[email protected]>
--- drivers/regulator/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/core.c +1 -1
@@ -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;
Signature · 1 line
1.7.5.4
Mark Brown
AppliedQuoted 3 lines · Axel Lin
Integer division may truncate the result.
UseDIV_ROUND_UPto ensure simple linear voltage mappings falls within the specified range.
Applied, thanks.