Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccfcb1c3 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

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: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 684ae39b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;