aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorJacek Anaszewski <j.anaszewski@samsung.com>2014-08-20 09:41:55 -0400
committerBryan Wu <cooloney@gmail.com>2014-09-12 17:01:54 -0400
commit3ef7de5304edf60d0b8674dd7cdacc104e15a93c (patch)
tree2af483fbfc67853ce5c8b3772fadb93c872b0d35 /drivers/leds
parent914ae25a62e77ebbfa0ce7cbc60edd01cc4d1d31 (diff)
leds: Improve and export led_update_brightness
led_update_brightness helper function used to be exploited only locally in the led-class.c module, where its result was being passed to the brightness_show sysfs callback. With the introduction of v4l2-flash subdevice the same functionality becomes required for reading current brightness from a LED device. This patch adds checking of return value of the brightness_get callback and moves the led_update_brightness() function to the LED subsystem public API. 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')
-rw-r--r--drivers/leds/led-class.c6
-rw-r--r--drivers/leds/led-core.c16
2 files changed, 16 insertions, 6 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 71666a40b79a..7440c58b8e6f 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -24,12 +24,6 @@
24 24
25static struct class *leds_class; 25static struct class *leds_class;
26 26
27static void led_update_brightness(struct led_classdev *led_cdev)
28{
29 if (led_cdev->brightness_get)
30 led_cdev->brightness = led_cdev->brightness_get(led_cdev);
31}
32
33static ssize_t brightness_show(struct device *dev, 27static ssize_t brightness_show(struct device *dev,
34 struct device_attribute *attr, char *buf) 28 struct device_attribute *attr, char *buf)
35{ 29{
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 50b579ad948e..aaa8eba9099f 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -127,3 +127,19 @@ void led_set_brightness(struct led_classdev *led_cdev,
127 __led_set_brightness(led_cdev, brightness); 127 __led_set_brightness(led_cdev, brightness);
128} 128}
129EXPORT_SYMBOL(led_set_brightness); 129EXPORT_SYMBOL(led_set_brightness);
130
131int led_update_brightness(struct led_classdev *led_cdev)
132{
133 int ret = 0;
134
135 if (led_cdev->brightness_get) {
136 ret = led_cdev->brightness_get(led_cdev);
137 if (ret >= 0) {
138 led_cdev->brightness = ret;
139 return 0;
140 }
141 }
142
143 return ret;
144}
145EXPORT_SYMBOL(led_update_brightness);