From 80bf67513f7be1aec9cd1c7eb34a33ea962e37f6 Mon Sep 17 00:00:00 2001 From: njl Date: Mon, 20 Dec 2004 05:03:41 +0000 Subject: Only report a critical battery level once until it's gone non-critical. An improvement would be to check all batteries for critical state before printing a message. Reported by: Kevin Oberman (oberman at es net) --- sys/dev/acpica/acpi_cmbat.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c index f48fdc6..54e4982 100644 --- a/sys/dev/acpica/acpi_cmbat.c +++ b/sys/dev/acpica/acpi_cmbat.c @@ -66,6 +66,7 @@ struct acpi_cmbat_softc { struct timespec bif_lastupdated; struct timespec bst_lastupdated; + int flags; int present; int cap; int min; @@ -189,9 +190,14 @@ acpi_cmbat_get_bst(void *context) goto end; acpi_cmbat_info_updated(&sc->bst_lastupdated); - /* XXX Should we shut down here? */ - if (sc->bst.state & ACPI_BATT_STAT_CRITICAL) - device_printf(dev, "critically low charge!\n"); + /* XXX If all batteries are critical, perhaps we should suspend. */ + if (sc->bst.state & ACPI_BATT_STAT_CRITICAL) { + if ((sc->flags & ACPI_BATT_STAT_CRITICAL) == 0) { + sc->flags |= ACPI_BATT_STAT_CRITICAL; + device_printf(dev, "critically low charge!\n"); + } + } else + sc->flags &= ~ACPI_BATT_STAT_CRITICAL; end: if (bst_buffer.Pointer != NULL) -- cgit v1.1