summaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-core.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-15 18:28:25 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-15 18:28:25 -0800
commit2dbfca5a181973558277b28b1f4c36362291f5e0 (patch)
treee9d217adf53e3532939e7a3c3bcec94afd671306 /drivers/leds/led-core.c
parentdab363f938a53ddaee60bfecc1aebdbb3d3af5f0 (diff)
parent2969bb18f8895eb4e0fbbc98efe706f15a3acff5 (diff)
downloadop-kernel-dev-2dbfca5a181973558277b28b1f4c36362291f5e0.zip
op-kernel-dev-2dbfca5a181973558277b28b1f4c36362291f5e0.tar.gz
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem update from Bryan Wu: "We got some cleanup and driver for LP8860 as well as some patches for LED Flash Class" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: leds: lp8860: Fix module dependency leds: lp8860: Introduce TI lp8860 4 channel LED driver leds: Add support for setting brightness in a synchronous way leds: implement sysfs interface locking mechanism leds: syscon: handle multiple syscon instances leds: delete copy/paste mistake leds: regulator: Convert to devm_regulator_get_exclusive
Diffstat (limited to 'drivers/leds/led-core.c')
-rw-r--r--drivers/leds/led-core.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index aaa8eba..9886dac 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -42,13 +42,13 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
/* never on - just set to off */
if (!delay_on) {
- __led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness_async(led_cdev, LED_OFF);
return;
}
/* never off - just set to brightness */
if (!delay_off) {
- __led_set_brightness(led_cdev, led_cdev->blink_brightness);
+ led_set_brightness_async(led_cdev, led_cdev->blink_brightness);
return;
}
@@ -117,6 +117,8 @@ EXPORT_SYMBOL_GPL(led_stop_software_blink);
void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
+ int ret = 0;
+
/* delay brightness setting if need to stop soft-blink timer */
if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
led_cdev->delayed_set_value = brightness;
@@ -124,7 +126,17 @@ void led_set_brightness(struct led_classdev *led_cdev,
return;
}
- __led_set_brightness(led_cdev, brightness);
+ if (led_cdev->flags & SET_BRIGHTNESS_ASYNC) {
+ led_set_brightness_async(led_cdev, brightness);
+ return;
+ } else if (led_cdev->flags & SET_BRIGHTNESS_SYNC)
+ ret = led_set_brightness_sync(led_cdev, brightness);
+ else
+ ret = -EINVAL;
+
+ if (ret < 0)
+ dev_dbg(led_cdev->dev, "Setting LED brightness failed (%d)\n",
+ ret);
}
EXPORT_SYMBOL(led_set_brightness);
@@ -143,3 +155,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);
OpenPOWER on IntegriCloud