aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-class.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2006-03-31 05:31:05 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-31 15:18:56 -0500
commitc3bc9956ec52fb2c70f29aa894d8eec766116584 (patch)
treec93aa56e6793cfa283d13a28cfa6c02a30f6c794 /drivers/leds/led-class.c
parentc72a1d608dd0eb3d553a08bfdf1c0041bebaa8a0 (diff)
[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,
54 54
55static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show, 55static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show,
56 led_brightness_store); 56 led_brightness_store);
57#ifdef CONFIG_LEDS_TRIGGERS
58static CLASS_DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
59#endif
57 60
58/** 61/**
59 * led_classdev_suspend - suspend an led_classdev. 62 * led_classdev_suspend - suspend an led_classdev.
@@ -100,6 +103,15 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
100 list_add_tail(&led_cdev->node, &leds_list); 103 list_add_tail(&led_cdev->node, &leds_list);
101 write_unlock(&leds_list_lock); 104 write_unlock(&leds_list_lock);
102 105
106#ifdef CONFIG_LEDS_TRIGGERS
107 rwlock_init(&led_cdev->trigger_lock);
108
109 led_trigger_set_default(led_cdev);
110
111 class_device_create_file(led_cdev->class_dev,
112 &class_device_attr_trigger);
113#endif
114
103 printk(KERN_INFO "Registered led device: %s\n", 115 printk(KERN_INFO "Registered led device: %s\n",
104 led_cdev->class_dev->class_id); 116 led_cdev->class_dev->class_id);
105 117
@@ -117,6 +129,14 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
117{ 129{
118 class_device_remove_file(led_cdev->class_dev, 130 class_device_remove_file(led_cdev->class_dev,
119 &class_device_attr_brightness); 131 &class_device_attr_brightness);
132#ifdef CONFIG_LEDS_TRIGGERS
133 class_device_remove_file(led_cdev->class_dev,
134 &class_device_attr_trigger);
135 write_lock(&led_cdev->trigger_lock);
136 if (led_cdev->trigger)
137 led_trigger_set(led_cdev, NULL);
138 write_unlock(&led_cdev->trigger_lock);
139#endif
120 140
121 class_device_unregister(led_cdev->class_dev); 141 class_device_unregister(led_cdev->class_dev);
122 142