aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-triggers.c
diff options
context:
space:
mode:
authorAdam Nielsen <a.nielsen@shikadi.net>2009-02-17 17:18:04 -0500
committerRichard Purdie <rpurdie@linux.intel.com>2009-04-06 11:06:26 -0400
commit700c6ea2242cf04ba3612fa7cf74763fffcc04fd (patch)
treeb002d5cb630d49bf374dcdfee304c2b87b59c646 /drivers/leds/led-triggers.c
parent17354bfe85275f1bdde7f4a27ebc1ba53e053939 (diff)
leds: Prevent multiple LED triggers with the same name
Signed-off-by: Adam Nielsen <a.nielsen@shikadi.net> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'drivers/leds/led-triggers.c')
-rw-r--r--drivers/leds/led-triggers.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index f910eaffe3a6..d8ddd9ef8994 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -156,12 +156,20 @@ EXPORT_SYMBOL_GPL(led_trigger_set_default);
156int led_trigger_register(struct led_trigger *trigger) 156int led_trigger_register(struct led_trigger *trigger)
157{ 157{
158 struct led_classdev *led_cdev; 158 struct led_classdev *led_cdev;
159 struct led_trigger *trig;
159 160
160 rwlock_init(&trigger->leddev_list_lock); 161 rwlock_init(&trigger->leddev_list_lock);
161 INIT_LIST_HEAD(&trigger->led_cdevs); 162 INIT_LIST_HEAD(&trigger->led_cdevs);
162 163
163 /* Add to the list of led triggers */
164 down_write(&triggers_list_lock); 164 down_write(&triggers_list_lock);
165 /* Make sure the trigger's name isn't already in use */
166 list_for_each_entry(trig, &trigger_list, next_trig) {
167 if (!strcmp(trig->name, trigger->name)) {
168 up_write(&triggers_list_lock);
169 return -EEXIST;
170 }
171 }
172 /* Add to the list of led triggers */
165 list_add_tail(&trigger->next_trig, &trigger_list); 173 list_add_tail(&trigger->next_trig, &trigger_list);
166 up_write(&triggers_list_lock); 174 up_write(&triggers_list_lock);
167 175