diff options
author | Jacek Anaszewski <j.anaszewski@samsung.com> | 2014-11-14 05:50:18 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2014-11-14 17:29:35 -0500 |
commit | 4d71a4a12b130ad033219e6f58c74a64059415eb (patch) | |
tree | 5b9560719835c5a204b92f4bb7e44aae6793281c /drivers/leds/leds.h | |
parent | acd899e4f3066b6662f6047da5b795cc762093cb (diff) |
leds: Add support for setting brightness in a synchronous way
There are use cases when setting a LED brightness has to
have immediate effect (e.g. setting a torch LED brightness).
This patch extends LED subsystem to support such operations.
The LED subsystem internal API __led_set_brightness is changed
to led_set_brightness_async and new led_set_brightness_sync API
is added.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds.h')
-rw-r--r-- | drivers/leds/leds.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index 4c50365344a9..2348dbda5269 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h | |||
@@ -17,16 +17,28 @@ | |||
17 | #include <linux/rwsem.h> | 17 | #include <linux/rwsem.h> |
18 | #include <linux/leds.h> | 18 | #include <linux/leds.h> |
19 | 19 | ||
20 | static inline void __led_set_brightness(struct led_classdev *led_cdev, | 20 | static inline void led_set_brightness_async(struct led_classdev *led_cdev, |
21 | enum led_brightness value) | 21 | enum led_brightness value) |
22 | { | 22 | { |
23 | if (value > led_cdev->max_brightness) | 23 | led_cdev->brightness = min(value, led_cdev->max_brightness); |
24 | value = led_cdev->max_brightness; | 24 | |
25 | led_cdev->brightness = value; | ||
26 | if (!(led_cdev->flags & LED_SUSPENDED)) | 25 | if (!(led_cdev->flags & LED_SUSPENDED)) |
27 | led_cdev->brightness_set(led_cdev, value); | 26 | led_cdev->brightness_set(led_cdev, value); |
28 | } | 27 | } |
29 | 28 | ||
29 | static inline int led_set_brightness_sync(struct led_classdev *led_cdev, | ||
30 | enum led_brightness value) | ||
31 | { | ||
32 | int ret = 0; | ||
33 | |||
34 | led_cdev->brightness = min(value, led_cdev->max_brightness); | ||
35 | |||
36 | if (!(led_cdev->flags & LED_SUSPENDED)) | ||
37 | ret = led_cdev->brightness_set_sync(led_cdev, | ||
38 | led_cdev->brightness); | ||
39 | return ret; | ||
40 | } | ||
41 | |||
30 | static inline int led_get_brightness(struct led_classdev *led_cdev) | 42 | static inline int led_get_brightness(struct led_classdev *led_cdev) |
31 | { | 43 | { |
32 | return led_cdev->brightness; | 44 | return led_cdev->brightness; |