diff options
author | Alexander Holler <holler@ahsoftware.de> | 2012-05-29 18:07:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:32 -0400 |
commit | 49dca5aebfdeadd4bf27b6cb4c60392147dc35a4 (patch) | |
tree | 99172a77186076842dce396469ea9d50f4d16c9f /drivers/leds | |
parent | 6335f8fa974bc284da0f55877935538e1d7b55eb (diff) |
leds: heartbeat: stop on shutdown
A halted kernel should not show a heartbeat.
[akpm@linux-foundation.org: checkpatch fixes]
Signed-off-by: Alexander Holler <holler@ahsoftware.de>
Cc: Shuah Khan <shuahkhan@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Bryan Wu <bryan.wu@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds')
-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 | ||