Skip to content

Commit

Permalink
backlight: pwm_bl: Eliminate a 64/32 division
Browse files Browse the repository at this point in the history
lightness*1000 is nowhere near overflowing 32 bits, so we can just use
an ordinary 32/32 division, which is much cheaper than the 64/32 done
via do_div().

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
Rasmus Villemoes authored and Lee Jones committed Oct 14, 2019
1 parent efdf690 commit e802cba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/video/backlight/pwm_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static u64 cie1931(unsigned int lightness, unsigned int scale)
*/
lightness *= 100;
if (lightness <= (8 * scale)) {
retval = DIV_ROUND_CLOSEST_ULL(lightness * 10, 9033);
retval = DIV_ROUND_CLOSEST(lightness * 10, 9033);
} else {
retval = int_pow((lightness + (16 * scale)) / 116, 3);
retval = DIV_ROUND_CLOSEST_ULL(retval, (scale * scale));
Expand Down

0 comments on commit e802cba

Please sign in to comment.