summaryrefslogtreecommitdiff
path: root/drivers/leds/led-class.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2006-03-31 14:31:05 +0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-01 00:18:56 +0400
commitc3bc9956ec52fb2c70f29aa894d8eec766116584 (patch)
treec93aa56e6793cfa283d13a28cfa6c02a30f6c794 /drivers/leds/led-class.c
parentc72a1d608dd0eb3d553a08bfdf1c0041bebaa8a0 (diff)
downloadlinux-c3bc9956ec52fb2c70f29aa894d8eec766116584.tar.xz
[PATCH] LED: add LED trigger tupport
Add support for LED triggers to the LED subsystem. "Triggers" are events which change the state of an LED. Two kinds of trigger are available, simple ones which can be added to exising code with minimum disruption and complex ones for implementing new or more complex functionality. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r--drivers/leds/led-class.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 0292df4101ba..b0b5d05fadd6 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -54,6 +54,9 @@ static ssize_t led_brightness_store(struct class_device *dev,
static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show,
led_brightness_store);
+#ifdef CONFIG_LEDS_TRIGGERS
+static CLASS_DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
+#endif
/**
* led_classdev_suspend - suspend an led_classdev.
@@ -100,6 +103,15 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
list_add_tail(&led_cdev->node, &leds_list);
write_unlock(&leds_list_lock);
+#ifdef CONFIG_LEDS_TRIGGERS
+ rwlock_init(&led_cdev->trigger_lock);
+
+ led_trigger_set_default(led_cdev);
+
+ class_device_create_file(led_cdev->class_dev,
+ &class_device_attr_trigger);
+#endif
+
printk(KERN_INFO "Registered led device: %s\n",
led_cdev->class_dev->class_id);
@@ -117,6 +129,14 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
{
class_device_remove_file(led_cdev->class_dev,
&class_device_attr_brightness);
+#ifdef CONFIG_LEDS_TRIGGERS
+ class_device_remove_file(led_cdev->class_dev,
+ &class_device_attr_trigger);
+ write_lock(&led_cdev->trigger_lock);
+ if (led_cdev->trigger)
+ led_trigger_set(led_cdev, NULL);
+ write_unlock(&led_cdev->trigger_lock);
+#endif
class_device_unregister(led_cdev->class_dev);