diff options
| -rw-r--r-- | drivers/leds/ledtrig-heartbeat.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c index 1aacf4c6c3e4..41dc76db4311 100644 --- a/drivers/leds/ledtrig-heartbeat.c +++ b/drivers/leds/ledtrig-heartbeat.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/timer.h> | 18 | #include <linux/timer.h> |
| 19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
| 20 | #include <linux/leds.h> | 20 | #include <linux/leds.h> |
| 21 | #include <linux/reboot.h> | ||
| 21 | #include "leds.h" | 22 | #include "leds.h" |
| 22 | 23 | ||
| 23 | struct heartbeat_trig_data { | 24 | struct heartbeat_trig_data { |
| @@ -103,13 +104,38 @@ static struct led_trigger heartbeat_led_trigger = { | |||
| 103 | .deactivate = heartbeat_trig_deactivate, | 104 | .deactivate = heartbeat_trig_deactivate, |
| 104 | }; | 105 | }; |
| 105 | 106 | ||
| 107 | static int heartbeat_reboot_notifier(struct notifier_block *nb, | ||
| 108 | unsigned long code, void *unused) | ||
| 109 | { | ||
| 110 | led_trigger_unregister(&heartbeat_led_trigger); | ||
| 111 | return NOTIFY_DONE; | ||
| 112 | } | ||
| 113 | |||
| 114 | static struct notifier_block heartbeat_reboot_nb = { | ||
| 115 | .notifier_call = heartbeat_reboot_notifier, | ||
| 116 | }; | ||
| 117 | |||
| 118 | static struct notifier_block heartbeat_panic_nb = { | ||
| 119 | .notifier_call = heartbeat_reboot_notifier, | ||
| 120 | }; | ||
| 121 | |||
| 106 | static int __init heartbeat_trig_init(void) | 122 | static int __init heartbeat_trig_init(void) |
| 107 | { | 123 | { |
| 108 | return led_trigger_register(&heartbeat_led_trigger); | 124 | int rc = led_trigger_register(&heartbeat_led_trigger); |
| 125 | |||
| 126 | if (!rc) { | ||
| 127 | atomic_notifier_chain_register(&panic_notifier_list, | ||
| 128 | &heartbeat_panic_nb); | ||
| 129 | register_reboot_notifier(&heartbeat_reboot_nb); | ||
| 130 | } | ||
| 131 | return rc; | ||
| 109 | } | 132 | } |
| 110 | 133 | ||
| 111 | static void __exit heartbeat_trig_exit(void) | 134 | static void __exit heartbeat_trig_exit(void) |
| 112 | { | 135 | { |
| 136 | unregister_reboot_notifier(&heartbeat_reboot_nb); | ||
| 137 | atomic_notifier_chain_unregister(&panic_notifier_list, | ||
| 138 | &heartbeat_panic_nb); | ||
| 113 | led_trigger_unregister(&heartbeat_led_trigger); | 139 | led_trigger_unregister(&heartbeat_led_trigger); |
| 114 | } | 140 | } |
| 115 | 141 | ||
