Module Name: src
Committed By: jmcneill
Date: Tue Jan 18 16:45:11 UTC 2011
Modified Files:
src/sys/dev/isa: aps.c
Log Message:
treat temperature readings of 0xff as invalid, as I'm somewhat confident
that my Thinkpad isn't idling at 255 degC.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/isa/aps.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/isa/aps.c
diff -u src/sys/dev/isa/aps.c:1.12 src/sys/dev/isa/aps.c:1.13
--- src/sys/dev/isa/aps.c:1.12 Sun Jan 16 14:16:03 2011
+++ src/sys/dev/isa/aps.c Tue Jan 18 16:45:11 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: aps.c,v 1.12 2011/01/16 14:16:03 jmcneill Exp $ */
+/* $NetBSD: aps.c,v 1.13 2011/01/18 16:45:11 jmcneill Exp $ */
/* $OpenBSD: aps.c,v 1.15 2007/05/19 19:14:11 tedu Exp $ */
/* $OpenBSD: aps.c,v 1.17 2008/06/27 06:08:43 canacar Exp $ */
/*
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aps.c,v 1.12 2011/01/16 14:16:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aps.c,v 1.13 2011/01/18 16:45:11 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -460,23 +460,35 @@
{
int64_t temp;
- if (aps_read_data(sc))
+ if (aps_read_data(sc)) {
+ printf("aps0: read data failed\n");
return;
+ }
sc->sc_sensor[APS_SENSOR_XACCEL].value_cur = sc->aps_data.x_accel;
sc->sc_sensor[APS_SENSOR_YACCEL].value_cur = sc->aps_data.y_accel;
- /* convert to micro (mu) degrees */
- temp = sc->aps_data.temp1 * 1000000;
- /* convert to kelvin */
- temp += 273150000;
- sc->sc_sensor[APS_SENSOR_TEMP1].value_cur = temp;
-
- /* convert to micro (mu) degrees */
- temp = sc->aps_data.temp2 * 1000000;
- /* convert to kelvin */
- temp += 273150000;
- sc->sc_sensor[APS_SENSOR_TEMP2].value_cur = temp;
+ if (sc->aps_data.temp1 == 0xff)
+ sc->sc_sensor[APS_SENSOR_TEMP1].state = ENVSYS_SINVALID;
+ else {
+ /* convert to micro (mu) degrees */
+ temp = sc->aps_data.temp1 * 1000000;
+ /* convert to kelvin */
+ temp += 273150000;
+ sc->sc_sensor[APS_SENSOR_TEMP1].value_cur = temp;
+ sc->sc_sensor[APS_SENSOR_TEMP1].state = ENVSYS_SVALID;
+ }
+
+ if (sc->aps_data.temp2 == 0xff)
+ sc->sc_sensor[APS_SENSOR_TEMP2].state = ENVSYS_SINVALID;
+ else {
+ /* convert to micro (mu) degrees */
+ temp = sc->aps_data.temp2 * 1000000;
+ /* convert to kelvin */
+ temp += 273150000;
+ sc->sc_sensor[APS_SENSOR_TEMP2].value_cur = temp;
+ sc->sc_sensor[APS_SENSOR_TEMP2].state = ENVSYS_SVALID;
+ }
sc->sc_sensor[APS_SENSOR_XVAR].value_cur = sc->aps_data.x_var;
sc->sc_sensor[APS_SENSOR_YVAR].value_cur = sc->aps_data.y_var;