summaryrefslogtreecommitdiff
path: root/sys/dev/pci
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/pci
parent2da4a587cf08c4fd33f160fe0f40ff89d9d3a3c3 (diff)
adapt to new two-level sensor api; Constantine A. Murenin
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/arc.c14
-rw-r--r--sys/dev/pci/mbg.c17
-rw-r--r--sys/dev/pci/viaenv.c22
3 files changed, 27 insertions, 26 deletions
diff --git a/sys/dev/pci/arc.c b/sys/dev/pci/arc.c
index 60479ad5d45..f2c15cacdfc 100644
--- a/sys/dev/pci/arc.c
+++ b/sys/dev/pci/arc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arc.c,v 1.56 2006/12/22 22:55:36 deraadt Exp $ */
+/* $OpenBSD: arc.c,v 1.57 2006/12/23 17:46:39 deraadt Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -385,6 +385,7 @@ struct arc_softc {
volatile int sc_talking;
struct sensor *sc_sensors;
+ struct sensordev sc_sensordev;
int sc_nsensors;
};
#define DEVNAME(_s) ((_s)->sc_dev.dv_xname)
@@ -1573,6 +1574,9 @@ arc_create_sensors(void *xsc, void *arg)
return;
bzero(sc->sc_sensors, sizeof(struct sensor) * sc->sc_nsensors);
+ strlcpy(sc->sc_sensordev.xname, DEVNAME(sc),
+ sizeof(sc->sc_sensordev.xname));
+
for (i = 0; i < sc->sc_nsensors; i++) {
bzero(&bv, sizeof(bv));
bv.bv_volid = i;
@@ -1582,22 +1586,20 @@ arc_create_sensors(void *xsc, void *arg)
sc->sc_sensors[i].type = SENSOR_DRIVE;
sc->sc_sensors[i].status = SENSOR_S_UNKNOWN;
- strlcpy(sc->sc_sensors[i].device, DEVNAME(sc),
- sizeof(sc->sc_sensors[i].device));
strlcpy(sc->sc_sensors[i].desc, bv.bv_dev,
sizeof(sc->sc_sensors[i].desc));
- sensor_add(&sc->sc_sensors[i]);
+ sensor_attach(&sc->sc_sensordev, &sc->sc_sensors[i]);
}
if (sensor_task_register(sc, arc_refresh_sensors, 120) != 0)
goto bad;
+ sensordev_install(&sc->sc_sensordev);
+
return;
bad:
- while (--i >= 0)
- sensor_del(&sc->sc_sensors[i]);
free(sc->sc_sensors, M_DEVBUF);
}
diff --git a/sys/dev/pci/mbg.c b/sys/dev/pci/mbg.c
index 4d3941a5c19..7b185e59401 100644
--- a/sys/dev/pci/mbg.c
+++ b/sys/dev/pci/mbg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbg.c,v 1.6 2006/12/22 09:04:42 mbalmer Exp $ */
+/* $OpenBSD: mbg.c,v 1.7 2006/12/23 17:46:39 deraadt Exp $ */
/*
* Copyright (c) 2006 Marc Balmer <mbalmer@openbsd.org>
@@ -39,6 +39,7 @@ struct mbg_softc {
struct sensor sc_timedelta;
struct sensor sc_signal;
+ struct sensordev sc_sensordev;
u_int8_t sc_status;
};
@@ -153,26 +154,28 @@ mbg_attach(struct device *parent, struct device *self, void *aux)
printf("invalid\n");
sc->sc_status = tframe.status;
}
- strlcpy(sc->sc_timedelta.device, sc->sc_dev.dv_xname,
- sizeof(sc->sc_timedelta.device));
+
+ strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
+ sizeof(sc->sc_sensordev.xname));
+
sc->sc_timedelta.type = SENSOR_TIMEDELTA;
sc->sc_timedelta.status = SENSOR_S_UNKNOWN;
sc->sc_timedelta.value = 0LL;
sc->sc_timedelta.flags = 0;
strlcpy(sc->sc_timedelta.desc, "DCF77", sizeof(sc->sc_timedelta.desc));
- sensor_add(&sc->sc_timedelta);
+ sensor_attach(&sc->sc_sensordev, &sc->sc_timedelta);
- strlcpy(sc->sc_signal.device, sc->sc_dev.dv_xname,
- sizeof(sc->sc_signal.device));
sc->sc_signal.type = SENSOR_PERCENT;
sc->sc_signal.status = SENSOR_S_UNKNOWN;
sc->sc_signal.value = 0LL;
sc->sc_signal.flags = 0;
strlcpy(sc->sc_signal.desc, "Signal strength",
sizeof(sc->sc_signal.desc));
- sensor_add(&sc->sc_signal);
+ sensor_attach(&sc->sc_sensordev, &sc->sc_signal);
sensor_task_register(sc, mbg_task, 10);
+
+ sensordev_install(&sc->sc_sensordev);
}
void
diff --git a/sys/dev/pci/viaenv.c b/sys/dev/pci/viaenv.c
index 9f7a16fb672..04d389b86d1 100644
--- a/sys/dev/pci/viaenv.c
+++ b/sys/dev/pci/viaenv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: viaenv.c,v 1.8 2006/06/19 14:43:54 kettenis Exp $ */
+/* $OpenBSD: viaenv.c,v 1.9 2006/12/23 17:46:39 deraadt Exp $ */
/* $NetBSD: viaenv.c,v 1.9 2002/10/02 16:51:59 thorpej Exp $ */
/*
@@ -70,6 +70,7 @@ struct viaenv_softc {
int sc_fan_div[2]; /* fan RPM divisor */
struct sensor sc_data[VIANUMSENSORS];
+ struct sensordev sc_sensordev;
};
int viaenv_match(struct device *, void *, void *);
@@ -283,25 +284,13 @@ viaenv_attach(struct device * parent, struct device * self, void *aux)
goto nohwm;
}
- /* Initialize sensors */
- for (i = 0; i < VIANUMSENSORS; ++i) {
- strlcpy(sc->sc_data[i].device, sc->sc_dev.dv_xname,
- sizeof(sc->sc_data[i].device));
- sensor_add(&sc->sc_data[i]);
- }
-
for (i = 0; i <= 2; i++) {
sc->sc_data[i].type = SENSOR_TEMP;
}
- strlcpy(sc->sc_data[0].desc, "TSENS1", sizeof(sc->sc_data[0].desc));
- strlcpy(sc->sc_data[1].desc, "TSENS2", sizeof(sc->sc_data[1].desc));
- strlcpy(sc->sc_data[2].desc, "TSENS3", sizeof(sc->sc_data[2].desc));
for (i = 3; i <= 4; i++) {
sc->sc_data[i].type = SENSOR_FANRPM;
}
- strlcpy(sc->sc_data[3].desc, "FAN1", sizeof(sc->sc_data[3].desc));
- strlcpy(sc->sc_data[4].desc, "FAN2", sizeof(sc->sc_data[4].desc));
for (i = 5; i <= 9; ++i) {
sc->sc_data[i].type = SENSOR_VOLTS_DC;
@@ -320,6 +309,13 @@ viaenv_attach(struct device * parent, struct device * self, void *aux)
/* Get initial set of sensor values. */
viaenv_refresh_sensor_data(sc);
+ /* Register sensors with sysctl */
+ strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
+ sizeof(sc->sc_sensordev.xname));
+ for (i = 0; i < VIANUMSENSORS; ++i)
+ sensor_attach(&sc->sc_sensordev, &sc->sc_data[i]);
+ sensordev_install(&sc->sc_sensordev);
+
/* Refresh sensors data every 1.5 seconds */
timeout_set(&viaenv_timeout, viaenv_refresh, sc);
timeout_add(&viaenv_timeout, (15 * hz) / 10);