Module Name:    src
Committed By:   jruoho
Date:           Sun Jan 24 11:32:13 UTC 2010

Modified Files:
        src/sys/dev/acpi: acpi_bat.c

Log Message:
  * Reintroduce a state variable. From nj...@.
  * Always mark the charge state sensor as valid.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/acpi/acpi_bat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_bat.c
diff -u src/sys/dev/acpi/acpi_bat.c:1.77 src/sys/dev/acpi/acpi_bat.c:1.78
--- src/sys/dev/acpi/acpi_bat.c:1.77	Sat Jan 23 15:06:47 2010
+++ src/sys/dev/acpi/acpi_bat.c	Sun Jan 24 11:32:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_bat.c,v 1.77 2010/01/23 15:06:47 jruoho Exp $	*/
+/*	$NetBSD: acpi_bat.c,v 1.78 2010/01/24 11:32:13 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.77 2010/01/23 15:06:47 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.78 2010/01/24 11:32:13 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -152,6 +152,7 @@
 	envsys_data_t		 sc_sensor[ACPIBAT_COUNT];
 	kmutex_t		 sc_mutex;
 	kcondvar_t		 sc_condvar;
+	int                      sc_present;
 };
 
 static const char * const bat_hid[] = {
@@ -233,6 +234,7 @@
 	aprint_normal(": ACPI Battery\n");
 
 	sc->sc_node = aa->aa_node;
+	sc->sc_present = 0;
 
 	mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(&sc->sc_condvar, device_xname(self));
@@ -498,6 +500,7 @@
 	sc->sc_sensor[ACPIBAT_VOLTAGE].value_cur = val;
 	sc->sc_sensor[ACPIBAT_VOLTAGE].state = ACPIBAT_VAL_ISVALID(val);
 
+	sc->sc_sensor[ACPIBAT_CHARGE_STATE].state = ENVSYS_SVALID;
 	sc->sc_sensor[ACPIBAT_CHARGE_STATE].value_cur =
 	    ENVSYS_BATTERY_CAPACITY_NORMAL;
 
@@ -552,6 +555,8 @@
 		}
 	}
 
+	sc->sc_present = rv;
+
 	mutex_exit(&sc->sc_mutex);
 }
 
@@ -566,9 +571,13 @@
 
 	rv = acpibat_get_sta(dv);
 
-	if (rv > 0)
+	if (rv > 0) {
+
+		if (sc->sc_present == 0)
+			acpibat_get_info(dv);
+
 		acpibat_get_status(dv);
-	else {
+	} else {
 		i = (rv < 0) ? 0 : ACPIBAT_DCAPACITY;
 
 		while (i < ACPIBAT_COUNT) {
@@ -577,6 +586,8 @@
 		}
 	}
 
+	sc->sc_present = rv;
+
 	microtime(&sc->sc_lastupdate);
 	cv_broadcast(&sc->sc_condvar);
 	mutex_exit(&sc->sc_mutex);

Reply via email to