Skip to content

Commit

Permalink
leds: Prevent multiple LED triggers with the same name
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Nielsen <a.nielsen@shikadi.net>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
  • Loading branch information
Adam Nielsen authored and Richard Purdie committed Apr 6, 2009
1 parent 17354bf commit 700c6ea
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/leds/led-triggers.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,20 @@ EXPORT_SYMBOL_GPL(led_trigger_set_default);
int led_trigger_register(struct led_trigger *trigger)
{
struct led_classdev *led_cdev;
struct led_trigger *trig;

rwlock_init(&trigger->leddev_list_lock);
INIT_LIST_HEAD(&trigger->led_cdevs);

/* Add to the list of led triggers */
down_write(&triggers_list_lock);
/* Make sure the trigger's name isn't already in use */
list_for_each_entry(trig, &trigger_list, next_trig) {
if (!strcmp(trig->name, trigger->name)) {
up_write(&triggers_list_lock);
return -EEXIST;
}
}
/* Add to the list of led triggers */
list_add_tail(&trigger->next_trig, &trigger_list);
up_write(&triggers_list_lock);

Expand Down

0 comments on commit 700c6ea

Please sign in to comment.