From: Alexander Holler Date: Wed, 25 Apr 2012 01:04:32 +0000 (+1000) Subject: leds: heartbeat: stop on shutdown X-Git-Tag: next-20120430~2^2~68 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=4aa3c88c920afb6783a72f538cdfe71a4814547b;p=karo-tx-linux.git leds: heartbeat: stop on shutdown A halted kernel should not show a heartbeat. Signed-off-by: Alexander Holler Cc: Shuah Khan Cc: Richard Purdie Signed-off-by: Andrew Morton --- diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c index 1aacf4c6c3e4..8ec5fecf577f 100644 --- a/drivers/leds/ledtrig-heartbeat.c +++ b/drivers/leds/ledtrig-heartbeat.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "leds.h" struct heartbeat_trig_data { @@ -103,13 +104,28 @@ static struct led_trigger heartbeat_led_trigger = { .deactivate = heartbeat_trig_deactivate, }; +static int heartbeat_reboot_notifier(struct notifier_block *nb, + unsigned long code, void *unused) +{ + led_trigger_unregister(&heartbeat_led_trigger); + return NOTIFY_DONE; +} + +static struct notifier_block heartbeat_reboot_nb = { + .notifier_call = heartbeat_reboot_notifier, +}; + static int __init heartbeat_trig_init(void) { - return led_trigger_register(&heartbeat_led_trigger); + int rc = led_trigger_register(&heartbeat_led_trigger); + if( ! rc ) + register_reboot_notifier(&heartbeat_reboot_nb); + return rc; } static void __exit heartbeat_trig_exit(void) { + unregister_reboot_notifier(&heartbeat_reboot_nb); led_trigger_unregister(&heartbeat_led_trigger); }