summaryrefslogtreecommitdiff
path: root/sys/dev/acpi
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-12-23 17:46:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-12-23 17:46:40 +0000
commit456453067d1414c6f4097d6aeaf996624183d72b (patch)
treeb3a5f4f9a05a1aba0dd603c6eb3a6ff0cd86ee9f /sys/dev/acpi
parent2da4a587cf08c4fd33f160fe0f40ff89d9d3a3c3 (diff)
adapt to new two-level sensor api; Constantine A. Murenin
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/acpiac.c10
-rw-r--r--sys/dev/acpi/acpibat.c28
-rw-r--r--sys/dev/acpi/acpidev.h8
-rw-r--r--sys/dev/acpi/acpitz.c10
4 files changed, 31 insertions, 25 deletions
diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c
index 8b37c7fbbcc..b9f3ff7b7b8 100644
--- a/sys/dev/acpi/acpiac.c
+++ b/sys/dev/acpi/acpiac.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpiac.c,v 1.12 2006/12/21 11:23:41 deraadt Exp $ */
+/* $OpenBSD: acpiac.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -80,10 +80,12 @@ acpiac_attach(struct device *parent, struct device *self, void *aux)
else
printf(" in unknown state");
- strlcpy(sc->sens[0].device, DEVNAME(sc), sizeof(sc->sens[0].device));
- strlcpy(sc->sens[0].desc, "power supply", sizeof(sc->sens[2].desc));
+ strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
+ sizeof(sc->sc_sensdev.xname));
+ strlcpy(sc->sens[0].desc, "power supply", sizeof(sc->sens[0].desc));
sc->sens[0].type = SENSOR_INDICATOR;
- sensor_add(&sc->sens[0]);
+ sensor_attach(&sc->sc_sensdev, &sc->sens[0]);
+ sensordev_install(&sc->sc_sensdev);
sc->sens[0].value = sc->sc_ac_stat;
}
diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c
index ca8e76b0d8c..e20ae8f01b7 100644
--- a/sys/dev/acpi/acpibat.c
+++ b/sys/dev/acpi/acpibat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpibat.c,v 1.35 2006/12/21 19:59:02 deraadt Exp $ */
+/* $OpenBSD: acpibat.c,v 1.36 2006/12/23 17:46:39 deraadt Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -104,64 +104,64 @@ acpibat_attach(struct device *parent, struct device *self, void *aux)
void
acpibat_monitor(struct acpibat_softc *sc)
{
- int i, type;
+ int type;
/* assume _BIF and _BST have been called */
- memset(sc->sc_sens, 0, sizeof(sc->sc_sens));
- for (i = 0; i < 8; i++)
- strlcpy(sc->sc_sens[i].device, DEVNAME(sc),
- sizeof(sc->sc_sens[i].device));
+ strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
+ sizeof(sc->sc_sensdev.xname));
type = sc->sc_bif.bif_power_unit ? SENSOR_AMPHOUR : SENSOR_WATTHOUR;
strlcpy(sc->sc_sens[0].desc, "last full capacity",
sizeof(sc->sc_sens[0].desc));
sc->sc_sens[0].type = type;
- sensor_add(&sc->sc_sens[0]);
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[0]);
sc->sc_sens[0].value = sc->sc_bif.bif_last_capacity * 1000;
strlcpy(sc->sc_sens[1].desc, "warning capacity",
sizeof(sc->sc_sens[1].desc));
sc->sc_sens[1].type = type;
- sensor_add(&sc->sc_sens[1]);
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[1]);
sc->sc_sens[1].value = sc->sc_bif.bif_warning * 1000;
strlcpy(sc->sc_sens[2].desc, "low capacity",
sizeof(sc->sc_sens[2].desc));
sc->sc_sens[2].type = type;
- sensor_add(&sc->sc_sens[2]);
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[2]);
sc->sc_sens[2].value = sc->sc_bif.bif_low * 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]);
+ sensor_attach(&sc->sc_sensdev, &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, "battery unknown",
sizeof(sc->sc_sens[4].desc));
sc->sc_sens[4].type = SENSOR_INTEGER;
- sensor_add(&sc->sc_sens[4]);
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[4]);
sc->sc_sens[4].status = SENSOR_S_UNKNOWN;
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]);
+ sensor_attach(&sc->sc_sensdev, &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 = type;
- sensor_add(&sc->sc_sens[6]);
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[6]);
sc->sc_sens[6].value = sc->sc_bst.bst_capacity * 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]);
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[7]);
sc->sc_sens[7].status = SENSOR_S_OK;
sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000;
+
+ sensordev_install(&sc->sc_sensdev);
}
void
diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h
index 93b4f6f1bc6..4834910f2fb 100644
--- a/sys/dev/acpi/acpidev.h
+++ b/sys/dev/acpi/acpidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpidev.h,v 1.12 2006/12/21 11:23:41 deraadt Exp $ */
+/* $OpenBSD: acpidev.h,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
@@ -258,7 +258,8 @@ struct acpiac_softc {
int sc_ac_stat;
- struct sensor sens[1]; /* XXX debug only */
+ struct sensor sens[1]; /* XXX debug only */
+ struct sensordev sc_sensdev;
};
struct acpibat_softc {
@@ -274,6 +275,7 @@ struct acpibat_softc {
struct acpibat_bst sc_bst;
volatile int sc_bat_present;
- struct sensor sc_sens[8]; /* XXX debug only */
+ struct sensor sc_sens[8]; /* XXX debug only */
+ struct sensordev sc_sensdev;
};
#endif /* __DEV_ACPI_ACPIDEV_H__ */
diff --git a/sys/dev/acpi/acpitz.c b/sys/dev/acpi/acpitz.c
index 7d06407816a..2d4f9200136 100644
--- a/sys/dev/acpi/acpitz.c
+++ b/sys/dev/acpi/acpitz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpitz.c,v 1.12 2006/12/21 11:23:41 deraadt Exp $ */
+/* $OpenBSD: acpitz.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */
/*
* Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org>
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
@@ -52,6 +52,7 @@ struct acpitz_softc {
int sc_tc2;
int sc_lasttmp;
struct sensor sc_sens;
+ struct sensordev sc_sensdev;
};
int acpitz_match(struct device *, void *, void *);
@@ -128,12 +129,13 @@ acpitz_attach(struct device *parent, struct device *self, void *aux)
aml_register_notify(sc->sc_devnode->parent, NULL,
acpitz_notify, sc);
- memset(&sc->sc_sens, 0, sizeof(sc->sc_sens));
- strlcpy(sc->sc_sens.device, DEVNAME(sc), sizeof(sc->sc_sens.device));
+ strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
+ sizeof(sc->sc_sensdev.xname));
strlcpy(sc->sc_sens.desc, "zone temperature",
sizeof(sc->sc_sens.desc));
sc->sc_sens.type = SENSOR_TEMP;
- sensor_add(&sc->sc_sens);
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens);
+ sensordev_install(&sc->sc_sensdev);
sc->sc_sens.value = 0;
}