summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/acpi/acpibat.c148
1 files changed, 74 insertions, 74 deletions
diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c
index 93a4d8e130d..85d674729ae 100644
--- a/sys/dev/acpi/acpibat.c
+++ b/sys/dev/acpi/acpibat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpibat.c,v 1.16 2006/02/21 01:12:40 marco Exp $ */
+/* $OpenBSD: acpibat.c,v 1.17 2006/02/21 20:25:26 marco Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -30,8 +30,8 @@
#include <sys/sensors.h>
-int acpibat_match(struct device *, void *, void *);
-void acpibat_attach(struct device *, struct device *, void *);
+int acpibat_match(struct device *, void *, void *);
+void acpibat_attach(struct device *, struct device *, void *);
struct acpibat_softc {
struct device sc_dev;
@@ -45,7 +45,7 @@ struct acpibat_softc {
struct acpibat_bif sc_bif;
struct acpibat_bst sc_bst;
- struct sensor sens[13]; /* XXX debug only */
+ struct sensor sc_sens[8]; /* XXX debug only */
};
struct cfattach acpibat_ca = {
@@ -56,15 +56,15 @@ struct cfdriver acpibat_cd = {
NULL, "acpibat", DV_DULL
};
-void acpibat_refresh(void *);
-int acpibat_getbif(struct acpibat_softc *);
-int acpibat_getbst(struct acpibat_softc *);
+void acpibat_refresh(void *);
+int acpibat_getbif(struct acpibat_softc *);
+int acpibat_getbst(struct acpibat_softc *);
int
acpibat_match(struct device *parent, void *match, void *aux)
{
- struct acpi_attach_args *aa = aux;
- struct cfdata *cf = match;
+ struct acpi_attach_args *aa = aux;
+ struct cfdata *cf = match;
/* sanity */
if (aa->aaa_name == NULL ||
@@ -78,9 +78,9 @@ acpibat_match(struct device *parent, void *match, void *aux)
void
acpibat_attach(struct device *parent, struct device *self, void *aux)
{
- struct acpibat_softc *sc = (struct acpibat_softc *) self;
- struct acpi_attach_args *aa = aux;
- int i;
+ struct acpibat_softc *sc = (struct acpibat_softc *)self;
+ struct acpi_attach_args *aa = aux;
+ int i;
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aa->aaa_node->child;
@@ -96,54 +96,54 @@ acpibat_attach(struct device *parent, struct device *self, void *aux)
sc->sc_bif.bif_type,
sc->sc_bif.bif_oem);
- memset(sc->sens, 0, sizeof(sc->sens));
+ memset(sc->sc_sens, 0, sizeof(sc->sc_sens));
/* XXX this is for debug only, remove later */
for (i = 0; i < 13; i++)
- strlcpy(sc->sens[i].device, DEVNAME(sc), sizeof(sc->sens[i].device));
-
- strlcpy(sc->sens[0].desc, "last full capacity", sizeof(sc->sens[2].desc));
- sc->sens[0].type = SENSOR_PERCENT;
- sensor_add(&sc->sens[0]);
- sc->sens[0].value = sc->sc_bif.bif_last_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
-
- strlcpy(sc->sens[1].desc, "warning capacity", sizeof(sc->sens[1].desc));
- sc->sens[1].type = SENSOR_PERCENT;
- sensor_add(&sc->sens[1]);
- sc->sens[1].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
-
- strlcpy(sc->sens[2].desc, "low capacity", sizeof(sc->sens[2].desc));
- sc->sens[2].type = SENSOR_PERCENT;
- sensor_add(&sc->sens[2]);
- sc->sens[2].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
-
- strlcpy(sc->sens[3].desc, "voltage", sizeof(sc->sens[3].desc));
- sc->sens[3].type = SENSOR_VOLTS_DC;
- sensor_add(&sc->sens[3]);
- sc->sens[3].status = SENSOR_S_OK;
- sc->sens[3].value = sc->sc_bif.bif_voltage * 1000;
-
- strlcpy(sc->sens[4].desc, "state", sizeof(sc->sens[4].desc));
- sc->sens[4].type = SENSOR_INTEGER;
- sensor_add(&sc->sens[4]);
- sc->sens[4].status = SENSOR_S_OK;
- sc->sens[4].value = sc->sc_bst.bst_state;
-
- strlcpy(sc->sens[5].desc, "rate", sizeof(sc->sens[5].desc));
- sc->sens[5].type = SENSOR_INTEGER;
- sensor_add(&sc->sens[5]);
- sc->sens[5].value = sc->sc_bst.bst_rate;
-
- strlcpy(sc->sens[6].desc, "remaining capacity", sizeof(sc->sens[6].desc));
- sc->sens[6].type = SENSOR_PERCENT;
- sensor_add(&sc->sens[6]);
- sc->sens[6].value = sc->sc_bst.bst_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
-
- strlcpy(sc->sens[7].desc, "current voltage", sizeof(sc->sens[7].desc));
- sc->sens[7].type = SENSOR_VOLTS_DC;
- sensor_add(&sc->sens[7]);
- sc->sens[7].status = SENSOR_S_OK;
- sc->sens[7].value = sc->sc_bst.bst_voltage * 1000;
+ strlcpy(sc->sc_sens[i].device, DEVNAME(sc), sizeof(sc->sc_sens[i].device));
+
+ strlcpy(sc->sc_sens[0].desc, "last full capacity", sizeof(sc->sc_sens[2].desc));
+ sc->sc_sens[0].type = SENSOR_PERCENT;
+ sensor_add(&sc->sc_sens[0]);
+ sc->sc_sens[0].value = sc->sc_bif.bif_last_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
+
+ strlcpy(sc->sc_sens[1].desc, "warning capacity", sizeof(sc->sc_sens[1].desc));
+ sc->sc_sens[1].type = SENSOR_PERCENT;
+ sensor_add(&sc->sc_sens[1]);
+ sc->sc_sens[1].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
+
+ strlcpy(sc->sc_sens[2].desc, "low capacity", sizeof(sc->sc_sens[2].desc));
+ sc->sc_sens[2].type = SENSOR_PERCENT;
+ sensor_add(&sc->sc_sens[2]);
+ sc->sc_sens[2].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
+
+ strlcpy(sc->sc_sens[3].desc, "voltage", sizeof(sc->sc_sens[3].desc));
+ sc->sc_sens[3].type = SENSOR_VOLTS_DC;
+ sensor_add(&sc->sc_sens[3]);
+ sc->sc_sens[3].status = SENSOR_S_OK;
+ sc->sc_sens[3].value = sc->sc_bif.bif_voltage * 1000;
+
+ strlcpy(sc->sc_sens[4].desc, "state", sizeof(sc->sc_sens[4].desc));
+ sc->sc_sens[4].type = SENSOR_INTEGER;
+ sensor_add(&sc->sc_sens[4]);
+ sc->sc_sens[4].status = SENSOR_S_OK;
+ sc->sc_sens[4].value = sc->sc_bst.bst_state;
+
+ strlcpy(sc->sc_sens[5].desc, "rate", sizeof(sc->sc_sens[5].desc));
+ sc->sc_sens[5].type = SENSOR_INTEGER;
+ sensor_add(&sc->sc_sens[5]);
+ sc->sc_sens[5].value = sc->sc_bst.bst_rate;
+
+ strlcpy(sc->sc_sens[6].desc, "remaining capacity", sizeof(sc->sc_sens[6].desc));
+ sc->sc_sens[6].type = SENSOR_PERCENT;
+ sensor_add(&sc->sc_sens[6]);
+ sc->sc_sens[6].value = sc->sc_bst.bst_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
+
+ strlcpy(sc->sc_sens[7].desc, "current voltage", sizeof(sc->sc_sens[7].desc));
+ sc->sc_sens[7].type = SENSOR_VOLTS_DC;
+ sensor_add(&sc->sc_sens[7]);
+ sc->sc_sens[7].status = SENSOR_S_OK;
+ sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000;
if (sensor_task_register(sc, acpibat_refresh, 10))
printf(", unable to register update task\n");
@@ -153,35 +153,35 @@ acpibat_attach(struct device *parent, struct device *self, void *aux)
void
acpibat_refresh(void *arg)
{
- struct acpibat_softc *sc = arg;
+ struct acpibat_softc *sc = arg;
acpibat_getbif(sc);
acpibat_getbst(sc);
- sc->sens[0].value = sc->sc_bif.bif_last_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
- sc->sens[1].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
- sc->sens[2].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
- sc->sens[3].value = sc->sc_bif.bif_voltage * 1000;
+ sc->sc_sens[0].value = sc->sc_bif.bif_last_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
+ sc->sc_sens[1].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
+ sc->sc_sens[2].value = sc->sc_bif.bif_warning / sc->sc_bif.bif_cap_granu1 * 1000;
+ sc->sc_sens[3].value = sc->sc_bif.bif_voltage * 1000;
- sc->sens[4].status = SENSOR_S_OK;
+ sc->sc_sens[4].status = SENSOR_S_OK;
if (sc->sc_bst.bst_state & BST_DISCHARGE)
- strlcpy(sc->sens[4].desc, "battery discharging", sizeof(sc->sens[4].desc));
+ strlcpy(sc->sc_sens[4].desc, "battery discharging", sizeof(sc->sc_sens[4].desc));
else if (sc->sc_bst.bst_state & BST_CHARGE)
- strlcpy(sc->sens[4].desc, "battery charging", sizeof(sc->sens[4].desc));
+ strlcpy(sc->sc_sens[4].desc, "battery charging", sizeof(sc->sc_sens[4].desc));
else if (sc->sc_bst.bst_state & BST_CRITICAL) {
- strlcpy(sc->sens[4].desc, "battery critical", sizeof(sc->sens[4].desc));
- sc->sens[4].status = SENSOR_S_CRIT;
+ strlcpy(sc->sc_sens[4].desc, "battery critical", sizeof(sc->sc_sens[4].desc));
+ sc->sc_sens[4].status = SENSOR_S_CRIT;
}
- sc->sens[4].value = sc->sc_bst.bst_state;
- sc->sens[5].value = sc->sc_bst.bst_rate;
- sc->sens[6].value = sc->sc_bst.bst_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
+ sc->sc_sens[4].value = sc->sc_bst.bst_state;
+ sc->sc_sens[5].value = sc->sc_bst.bst_rate;
+ sc->sc_sens[6].value = sc->sc_bst.bst_capacity / sc->sc_bif.bif_cap_granu1 * 1000;
}
int
acpibat_getbif(struct acpibat_softc *sc)
{
- struct aml_value res, env;
- struct acpi_context *ctx;
+ struct aml_value res, env;
+ struct acpi_context *ctx;
memset(&res, 0, sizeof(res));
memset(&env, 0, sizeof(env));
@@ -247,8 +247,8 @@ acpibat_getbif(struct acpibat_softc *sc)
int
acpibat_getbst(struct acpibat_softc *sc)
{
- struct aml_value res, env;
- struct acpi_context *ctx;
+ struct aml_value res, env;
+ struct acpi_context *ctx;
memset(&res, 0, sizeof(res));
memset(&env, 0, sizeof(env));