Subject: port-i386/7718: changed logging behaviour of sys/arch/i386/i386/apm.c
To: None <gnats-bugs@gnats.netbsd.org>
From: Benjamin Lorenz <lorenz@inetmail.de>
List: netbsd-bugs
Date: 06/06/1999 04:45:50
>Number:         7718
>Category:       port-i386
>Synopsis:       changed logging behaviour of sys/arch/i386/i386/apm.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-i386-maintainer (NetBSD/i386 Portmaster)
>State:          open
>Class:          support
>Submitter-Id:   net
>Arrival-Date:   Sun Jun  6 04:20:01 1999
>Last-Modified:
>Originator:     Benjamin Lorenz
>Organization:
>Release:        1.4
>Environment:
System: NetBSD suag 1.4 NetBSD 1.4 (SUAG) #0: Sun Jun 6 00:59:33 CEST 1999 lorenz@suag:/var/src/sys/arch/i386/compile/SUAG i386


>Description:
	As in the diffs for the apm userland programs I mailed yesterday,
	I also changed the logging behaviour in the kernel itself, to
	make it a bit less noisy and more compact.
	You get only informed about the current battery power when
	there was a change of more than 17%.

	IMHO all the other values beside battery power (AC state, etc.)
	aren't really interesting, are they?
>How-To-Repeat:
>Fix:

--- apm.c.orig	Fri Jan 22 13:11:17 1999
+++ apm.c	Wed Mar 31 23:55:55 1999
@@ -265,11 +265,19 @@ apm_power_print(sc, regs)
 	struct apm_softc *sc;
 	struct bioscallregs *regs;
 {
+	static int last_battery_life_expectancy = 0;
 
 	if (APM_BATT_LIFE(regs) != APM_BATT_LIFE_UNKNOWN) {
-		printf("%s: battery life expectancy: %d%%\n",
-		    sc->sc_dev.dv_xname, APM_BATT_LIFE(regs));
+		if (abs(APM_BATT_LIFE(regs) -
+		    last_battery_life_expectancy) < 17) {
+			return;
+		}
+		printf("%s: battery life expectancy: %d%% (was %d%%)\n",
+		    sc->sc_dev.dv_xname, APM_BATT_LIFE(regs),
+		    last_battery_life_expectancy);
+		last_battery_life_expectancy = APM_BATT_LIFE(regs);
 	}
+#if 0
 	printf("%s: A/C state: ", sc->sc_dev.dv_xname);
 	switch (APM_AC_STATE(regs)) {
 	case APM_AC_OFF:
@@ -329,6 +337,7 @@ apm_power_print(sc, regs)
 			printf("%dm\n", APM_BATT_REMAINING(regs) % 60);
 		}
 	}
+#endif
 	return;
 }
 
>Audit-Trail:
>Unformatted: