diff options
Diffstat (limited to 'drivers/leds/trigger/ledtrig-heartbeat.c')
-rw-r--r-- | drivers/leds/trigger/ledtrig-heartbeat.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/leds/trigger/ledtrig-heartbeat.c b/drivers/leds/trigger/ledtrig-heartbeat.c index 410c39c62dc7..c9f386213e9e 100644 --- a/drivers/leds/trigger/ledtrig-heartbeat.c +++ b/drivers/leds/trigger/ledtrig-heartbeat.c | |||
@@ -19,6 +19,7 @@ | |||
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 <linux/reboot.h> |
22 | #include <linux/suspend.h> | ||
22 | #include "../leds.h" | 23 | #include "../leds.h" |
23 | 24 | ||
24 | static int panic_heartbeats; | 25 | static int panic_heartbeats; |
@@ -154,6 +155,30 @@ static struct led_trigger heartbeat_led_trigger = { | |||
154 | .deactivate = heartbeat_trig_deactivate, | 155 | .deactivate = heartbeat_trig_deactivate, |
155 | }; | 156 | }; |
156 | 157 | ||
158 | static int heartbeat_pm_notifier(struct notifier_block *nb, | ||
159 | unsigned long pm_event, void *unused) | ||
160 | { | ||
161 | int rc; | ||
162 | |||
163 | switch (pm_event) { | ||
164 | case PM_SUSPEND_PREPARE: | ||
165 | case PM_HIBERNATION_PREPARE: | ||
166 | case PM_RESTORE_PREPARE: | ||
167 | led_trigger_unregister(&heartbeat_led_trigger); | ||
168 | break; | ||
169 | case PM_POST_SUSPEND: | ||
170 | case PM_POST_HIBERNATION: | ||
171 | case PM_POST_RESTORE: | ||
172 | rc = led_trigger_register(&heartbeat_led_trigger); | ||
173 | if (rc) | ||
174 | pr_err("could not re-register heartbeat trigger\n"); | ||
175 | break; | ||
176 | default: | ||
177 | break; | ||
178 | } | ||
179 | return NOTIFY_DONE; | ||
180 | } | ||
181 | |||
157 | static int heartbeat_reboot_notifier(struct notifier_block *nb, | 182 | static int heartbeat_reboot_notifier(struct notifier_block *nb, |
158 | unsigned long code, void *unused) | 183 | unsigned long code, void *unused) |
159 | { | 184 | { |
@@ -168,6 +193,10 @@ static int heartbeat_panic_notifier(struct notifier_block *nb, | |||
168 | return NOTIFY_DONE; | 193 | return NOTIFY_DONE; |
169 | } | 194 | } |
170 | 195 | ||
196 | static struct notifier_block heartbeat_pm_nb = { | ||
197 | .notifier_call = heartbeat_pm_notifier, | ||
198 | }; | ||
199 | |||
171 | static struct notifier_block heartbeat_reboot_nb = { | 200 | static struct notifier_block heartbeat_reboot_nb = { |
172 | .notifier_call = heartbeat_reboot_notifier, | 201 | .notifier_call = heartbeat_reboot_notifier, |
173 | }; | 202 | }; |
@@ -184,12 +213,14 @@ static int __init heartbeat_trig_init(void) | |||
184 | atomic_notifier_chain_register(&panic_notifier_list, | 213 | atomic_notifier_chain_register(&panic_notifier_list, |
185 | &heartbeat_panic_nb); | 214 | &heartbeat_panic_nb); |
186 | register_reboot_notifier(&heartbeat_reboot_nb); | 215 | register_reboot_notifier(&heartbeat_reboot_nb); |
216 | register_pm_notifier(&heartbeat_pm_nb); | ||
187 | } | 217 | } |
188 | return rc; | 218 | return rc; |
189 | } | 219 | } |
190 | 220 | ||
191 | static void __exit heartbeat_trig_exit(void) | 221 | static void __exit heartbeat_trig_exit(void) |
192 | { | 222 | { |
223 | unregister_pm_notifier(&heartbeat_pm_nb); | ||
193 | unregister_reboot_notifier(&heartbeat_reboot_nb); | 224 | unregister_reboot_notifier(&heartbeat_reboot_nb); |
194 | atomic_notifier_chain_unregister(&panic_notifier_list, | 225 | atomic_notifier_chain_unregister(&panic_notifier_list, |
195 | &heartbeat_panic_nb); | 226 | &heartbeat_panic_nb); |