Skip to contentSkip to conversation

Add keyboard blink driver

PATCH In review Andi Kleen 3 participants 5 messages Apr 12, 2007 – Apr 18, 2007 Char and misc drivers

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Add keyboard blink driver

Add a blink driver for debugging

Simple driver that blinks the keyboard LEDs when loaded. Useful for checking that the kernel is still alive or for crashdumping. The kdump kernel currently typically doesn't give any feedback on the screen because it often cannot reinitialize the graphics state. This patch allows it to at least show blinking lights like panic.

---
 drivers/misc/Kconfig  |    9 +++++++++
 drivers/misc/Makefile |    1 +
 drivers/misc/blink.c  |   26 ++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
drivers/misc/Kconfig +9 -0
Index: linux/drivers/misc/Kconfig
===================================================================
@@ -107,4 +107,13 @@ config MSI_LAPTOP
 
 	  If you have an MSI S270 laptop, say Y or M here.
 
+config BLINK
+	tristate "Keyboard blink driver"
+	help
+	  Driver that when loaded will blink the keyboard LEDs continuously.
+	  This is useful for debugging and for kernels that cannot necessarily
+	  output something to the screen like kexec kernels to give the user
+	  a visual indication that the kernel is doing something.
+
+
 endmenu
drivers/misc/Makefile +1 -0
Index: linux/drivers/misc/Makefile
===================================================================
@@ -11,3 +11,4 @@ obj-$(CONFIG_LKDTM)		+= lkdtm.o
 obj-$(CONFIG_TIFM_CORE)       	+= tifm_core.o
 obj-$(CONFIG_TIFM_7XX1)       	+= tifm_7xx1.o
 obj-$(CONFIG_SGI_IOC4)		+= ioc4.o
+obj-$(CONFIG_BLINK)		+= blink.o
drivers/misc/blink.c new file +26 -0
Index: linux/drivers/misc/blink.c
===================================================================
@@ -0,0 +1,26 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+
+static void do_blink(unsigned long data);
+
+static DEFINE_TIMER(blink_timer, do_blink, 0 ,0);
+
+static void do_blink(unsigned long data)
+{
+	static long count;
+	panic_blink(count++);
+	blink_timer.expires = jiffies + msecs_to_jiffies(1);
+	add_timer(&blink_timer);
+}
+
+static int blink_init(void)
+{
+	printk(KERN_INFO "Enabling keyboard blinking\n");
+	do_blink(0);
+	return 0;
+}
+
+module_init(blink_init);
+
#1 lore raw
Quoted 8 lines · On Thu, 12 Apr 2007 17:27:27 +0200 Andi Kleen <[email protected]> wrote:

Add a blink driver for debugging

Simple driver that blinks the keyboard LEDs when loaded. Useful for checking that the kernel is still alive or for crashdumping. The kdump kernel currently typically doesn't give any feedback on the screen because it often cannot reinitialize the graphics state. This patch allows it to at least show blinking lights like panic.

OK..

Quoted 18 lines
drivers/misc/blink.c new file +15 -0
@@ -0,0 +1,26 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+
+static void do_blink(unsigned long data);
+
+static DEFINE_TIMER(blink_timer, do_blink, 0 ,0);
+
+static void do_blink(unsigned long data)
+{
+	static long count;
+	panic_blink(count++);
+	blink_timer.expires = jiffies + msecs_to_jiffies(1);
+	add_timer(&blink_timer);

drivers/misc/blink.c line 25

Quoted 10 lines
drivers/misc/blink.c new file +10 -0
+}
+
+static int blink_init(void)
+{
+	printk(KERN_INFO "Enabling keyboard blinking\n");
+	do_blink(0);
+	return 0;
+}
+
+module_init(blink_init);

panic_blink is NULL in lots of setups. `modprobe blink' will be deadly.

I wonder if this facility would be more effective if it were to use schedule_delayed_work(). That way, we're using more of the kernel and it will more reliably detect kernel deadness.

author
#2 lore raw
Quoted 36 lines · On Thursday 12 April 2007 21:10:28 Andrew Morton wrote:
Quoted 8 lines · On Thu, 12 Apr 2007 17:27:27 +0200 Andi Kleen <[email protected]> wrote:

Add a blink driver for debugging

Simple driver that blinks the keyboard LEDs when loaded. Useful for checking that the kernel is still alive or for crashdumping. The kdump kernel currently typically doesn't give any feedback on the screen because it often cannot reinitialize the graphics state. This patch allows it to at least show blinking lights like panic.

OK..

Quoted 22 lines
drivers/misc/blink.c new file +19 -0
@@ -0,0 +1,26 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+
+static void do_blink(unsigned long data);
+
+static DEFINE_TIMER(blink_timer, do_blink, 0 ,0);
+
+static void do_blink(unsigned long data)
+{
+	static long count;
+	panic_blink(count++);
+	blink_timer.expires = jiffies + msecs_to_jiffies(1);
+	add_timer(&blink_timer);
+}
+
+static int blink_init(void)
+{
Quoted 8 lines

drivers/misc/blink.c line 25

Quoted 6 lines
drivers/misc/blink.c new file +6 -0
+	printk(KERN_INFO "Enabling keyboard blinking\n");
+	do_blink(0);
+	return 0;
+}
+
+module_init(blink_init);

panic_blink is NULL in lots of setups. `modprobe blink' will be deadly.

