]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
leds: Ensure led->trigger is set earlier
authorDmitry Baryshkov <dbaryshkov@gmail.com>
Wed, 16 Jul 2008 21:51:14 +0000 (22:51 +0100)
committerRichard Purdie <rpurdie@rpsys.net>
Wed, 23 Jul 2008 08:49:56 +0000 (09:49 +0100)
Make sure led->trigger is valid before calling trigger->activate

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
drivers/leds/led-triggers.c

index 0f242b3f09b6b7018354952e7a01bae8b37d6071..f910eaffe3a6f057cd835412204c304f1bd0af38 100644 (file)
@@ -111,16 +111,17 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
                        flags);
                if (led_cdev->trigger->deactivate)
                        led_cdev->trigger->deactivate(led_cdev);
                        flags);
                if (led_cdev->trigger->deactivate)
                        led_cdev->trigger->deactivate(led_cdev);
+               led_cdev->trigger = NULL;
                led_set_brightness(led_cdev, LED_OFF);
        }
        if (trigger) {
                write_lock_irqsave(&trigger->leddev_list_lock, flags);
                list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs);
                write_unlock_irqrestore(&trigger->leddev_list_lock, flags);
                led_set_brightness(led_cdev, LED_OFF);
        }
        if (trigger) {
                write_lock_irqsave(&trigger->leddev_list_lock, flags);
                list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs);
                write_unlock_irqrestore(&trigger->leddev_list_lock, flags);
+               led_cdev->trigger = trigger;
                if (trigger->activate)
                        trigger->activate(led_cdev);
        }
                if (trigger->activate)
                        trigger->activate(led_cdev);
        }
-       led_cdev->trigger = trigger;
 }
 EXPORT_SYMBOL_GPL(led_trigger_set);
 
 }
 EXPORT_SYMBOL_GPL(led_trigger_set);