diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2011-05-29 20:46:53 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2011-05-29 20:46:53 +0000 |
commit | 05e7cba7111f31880f8417bd021e471f5376a2a5 (patch) | |
tree | 732864e0f436feb91eebdc57c17fd8f472e4e16b /sys/powerpc | |
parent | 68cfdce751b5ac2ff0dbf8ca60be191245e47283 (diff) | |
download | FreeBSD-src-05e7cba7111f31880f8417bd021e471f5376a2a5.zip FreeBSD-src-05e7cba7111f31880f8417bd021e471f5376a2a5.tar.gz |
Add some error handling here: if a sensor returns an error code (a negative
Kelvin temperature, which is impossible except for some contrived magnetic
spin systems), use the previous measurement from that sensor instead of
corrupting everything and randomly changing the fans or shutting off the
machine.
Diffstat (limited to 'sys/powerpc')
-rw-r--r-- | sys/powerpc/powermac/powermac_thermal.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/powerpc/powermac/powermac_thermal.c b/sys/powerpc/powermac/powermac_thermal.c index 041924a..2d29d42 100644 --- a/sys/powerpc/powermac/powermac_thermal.c +++ b/sys/powerpc/powermac/powermac_thermal.c @@ -94,13 +94,17 @@ pmac_therm_manage_fans(void) struct pmac_fan_le *fan; int average_excess, max_excess_zone, frac_excess; int nsens, nsens_zone; + int temp; if (!enable_pmac_thermal) return; /* Read all the sensors */ SLIST_FOREACH(sensor, &sensors, entries) { - sensor->last_val = sensor->sensor->read(sensor->sensor); + temp = sensor->sensor->read(sensor->sensor); + if (temp > 0) /* Use the previous temp in case of error */ + sensor->last_val = temp; + if (sensor->last_val > sensor->sensor->max_temp) { printf("WARNING: Current temperature (%s: %d.%d C) " "exceeds critical temperature (%d.%d C)! " |