aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/leds.h
diff options
context:
space:
mode:
authorJacek Anaszewski <j.anaszewski@samsung.com>2014-09-22 11:21:04 -0400
committerBryan Wu <cooloney@gmail.com>2014-11-14 17:29:35 -0500
commitacd899e4f3066b6662f6047da5b795cc762093cb (patch)
tree8a0cdf6849c1aec46d741ddee463067951a942ed /include/linux/leds.h
parent3f6e42c808409c40dd0d0f8fe2022d197b27455e (diff)
leds: implement sysfs interface locking mechanism
Add a mechanism for locking LED subsystem sysfs interface. This patch prepares ground for addition of LED Flash Class extension, whose API will be integrated with V4L2 Flash API. Such a fusion enforces introducing a locking scheme, which will secure consistent access to the LED Flash Class device. The mechanism being introduced allows for disabling LED subsystem sysfs interface by calling led_sysfs_disable function and enabling it by calling led_sysfs_enable. The functions alter the LED_SYSFS_DISABLE flag state and must be called under mutex lock. The state of the lock is checked with use of led_sysfs_is_disabled function. Such a design allows for providing immediate feedback to the user space on whether the LED Flash Class device is available or is under V4L2 Flash sub-device control. 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 'include/linux/leds.h')
-rw-r--r--include/linux/leds.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/leds.h b/include/linux/leds.h
index a57611d0c94e..737f9b1051f2 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -13,6 +13,7 @@
13#define __LINUX_LEDS_H_INCLUDED 13#define __LINUX_LEDS_H_INCLUDED
14 14
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/mutex.h>
16#include <linux/rwsem.h> 17#include <linux/rwsem.h>
17#include <linux/spinlock.h> 18#include <linux/spinlock.h>
18#include <linux/timer.h> 19#include <linux/timer.h>
@@ -42,6 +43,7 @@ struct led_classdev {
42#define LED_BLINK_ONESHOT (1 << 17) 43#define LED_BLINK_ONESHOT (1 << 17)
43#define LED_BLINK_ONESHOT_STOP (1 << 18) 44#define LED_BLINK_ONESHOT_STOP (1 << 18)
44#define LED_BLINK_INVERT (1 << 19) 45#define LED_BLINK_INVERT (1 << 19)
46#define LED_SYSFS_DISABLE (1 << 20)
45 47
46 /* Set LED brightness level */ 48 /* Set LED brightness level */
47 /* Must not sleep, use a workqueue if needed */ 49 /* Must not sleep, use a workqueue if needed */
@@ -85,6 +87,9 @@ struct led_classdev {
85 /* true if activated - deactivate routine uses it to do cleanup */ 87 /* true if activated - deactivate routine uses it to do cleanup */
86 bool activated; 88 bool activated;
87#endif 89#endif
90
91 /* Ensures consistent access to the LED Flash Class device */
92 struct mutex led_access;
88}; 93};
89 94
90extern int led_classdev_register(struct device *parent, 95extern int led_classdev_register(struct device *parent,
@@ -151,6 +156,33 @@ extern void led_set_brightness(struct led_classdev *led_cdev,
151 */ 156 */
152extern int led_update_brightness(struct led_classdev *led_cdev); 157extern int led_update_brightness(struct led_classdev *led_cdev);
153 158
159/**
160 * led_sysfs_disable - disable LED sysfs interface
161 * @led_cdev: the LED to set
162 *
163 * Disable the led_cdev's sysfs interface.
164 */
165extern void led_sysfs_disable(struct led_classdev *led_cdev);
166
167/**
168 * led_sysfs_enable - enable LED sysfs interface
169 * @led_cdev: the LED to set
170 *
171 * Enable the led_cdev's sysfs interface.
172 */
173extern void led_sysfs_enable(struct led_classdev *led_cdev);
174
175/**
176 * led_sysfs_is_disabled - check if LED sysfs interface is disabled
177 * @led_cdev: the LED to query
178 *
179 * Returns: true if the led_cdev's sysfs interface is disabled.
180 */
181static inline bool led_sysfs_is_disabled(struct led_classdev *led_cdev)
182{
183 return led_cdev->flags & LED_SYSFS_DISABLE;
184}
185
154/* 186/*
155 * LED Triggers 187 * LED Triggers
156 */ 188 */