Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi Use ratecheck() to prevent envstat(1) doing man...



details:   https://anonhg.NetBSD.org/src/rev/6cbfc692ec34
branches:  trunk
changeset: 554629:6cbfc692ec34
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Thu Oct 30 22:12:02 2003 +0000

description:
Use ratecheck() to prevent envstat(1) doing many ACPI calls at once.  Now my
MP3 player doesn't skip...

diffstat:

 sys/dev/acpi/acpi_bat.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (47 lines):

diff -r ab45d045c858 -r 6cbfc692ec34 sys/dev/acpi/acpi_bat.c
--- a/sys/dev/acpi/acpi_bat.c   Thu Oct 30 22:04:39 2003 +0000
+++ b/sys/dev/acpi/acpi_bat.c   Thu Oct 30 22:12:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_bat.c,v 1.22 2003/08/31 01:36:12 gson Exp $       */
+/*     $NetBSD: acpi_bat.c,v 1.23 2003/10/30 22:12:02 mycroft Exp $    */
 
 /*
  * Copyright 2001 Bill Sommerfeld.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.22 2003/08/31 01:36:12 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.23 2003/10/30 22:12:02 mycroft Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -102,6 +102,8 @@
        struct envsys_tre_data sc_data[ACPIBAT_NSENSORS];
 
        struct simplelock sc_lock;
+
+       struct timeval sc_lastupdate, sc_updateinterval;
 };
 
 /*
@@ -702,6 +704,9 @@
        sc->sc_sysmon.sme_nsensors = ACPIBAT_NSENSORS;
        sc->sc_sysmon.sme_envsys_version = 1000;
 
+       sc->sc_updateinterval.tv_sec = 1;
+       sc->sc_updateinterval.tv_usec = 0;
+
        if (sysmon_envsys_register(&sc->sc_sysmon))
                printf("%s: unable to register with sysmon\n",
                    sc->sc_dev.dv_xname);
@@ -712,7 +717,8 @@
 {
        struct acpibat_softc *sc = sme->sme_cookie;
 
-       acpibat_update(sc);
+       if (ratecheck(&sc->sc_lastupdate, &sc->sc_updateinterval))
+               acpibat_update(sc);
 
        /* XXX locking */
        /* XXX it should be checked whether info/stat is valid. */



Home | Main Index | Thread Index | Old Index