File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 18
18
#include <linux/timer.h>
19
19
#include <linux/sched.h>
20
20
#include <linux/leds.h>
21
+ #include <linux/reboot.h>
21
22
#include "leds.h"
22
23
23
24
struct heartbeat_trig_data {
@@ -103,13 +104,38 @@ static struct led_trigger heartbeat_led_trigger = {
103
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
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
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
139
led_trigger_unregister (& heartbeat_led_trigger );
114
140
}
115
141
You can’t perform that action at this time.
0 commit comments