diff options
author | jhb <jhb@FreeBSD.org> | 2002-08-21 15:01:53 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-08-21 15:01:53 +0000 |
commit | e08ee29c0fc03530f172d414b2c259b48fc6e16c (patch) | |
tree | 4ad9f2ce64e90e63e6a8c3642108d4c6757ea47b /sys/dev/acpica | |
parent | e383817c6e274a4284061144d8f4496920a50579 (diff) | |
download | FreeBSD-src-e08ee29c0fc03530f172d414b2c259b48fc6e16c.zip FreeBSD-src-e08ee29c0fc03530f172d414b2c259b48fc6e16c.tar.gz |
Use the _STA method of a battery control method to see if a battery is
present or not. My laptop now properly notices when a battery is removed.
Reviewed by: iwasaki
Diffstat (limited to 'sys/dev/acpica')
-rw-r--r-- | sys/dev/acpica/acpi_cmbat.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c index 0c200bd..86a650e 100644 --- a/sys/dev/acpica/acpi_cmbat.c +++ b/sys/dev/acpica/acpi_cmbat.c @@ -109,7 +109,7 @@ struct acpi_cmbat_softc { int bif_updating; int bst_updating; - int not_present; + int present; int cap; int min; int full_charge_time; @@ -420,12 +420,15 @@ acpi_cmbat_ioctl(u_long cmd, caddr_t addr, void *arg) break; case ACPIIO_CMBAT_GET_BST: - acpi_cmbat_get_bst(dev); bstp = &ioctl_arg->bst; - bstp->state = sc->bst.state; - bstp->rate = sc->bst.rate; - bstp->cap = sc->bst.cap; - bstp->volt = sc->bst.volt; + if (acpi_BatteryIsPresent(dev)) { + acpi_cmbat_get_bst(dev); + bstp->state = sc->bst.state; + bstp->rate = sc->bst.rate; + bstp->cap = sc->bst.cap; + bstp->volt = sc->bst.volt; + } else + bstp->state = ACPI_BATT_STAT_NOT_PRESENT; break; } @@ -486,7 +489,10 @@ acpi_cmbat_get_total_battinfo(struct acpi_battinfo *battinfo) /* Get battery status, valid rate and valid units */ batt_stat = valid_rate = valid_units = 0; for (i = 0; i < acpi_cmbat_units; i++) { - bat[i]->not_present = 0; + bat[i]->present = acpi_BatteryIsPresent(bat[i]->dev); + if (!bat[i]->present) + continue; + acpi_cmbat_get_bst(bat[i]->dev); /* If battey not installed, we get strange values */ @@ -494,7 +500,7 @@ acpi_cmbat_get_total_battinfo(struct acpi_battinfo *battinfo) bat[i]->bst.cap == 0xffffffff || bat[i]->bst.volt == 0xffffffff || bat[i]->bif.lfcap == 0) { - bat[i]->not_present = 1; + bat[i]->present = 0; continue; } @@ -526,7 +532,7 @@ acpi_cmbat_get_total_battinfo(struct acpi_battinfo *battinfo) /* Calculate total battery capacity and time */ total_cap = total_min = total_full = 0; for (i = 0; i < acpi_cmbat_units; i++) { - if (bat[i]->not_present) { + if (!bat[i]->present) { continue; } @@ -612,7 +618,7 @@ acpi_cmbat_get_battinfo(int unit, struct acpi_battinfo *battinfo) goto out; } - if (sc->not_present) { + if (!sc->present) { battinfo->cap = -1; battinfo->min = -1; battinfo->state = ACPI_BATT_STAT_NOT_PRESENT; |