summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAdam Nielsen <a.nielsen@shikadi.net>2009-02-18 08:18:04 +1000
committerRichard Purdie <rpurdie@linux.intel.com>2009-04-06 16:06:26 +0100
commit700c6ea2242cf04ba3612fa7cf74763fffcc04fd (patch)
treeb002d5cb630d49bf374dcdfee304c2b87b59c646 /drivers
parent17354bfe85275f1bdde7f4a27ebc1ba53e053939 (diff)
downloadop-kernel-dev-700c6ea2242cf04ba3612fa7cf74763fffcc04fd.zip
op-kernel-dev-700c6ea2242cf04ba3612fa7cf74763fffcc04fd.tar.gz
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')
-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 f910eaf..d8ddd9e 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -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);
OpenPOWER on IntegriCloud