Permalink
Browse files

acpibat: look for _BIX first before falling back on _BIF

ACPI 4.0 deprecated _BIF for battery status so some newer machines
are exporting _BIX which extends _BIF's package with a few extra
fields.  When using _BIX, export the new discharge cycle count as a
sensor.

feedback from kettenis and anton
ok deraadt
  • Loading branch information...
jcs committed Jul 22, 2017
1 parent c947572 commit 254e454239cd0f7d5fe820553a25294d0cff53b8
Showing with 206 additions and 106 deletions.
  1. +3 −3 sys/dev/acpi/acpi.c
  2. +146 −81 sys/dev/acpi/acpibat.c
  3. +57 −22 sys/dev/acpi/acpidev.h
@@ -1,4 +1,4 @@
/* $OpenBSD: acpi.c,v 1.329 2017/07/20 18:34:24 kettenis Exp $ */
/* $OpenBSD: acpi.c,v 1.330 2017/07/22 21:06:17 jcs Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -3096,12 +3096,12 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
if (bat->aba_softc->sc_bat_present == 0)
continue;

if (bat->aba_softc->sc_bif.bif_last_capacity == 0)
if (bat->aba_softc->sc_bix.bix_last_capacity == 0)
continue;

bats++;
rem = (bat->aba_softc->sc_bst.bst_capacity * 100) /
bat->aba_softc->sc_bif.bif_last_capacity;
bat->aba_softc->sc_bix.bix_last_capacity;
if (rem > 100)
rem = 100;
remaining += rem;
Oops, something went wrong.

0 comments on commit 254e454

Please sign in to comment.