Skip to content

Commit

Permalink
leds: Don't allow brightness values greater than max_brightness
Browse files Browse the repository at this point in the history
Since commit 4d71a4a ("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>
  • Loading branch information
Gabriele Mazzotta authored and Bryan Wu committed Jan 14, 2015
1 parent 13b695f commit 56d06fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/leds/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
static inline void led_set_brightness_async(struct led_classdev *led_cdev,
enum led_brightness value)
{
led_cdev->brightness = min(value, led_cdev->max_brightness);
value = min(value, led_cdev->max_brightness);
led_cdev->brightness = value;

if (!(led_cdev->flags & LED_SUSPENDED))
led_cdev->brightness_set(led_cdev, value);
Expand Down

0 comments on commit 56d06fd

Please sign in to comment.