aboutsummaryrefslogtreecommitdiff
path: root/lib/crypto
diff options
context:
space:
mode:
authorMarek BehĂșn <[email protected]>2023-08-01 14:49:31 +0200
committerLee Jones <[email protected]>2023-08-17 11:25:03 +0100
commit065d099f1be58187e6629273c50b948a02b7e1bf (patch)
tree9bf378b3b58cf9f72db477b9b98410bacc829cab /lib/crypto
parent37d0849ed3927f7c4be6f5ee030730f9aa7439c0 (diff)
leds: multicolor: Use rounded division when calculating color components
Given channel intensity, LED brightness and max LED brightness, the multicolor LED framework helper led_mc_calc_color_components() computes the color channel brightness as chan_brightness = brightness * chan_intensity / max_brightness Consider the situation when (brightness, intensity, max_brightness) is for example (16, 15, 255), then chan_brightness is computed to 0 although the fractional divison would give 0.94, which should be rounded to 1. Use DIV_ROUND_CLOSEST here for the division to give more realistic component computation: chan_brightness = DIV_ROUND_CLOSEST(brightness * chan_intensity, max_brightness) Fixes: 55d5d3b46b08 ("leds: multicolor: Introduce a multicolor class definition") Signed-off-by: Marek BehĂșn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
Diffstat (limited to 'lib/crypto')
0 files changed, 0 insertions, 0 deletions