Commit fe3025b5 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Richard Purdie

leds: Ensure led->trigger is set earlier

Make sure led->trigger is valid before calling trigger->activate
Signed-off-by: default avatarDmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarRichard Purdie <rpurdie@rpsys.net>
parent f46e9203
...@@ -111,16 +111,17 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger) ...@@ -111,16 +111,17 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
flags); flags);
if (led_cdev->trigger->deactivate) if (led_cdev->trigger->deactivate)
led_cdev->trigger->deactivate(led_cdev); led_cdev->trigger->deactivate(led_cdev);
led_cdev->trigger = NULL;
led_set_brightness(led_cdev, LED_OFF); led_set_brightness(led_cdev, LED_OFF);
} }
if (trigger) { if (trigger) {
write_lock_irqsave(&trigger->leddev_list_lock, flags); write_lock_irqsave(&trigger->leddev_list_lock, flags);
list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs); list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs);
write_unlock_irqrestore(&trigger->leddev_list_lock, flags); write_unlock_irqrestore(&trigger->leddev_list_lock, flags);
led_cdev->trigger = trigger;
if (trigger->activate) if (trigger->activate)
trigger->activate(led_cdev); trigger->activate(led_cdev);
} }
led_cdev->trigger = trigger;
} }
EXPORT_SYMBOL_GPL(led_trigger_set); EXPORT_SYMBOL_GPL(led_trigger_set);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment