[parisc-linux-cvs] 2.5.70-pa7: chassis SCSI-LED fixes for 2.5

Helge Deller deller@gmx.de
Tue, 3 Jun 2003 00:08:44 +0200


--Boundary-00=_sr82+afMqT/8ZFm
Content-Type: text/plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Dienstag, 3. Juni 2003 00:05, Helge Deller wrote:
> CVSROOT:	/var/cvs
> Module name:	linux-2.5
> Changes by:	deller	03/06/02 16:05:35
>
> Modified files:
> 	.              : Makefile
> 	drivers/parisc : led.c
>
> Log message:
> 2.5.70-pa7:
> - the front SCSI-LED now works again in 2.5 for SCSI HDD activity


--Boundary-00=_sr82+afMqT/8ZFm
Content-Type: text/plain;
  charset="iso-8859-15";
  name="diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="diff"

Index: Makefile
===================================================================
RCS file: /var/cvs/linux-2.5/Makefile,v
retrieving revision 1.119
diff -u -p -r1.119 Makefile
--- Makefile	1 Jun 2003 12:26:17 -0000	1.119
+++ Makefile	2 Jun 2003 22:04:08 -0000
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 70
-EXTRAVERSION = -pa6
+EXTRAVERSION = -pa7
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
Index: drivers/parisc/led.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/parisc/led.c,v
retrieving revision 1.8
diff -u -p -r1.8 led.c
--- drivers/parisc/led.c	27 May 2003 17:24:59 -0000	1.8
+++ drivers/parisc/led.c	2 Jun 2003 22:04:08 -0000
@@ -3,7 +3,7 @@
  *
  *      (c) Copyright 2000 Red Hat Software
  *      (c) Copyright 2000 Helge Deller <hdeller@redhat.com>
- *      (c) Copyright 2001-2002 Helge Deller <deller@gmx.de>
+ *      (c) Copyright 2001-2003 Helge Deller <deller@gmx.de>
  *      (c) Copyright 2001 Randolph Chung <tausq@debian.org>
  *
  *      This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
  *
  * TODO:
  *	- speed-up calculations with inlined assembler
- *	- interface to write to second row of LCD from /proc
+ *	- interface to write to second row of LCD from /proc (if technically possible)
  */
 
 #include <linux/config.h>
@@ -392,42 +392,26 @@ static void led_get_net_stats(int addval
    ** 
    ** led_get_diskio_stats()
    ** 
-   ** calculate the disk-io througput in the system
-   ** (analog to linux/fs/proc/proc_misc.c)
+   ** calculate if there was disk-io in the system
    **   
  */
-static unsigned long led_diskio_counter;
-
-static void led_get_diskio_stats(int addvalue)
+static int led_get_diskio_stats(void)
 {	
-	static unsigned int diskio_total_last, diskio_max;
-	int major, disk, total;
-	
-	total = 0;
-#if 0
-	/*
-	 * this section will no longer work in 2.5, as we no longer
-	 * have either kstat.dk_drive nor DK_MAX_*.  It can probably
-	 * be rewritten to use the per-disk statistics now kept in the
-	 * gendisk, but since I have no HP machines to test it on, I'm
-	 * not really up to that.  ricklind@us.ibm.com 11/7/02
-	 */
-	for (major = 0; major < DK_MAX_MAJOR; major++) {
-	    for (disk = 0; disk < DK_MAX_DISK; disk++)
-		total += dkstat.drive[major][disk];
-	}
-	total -= diskio_total_last;
+	unsigned int total;
+
+	struct page_state pgstat;
+	static unsigned long last_pgpgin, last_pgpgout;
 	
-	if (total) {
-	    if (total >= diskio_max) {
-		led_diskio_counter += addvalue;
-	        diskio_max = total; /* new maximum value found */ 
-	    } else
-		led_diskio_counter += CALC_ADD(total, diskio_max, addvalue);
-	}
-#endif
+	get_full_page_state(&pgstat); /* get no of sectors in & out */
+
+	/* Just use a very simple calculation here. Do not care about overflow,
+	   since we only want to know if there was activity or not. */
+	#define  DIFF_AND_SAVE(new,saved) (new-saved);  saved = new;
+	total  = DIFF_AND_SAVE(pgstat.pgpgin,  last_pgpgin);
+	total += DIFF_AND_SAVE(pgstat.pgpgout, last_pgpgout);
+        #undef   DIFF_AND_SAVE
 	
-	diskio_total_last += total; 
+	return total;
 }
 
 
@@ -497,14 +481,14 @@ static void led_tasklet_func(unsigned lo
 
 	if (led_diskio)
 	{
+		static int last_diskio_found;
+
 		/* avoid to calculate diskio-stats at same irq as netio-stats ! */
-		if ((count & 31) == 15) 
-			led_get_diskio_stats(30);
+		if ((count & 7) == 7) 
+			last_diskio_found = led_get_diskio_stats();
 
-		if (led_diskio_counter) {
-			led_diskio_counter--;
+		if (last_diskio_found)
 			currentleds |= LED_DISK_IO;
-		}
 		else    
 			currentleds &= ~LED_DISK_IO;
 	}

--Boundary-00=_sr82+afMqT/8ZFm--