Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 May 2011 20:46:54 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r222463 - head/sys/powerpc/powermac
Message-ID:  <201105292046.p4TKksdv045882@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sun May 29 20:46:53 2011
New Revision: 222463
URL: http://svn.freebsd.org/changeset/base/222463

Log:
  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.

Modified:
  head/sys/powerpc/powermac/powermac_thermal.c

Modified: head/sys/powerpc/powermac/powermac_thermal.c
==============================================================================
--- head/sys/powerpc/powermac/powermac_thermal.c	Sun May 29 20:04:02 2011	(r222462)
+++ head/sys/powerpc/powermac/powermac_thermal.c	Sun May 29 20:46:53 2011	(r222463)
@@ -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)! "



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105292046.p4TKksdv045882>