misc/124744: incorrect _BST result validation for Tosh Satellite P20

Yuri Skripachov y.skripachov at gmail.com
Thu Jun 19 06:20:02 UTC 2008


>Number:         124744
>Category:       misc
>Synopsis:       incorrect _BST result validation for Tosh Satellite P20
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 19 06:20:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Yuri Skripachov
>Release:        FreeBSD 7.0-STABLE
>Organization:
>Environment:
FreeBSD satellite.local 7.0-STABLE FreeBSD 7.0-STABLE #0: Wed Jun 18 13:50:25 MSD 2008  yvs at satellite.local:/usr/local/obj/usr/src/sys/SATELLITE i386
>Description:
"acpiconf -i 0" command does not show battery presence if notebook is AC powered. that is because of extra bits used in _BST state by toshiba. according to acpi specs the only wrong _BST state is (ACPI_BATT_STAT_CHARGING | ACPI_BATT_STAT_DISCHARG). it seems that other bits in _BST have to be ignored and arithmetic comparison is a wrong way to validate _BST state. at least for my satellite :( i have been using this patch for 5.x, 6.x and 7.0-stable.
>How-To-Repeat:
plug in AC adapter and type acpiconf -i 0.
>Fix:
patch for /usr/src/sys/dev/acpica/acpi_battery.c is attached.

Patch attached with submission follows:

--- acpi_battery.c.orig	2008-06-19 09:35:41.000000000 +0400
+++ acpi_battery.c	2008-06-19 09:36:05.000000000 +0400
@@ -101,8 +101,10 @@
 int
 acpi_battery_bst_valid(struct acpi_bst *bst)
 {
-    return (bst->state < ACPI_BATT_STAT_MAX && bst->cap != ACPI_BATT_UNKNOWN &&
-	bst->volt != ACPI_BATT_UNKNOWN);
+#define ACPI_BATT_STAT_IMPOSSIBLE (ACPI_BATT_STAT_CHARGING | ACPI_BATT_STAT_DISCHARG)
+    return ((bst->state & ACPI_BATT_STAT_IMPOSSIBLE) != ACPI_BATT_STAT_IMPOSSIBLE &&
+        bst->cap != ACPI_BATT_UNKNOWN && bst->volt != ACPI_BATT_UNKNOWN);
+#undef ACPI_BATT_STAT_IMPOSSIBLE
 }
 
 /* Check _BIF results for validity. */


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list