Oops sorry -- i must somehow have sent an old patch. I had fixed this of course Ahh, quilt refresh was missing.

See the new patch.

Quoted 3 lines

I wonder if this facility would be more effective if it were to use schedule_delayed_work(). That way, we're using more of the kernel and it will more reliably detect kernel deadness.

Hmm, maybe

-Andi

Add a blink driver for debugging

Simple driver that blinks the keyboard LEDs when loaded. Useful for checking that the kernel is still alive or for crashdumping

---
 drivers/misc/Kconfig  |    9 +++++++++
 drivers/misc/Makefile |    1 +
 drivers/misc/blink.c  |   26 ++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
drivers/misc/Kconfig +9 -0
Index: linux-2.6.21-rc6-test/drivers/misc/Kconfig
===================================================================
@@ -122,4 +122,13 @@ config SONY_LAPTOP
 
 	  Read <file:Documentation/sony-laptop.txt> for more information.
 
+config BLINK
+	tristate "Keyboard blink driver"
+	help
+	  Driver that when loaded will blink the keyboard LEDs continuously.
+	  This is useful for debugging and for kernels that cannot necessarily
+	  output something to the screen like kexec kernels to give the user
+	  a visual indication that the kernel is doing something.
+
+
 endmenu
drivers/misc/Makefile +1 -0
Index: linux-2.6.21-rc6-test/drivers/misc/Makefile
===================================================================
@@ -12,3 +12,4 @@ obj-$(CONFIG_TIFM_CORE)       	+= tifm_c
 obj-$(CONFIG_TIFM_7XX1)       	+= tifm_7xx1.o
 obj-$(CONFIG_SGI_IOC4)		+= ioc4.o
 obj-$(CONFIG_SONY_LAPTOP)	+= sony-laptop.o
+obj-$(CONFIG_BLINK)		+= blink.o
drivers/misc/blink.c new file +27 -0
Index: linux-2.6.21-rc6-test/drivers/misc/blink.c
===================================================================
@@ -0,0 +1,27 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+
+static void do_blink(unsigned long data);
+
+static DEFINE_TIMER(blink_timer, do_blink, 0 ,0);
+
+static void do_blink(unsigned long data)
+{
+	static long count;
+	if (panic_blink)
+		panic_blink(count++);
+	blink_timer.expires = jiffies + msecs_to_jiffies(1);
+	add_timer(&blink_timer);
+}
+
+static int blink_init(void)
+{
+	printk(KERN_INFO "Enabling keyboard blinking\n");
+	do_blink(0);
+	return 0;
+}
+
+module_init(blink_init);
+
#3 lore raw
Quoted 5 lines · On Thu, 12 Apr 2007 21:28:08 +0200 Andi Kleen <[email protected]> wrote:
Quoted 3 lines

I wonder if this facility would be more effective if it were to use schedule_delayed_work(). That way, we're using more of the kernel and it will more reliably detect kernel deadness.

Hmm, maybe

??

Quoted 5 lines
drivers/misc/blink.c new file +5 -0
+static void do_blink(unsigned long data)
+{
+	static long count;
+	if (panic_blink)
+		panic_blink(count++);

drivers/misc/blink.c line 24

Quoted 10 lines
drivers/misc/blink.c new file +10 -0
+	blink_timer.expires = jiffies + msecs_to_jiffies(1);
+	add_timer(&blink_timer);
+}
+
+static int blink_init(void)
+{
+	printk(KERN_INFO "Enabling keyboard blinking\n");
+	do_blink(0);
+	return 0;
+}

Would it be better to just not start the timer at all if panic_blink==0? That would improve life rather a lot for people who link this into vmlinux but don't have i8042.

#4 lore raw
In reply to Andi Kleen

Hi!

Quoted 4 lines

Add a blink driver for debugging

Simple driver that blinks the keyboard LEDs when loaded. Useful for checking that the kernel is still alive or for crashdumping.

For checking if kernel is alive/crashdumping... can user just do setleds +caps; sleep 1; setleds -caps; ... ? You can even have morse code :-).

Besides, we now have led support framework in kernel, that can do blinking by itself etc.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html