diff options
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r-- | drivers/leds/led-class.c | 20 |
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 | ||
55 | static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show, | 55 | static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show, |
56 | led_brightness_store); | 56 | led_brightness_store); |
57 | #ifdef CONFIG_LEDS_TRIGGERS | ||
58 | static 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 | ||