linux-mainline 3.2: shut down heartbeat LED on halt/reboot/panic
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-mainline-3.2 / led / 0001-leds-heartbeat-stop-on-shutdown-reboot-or-panic.patch
1 From d4369481800faa1ab93ab10c23626a5ce5fad5b5 Mon Sep 17 00:00:00 2001
2 From: Alexander Holler <hol...@ahsoftware.de>
3 Date: Wed, 25 Apr 2012 00:50:03 +0200
4 Subject: [PATCH] leds: heartbeat: stop on shutdown, reboot or panic
6 A halted kernel should not show a heartbeat.
8 Signed-off-by: Alexander Holler <hol...@ahsoftware.de>
9 Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
10 ---
11  drivers/leds/ledtrig-heartbeat.c |   27 ++++++++++++++++++++++++++-
12  1 files changed, 26 insertions(+), 1 deletions(-)
14 diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c
15 index 759c0bb..31c234c 100644
16 --- a/drivers/leds/ledtrig-heartbeat.c
17 +++ b/drivers/leds/ledtrig-heartbeat.c
18 @@ -18,6 +18,7 @@
19  #include <linux/timer.h>
20  #include <linux/sched.h>
21  #include <linux/leds.h>
22 +#include <linux/reboot.h>
23  #include "leds.h"
24  
25  struct heartbeat_trig_data {
26 @@ -101,13 +102,37 @@ static struct led_trigger heartbeat_led_trigger = {
27         .deactivate = heartbeat_trig_deactivate,
28  };
29  
30 +static int heartbeat_reboot_notifier(struct notifier_block *nb,
31 +                                    unsigned long code, void *unused)
32 +{
33 +       led_trigger_unregister(&heartbeat_led_trigger);
34 +       return NOTIFY_DONE;
35 +}
36 +
37 +static struct notifier_block heartbeat_reboot_nb = {
38 +       .notifier_call = heartbeat_reboot_notifier,
39 +};
40 +
41 +static struct notifier_block heartbeat_panic_nb = {
42 +       .notifier_call = heartbeat_reboot_notifier,
43 +};
44 +
45  static int __init heartbeat_trig_init(void)
46  {
47 -       return led_trigger_register(&heartbeat_led_trigger);
48 +       int rc = led_trigger_register(&heartbeat_led_trigger);
49 +       if (!rc) {
50 +               atomic_notifier_chain_register(&panic_notifier_list,
51 +                                              &heartbeat_panic_nb);
52 +               register_reboot_notifier(&heartbeat_reboot_nb);
53 +       }
54 +       return rc;
55  }
56  
57  static void __exit heartbeat_trig_exit(void)
58  {
59 +       unregister_reboot_notifier(&heartbeat_reboot_nb);
60 +       atomic_notifier_chain_unregister(&panic_notifier_list,
61 +                                        &heartbeat_panic_nb);
62         led_trigger_unregister(&heartbeat_led_trigger);
63  }
64  
65 -- 
66 1.7.7.4