aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel@vanguardiasur.com.ar>2016-03-29 16:35:47 -0400
committerJacek Anaszewski <j.anaszewski@samsung.com>2016-03-30 05:16:39 -0400
commit916fe619951f41b55d4f2b9f26d64ad981bc0dfa (patch)
treef2adcab47354d000d4851274caf136ad98851830
parentf55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff)
leds: trigger: Introduce a kernel panic LED trigger
This commit introduces a new LED trigger which allows to configure a LED to blink on a kernel panic (through panic_blink). Notice that currently the Openmoko FreeRunner (GTA02) mach code sets panic_blink to blink a hard-coded LED. The new trigger is meant to introduce a generic mechanism to achieve this. Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
-rw-r--r--drivers/leds/trigger/Kconfig7
-rw-r--r--drivers/leds/trigger/Makefile1
-rw-r--r--drivers/leds/trigger/ledtrig-panic.c30
3 files changed, 38 insertions, 0 deletions
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
index 5bda6a9b56bb..554f5bfbeced 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -108,4 +108,11 @@ config LEDS_TRIGGER_CAMERA
108 This enables direct flash/torch on/off by the driver, kernel space. 108 This enables direct flash/torch on/off by the driver, kernel space.
109 If unsure, say Y. 109 If unsure, say Y.
110 110
111config LEDS_TRIGGER_PANIC
112 bool "LED Panic Trigger"
113 depends on LEDS_TRIGGERS
114 help
115 This allows LEDs to be configured to blink on a kernel panic.
116 If unsure, say Y.
117
111endif # LEDS_TRIGGERS 118endif # LEDS_TRIGGERS
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
index 1abf48dacf7e..547bf5c80e52 100644
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtrig-cpu.o
8obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o 8obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
9obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o 9obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
10obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o 10obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
11obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o
diff --git a/drivers/leds/trigger/ledtrig-panic.c b/drivers/leds/trigger/ledtrig-panic.c
new file mode 100644
index 000000000000..627b350c5ec3
--- /dev/null
+++ b/drivers/leds/trigger/ledtrig-panic.c
@@ -0,0 +1,30 @@
1/*
2 * Kernel Panic LED Trigger
3 *
4 * Copyright 2016 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/leds.h>
15
16static struct led_trigger *trigger;
17
18static long led_panic_blink(int state)
19{
20 led_trigger_event(trigger, state ? LED_FULL : LED_OFF);
21 return 0;
22}
23
24static int __init ledtrig_panic_init(void)
25{
26 led_trigger_register_simple("panic", &trigger);
27 panic_blink = led_panic_blink;
28 return 0;
29}
30device_initcall(ledtrig_panic_init);