14 #include <linux/module.h>
15 #include <linux/kernel.h>
17 #include <linux/slab.h>
19 #include <linux/sched.h>
21 #include <linux/reboot.h>
24 static int panic_heartbeats;
32 static void led_heartbeat_function(
unsigned long data)
37 unsigned long delay = 0;
45 switch (heartbeat_data->
phase) {
53 heartbeat_data->
period = 300 +
58 heartbeat_data->
phase++;
63 heartbeat_data->
phase++;
67 heartbeat_data->
phase++;
71 delay = heartbeat_data->
period - heartbeat_data->
period / 4 -
73 heartbeat_data->
phase = 0;
77 __led_set_brightness(led_cdev, brightness);
81 static void heartbeat_trig_activate(
struct led_classdev *led_cdev)
85 heartbeat_data = kzalloc(
sizeof(*heartbeat_data),
GFP_KERNEL);
89 led_cdev->trigger_data = heartbeat_data;
91 led_heartbeat_function, (
unsigned long) led_cdev);
92 heartbeat_data->
phase = 0;
93 led_heartbeat_function(heartbeat_data->
timer.data);
94 led_cdev->activated =
true;
97 static void heartbeat_trig_deactivate(
struct led_classdev *led_cdev)
101 if (led_cdev->activated) {
103 kfree(heartbeat_data);
104 led_cdev->activated =
false;
108 static struct led_trigger heartbeat_led_trigger = {
110 .activate = heartbeat_trig_activate,
111 .deactivate = heartbeat_trig_deactivate,
124 panic_heartbeats = 1;
129 .notifier_call = heartbeat_reboot_notifier,
133 .notifier_call = heartbeat_panic_notifier,
136 static int __init heartbeat_trig_init(
void)
142 &heartbeat_panic_nb);
148 static void __exit heartbeat_trig_exit(
void)
152 &heartbeat_panic_nb);