Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: Don't allow brightness values greater than max_brightness

Since commit 4d71a4a12b13 ("leds: Add support for setting brightness in
a synchronous way") the value passed to brightness_set() is no longer
limited to max_brightness and can be different from the internally saved
brightness value.

Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>

authored by

Gabriele Mazzotta and committed by
Bryan Wu
56d06fde 13b695f3

+2 -1
+2 -1
drivers/leds/leds.h
··· 20 20 static inline void led_set_brightness_async(struct led_classdev *led_cdev, 21 21 enum led_brightness value) 22 22 { 23 - led_cdev->brightness = min(value, led_cdev->max_brightness); 23 + value = min(value, led_cdev->max_brightness); 24 + led_cdev->brightness = value; 24 25 25 26 if (!(led_cdev->flags & LED_SUSPENDED)) 26 27 led_cdev->brightness_set(led_cdev, value);