diff options
author | Jacek Anaszewski <j.anaszewski@samsung.com> | 2014-09-22 17:21:04 +0200 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2014-11-14 23:29:35 +0100 |
commit | acd899e4f3066b6662f6047da5b795cc762093cb (patch) | |
tree | 8a0cdf6849c1aec46d741ddee463067951a942ed /drivers/leds/led-core.c | |
parent | leds: syscon: handle multiple syscon instances (diff) | |
download | linux-acd899e4f3066b6662f6047da5b795cc762093cb.tar.xz linux-acd899e4f3066b6662f6047da5b795cc762093cb.zip |
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 'drivers/leds/led-core.c')
-rw-r--r-- | drivers/leds/led-core.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index aaa8eba9099f..be6d9fa5e971 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -143,3 +143,21 @@ int led_update_brightness(struct led_classdev *led_cdev) return ret; } EXPORT_SYMBOL(led_update_brightness); + +/* Caller must ensure led_cdev->led_access held */ +void led_sysfs_disable(struct led_classdev *led_cdev) +{ + lockdep_assert_held(&led_cdev->led_access); + + led_cdev->flags |= LED_SYSFS_DISABLE; +} +EXPORT_SYMBOL_GPL(led_sysfs_disable); + +/* Caller must ensure led_cdev->led_access held */ +void led_sysfs_enable(struct led_classdev *led_cdev) +{ + lockdep_assert_held(&led_cdev->led_access); + + led_cdev->flags &= ~LED_SYSFS_DISABLE; +} +EXPORT_SYMBOL_GPL(led_sysfs_enable); |