Initialize sensor states before registering.

This commit is contained in:
pgoyette 2011-06-20 17:01:45 +00:00
parent f80eb73fce
commit d9b90a6705
2 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: lom.c,v 1.8 2011/06/19 21:37:10 nakayama Exp $ */
/* $NetBSD: lom.c,v 1.9 2011/06/20 17:01:45 pgoyette Exp $ */
/* $OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.8 2011/06/19 21:37:10 nakayama Exp $");
__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.9 2011/06/20 17:01:45 pgoyette Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -351,6 +351,7 @@ lom_attach(device_t parent, device_t self, void *aux)
sc->sc_sme = sysmon_envsys_create();
for (i = 0; i < sc->sc_num_alarm; i++) {
sc->sc_alarm[i].units = ENVSYS_INDICATOR;
sc->sc_alarm[i].state = ENVSYS_SINVALID;
snprintf(sc->sc_alarm[i].desc, sizeof(sc->sc_alarm[i].desc),
i == 0 ? "Fault LED" : "Alarm%d", i);
if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_alarm[i])) {
@ -372,6 +373,7 @@ lom_attach(device_t parent, device_t self, void *aux)
}
for (i = 0; i < sc->sc_num_fan; i++) {
sc->sc_fan[i].units = ENVSYS_SFANRPM;
sc->sc_fan[i].state = ENVSYS_SINVALID;
snprintf(sc->sc_fan[i].desc, sizeof(sc->sc_fan[i].desc),
"fan%d", i + 1);
if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_fan[i])) {
@ -382,6 +384,7 @@ lom_attach(device_t parent, device_t self, void *aux)
}
for (i = 0; i < sc->sc_num_psu; i++) {
sc->sc_psu[i].units = ENVSYS_INDICATOR;
sc->sc_psu[i].state = ENVSYS_SINVALID;
snprintf(sc->sc_psu[i].desc, sizeof(sc->sc_psu[i].desc),
"PSU%d", i + 1);
if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_psu[i])) {
@ -392,6 +395,7 @@ lom_attach(device_t parent, device_t self, void *aux)
}
for (i = 0; i < sc->sc_num_temp; i++) {
sc->sc_temp[i].units = ENVSYS_STEMP;
sc->sc_temp[i].state = ENVSYS_SINVALID;
snprintf(sc->sc_temp[i].desc, sizeof(sc->sc_temp[i].desc),
"temp%d", i + 1);
if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_temp[i])) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcf8591_envctrl.c,v 1.4 2011/04/03 06:22:02 jdc Exp $ */
/* $NetBSD: pcf8591_envctrl.c,v 1.5 2011/06/20 17:01:45 pgoyette Exp $ */
/* $OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
/*
@ -137,6 +137,7 @@ ecadc_attach(device_t parent, device_t self, void *aux)
sensor = &sc->sc_channels[sc->sc_nchan].chan_sensor;
sensor->units = ENVSYS_STEMP;
sensor->flags |= ENVSYS_FMONLIMITS;
sensor->state = ENVSYS_SINVALID;
strlcpy(sensor->desc, desc, sizeof(sensor->desc));
if (strncmp(desc, "CPU", 3) == 0)