[parisc-linux-cvs] pa50: stop LED/LCD activity at system shutdown

Helge Deller deller@gmx.de
Sat, 30 Jun 2001 00:17:07 +0200


--------------Boundary-00=_JWPPMZXF4SN2BAK3869E
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Subject: 



--------------Boundary-00=_JWPPMZXF4SN2BAK3869E
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="diff"

Index: Makefile
===================================================================
RCS file: /home/cvs/parisc/linux/Makefile,v
retrieving revision 1.81
diff -u -r1.81 Makefile
--- Makefile	2001/06/28 01:50:24	1.81
+++ Makefile	2001/06/29 22:13:12
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 0
-EXTRAVERSION = -pa49
+EXTRAVERSION = -pa50
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
Index: arch/parisc/kernel/led.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/led.c,v
retrieving revision 1.18
diff -u -r1.18 led.c
--- led.c	2001/06/06 19:46:31	1.18
+++ led.c	2001/06/29 22:13:12
@@ -10,15 +10,11 @@
  *      (at your option) any later version.
  *
  * TODO:
- *	- stop all LED activity at kernel shutdown/halt (add to notifier chain)
  *	- LCD functionality is completely untested (lack of hardware :-() 
  *	- add procfs entry to (maybe partially) enable & disable LEDs
  *	- speed-up calculations with inlined assembler
- *	- modularization
  */
 
-#define DEBUG 1	/* undefine for production */
-
 #include <linux/config.h>
 #include <linux/stddef.h>	/* for offsetof() */
 #include <linux/init.h>
@@ -30,6 +26,7 @@
 #include <linux/netdevice.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
+#include <linux/reboot.h>
 #include <asm/io.h>
 #include <asm/gsc.h>
 #include <asm/processor.h>
@@ -47,6 +44,13 @@
 #undef NO_LAN_RXTX
 
 
+#if 0
+#define DPRINTK(x)	printk x
+#else
+#define DPRINTK(x)
+#endif
+
+
 #define CALC_ADD(val, comp, add) \
  (val<=(comp/8) ? add/16 : val<=(comp/4) ? add/8 : val<=(comp/2) ? add/4 : add)
 
@@ -174,7 +178,6 @@
 			value = leds & LED_LAN_TX;
 			break;
 	    default:	/* should never happen: */
-			BUG();
 			return;
 	}
 
@@ -291,6 +294,7 @@
  */
 
 static unsigned char currentleds;	/* stores current value of the LEDs */
+static unsigned char led_stop;		/* stop LED activity at system shutdown */
 
 #define HEARTBEAT_LEN (HZ*6/100)
 #define HEARTBEAT_2ND_RANGE_START (HZ*22/100)
@@ -304,6 +308,16 @@
 	/* exit, if not initialized */
 	if (!led_func_ptr)
 	    return;
+
+	/* if the system shuts down update the LED HZ times and exit */
+	if (led_stop) {
+		if (led_stop > HZ)
+			return;
+		led_stop++;
+		lastleds = 0;
+		currentleds = 0xff;
+		goto update;
+	}
 	
 	/* increment the local counters */
 	++count;
@@ -353,6 +367,7 @@
 	    currentleds &= ~LED_DISK_IO;
 #endif
 
+update:
 	/* update the LCD/LEDs */
 	if (currentleds != lastleds) {
 	    led_func_ptr(currentleds);
@@ -362,6 +377,31 @@
 
 
 /*
+   ** led_halt()
+   ** 
+   ** called by the reboot notifier chain at shutdown and stops all
+   ** LED/LCD activities.
+   ** 
+ */
+
+static int led_halt(struct notifier_block *, unsigned long, void *);
+
+static struct notifier_block led_notifier = {
+	notifier_call: led_halt,
+};
+
+static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) 
+{
+	if ((event != SYS_RESTART) && (event != SYS_HALT) &&
+	    (event != SYS_POWER_OFF))
+		return NOTIFY_DONE;
+	
+	led_stop = 1;
+	unregister_reboot_notifier(&led_notifier);
+	return NOTIFY_OK;
+}
+
+/*
    ** register_led_driver()
    ** 
    ** registers an external LED or LCD for usage by this driver.
@@ -408,6 +448,7 @@
 	}
 	
 	initialized++; /* mark the LCD/LED driver now as initialized */
+	register_reboot_notifier(&led_notifier);
 	
 	return 0;
 }
@@ -508,14 +549,14 @@
 	chassis_info.actcnt = chassis_info.maxcnt = 0;
 
 	if (pdc_chassis_info(&chassis_info, &lcd_info, sizeof(lcd_info)) == PDC_OK) {
-		pr_debug("%s: chassis info: model=%d (%s), "
+		DPRINTK((KERN_INFO "%s: chassis info: model=%d (%s), "
 			 "lcd_width=%d, cmd_delay=%u, "
 			 "sizecnt=%d, actcnt=%ld, maxcnt=%ld\n",
 		         __FUNCTION__, lcd_info.model, 
 			 (lcd_info.model==DISPLAY_MODEL_LCD) ? "LCD" :
 			  (lcd_info.model==DISPLAY_MODEL_LASI) ? "LED" : "unknown",  
 			 lcd_info.lcd_width, lcd_info.min_cmd_delay,
-			 sizeof(lcd_info), chassis_info.actcnt, chassis_info.maxcnt);
+			 sizeof(lcd_info), chassis_info.actcnt, chassis_info.maxcnt));
 
 		/* check the results. Some machines have a buggy PDC */
 		if (chassis_info.actcnt <= 0 || chassis_info.actcnt != chassis_info.maxcnt)

--------------Boundary-00=_JWPPMZXF4SN2BAK3869E--