summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorrpaulo <rpaulo@FreeBSD.org>2008-04-25 16:45:13 +0000
committerrpaulo <rpaulo@FreeBSD.org>2008-04-25 16:45:13 +0000
commit9047f0743d22eb0c15a4b22e7ca4b4a2e8d4dd69 (patch)
treeae1171eb094e4eba662085f54e850ffa5f3f4d51 /sys
parentb14c656c51b11d04dfc49637147be87152663252 (diff)
downloadFreeBSD-src-9047f0743d22eb0c15a4b22e7ca4b4a2e8d4dd69.zip
FreeBSD-src-9047f0743d22eb0c15a4b22e7ca4b4a2e8d4dd69.tar.gz
Initialize tz_active to a new constant TZ_ACTIVE_UNKNOWN and make no
assumptions about the state of the cooling devices. Instead, switch them off on init and, only after that, we are in TZ_ACTIVE_NONE. Submited by: Andriy Gapon <avg at icyb.net.ua> Reviewed by: njl
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpica/acpi_thermal.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c
index 4f90142..08cd15b 100644
--- a/sys/dev/acpica/acpi_thermal.c
+++ b/sys/dev/acpica/acpi_thermal.c
@@ -90,6 +90,7 @@ struct acpi_tz_softc {
int tz_temperature; /*Current temperature*/
int tz_active; /*Current active cooling*/
#define TZ_ACTIVE_NONE -1
+#define TZ_ACTIVE_UNKNOWN -2
int tz_requested; /*Minimum active cooling*/
int tz_thflags; /*Current temp-related flags*/
#define TZ_THFLAG_NONE 0
@@ -202,7 +203,7 @@ acpi_tz_attach(device_t dev)
sc->tz_dev = dev;
sc->tz_handle = acpi_get_handle(dev);
sc->tz_requested = TZ_ACTIVE_NONE;
- sc->tz_active = TZ_ACTIVE_NONE;
+ sc->tz_active = TZ_ACTIVE_UNKNOWN;
sc->tz_thflags = TZ_THFLAG_NONE;
sc->tz_cooling_proc = NULL;
sc->tz_cooling_proc_running = FALSE;
@@ -520,6 +521,7 @@ acpi_tz_monitor(void *Context)
* minimum cooling run time if requested.
*/
if (acpi_tz_min_runtime > 0 && sc->tz_active != TZ_ACTIVE_NONE &&
+ sc->tz_active != TZ_ACTIVE_UNKNOWN &&
(newactive == TZ_ACTIVE_NONE || newactive > sc->tz_active)) {
getnanotime(&curtime);
@@ -543,6 +545,23 @@ acpi_tz_monitor(void *Context)
newflags |= TZ_THFLAG_CRT;
/* If the active cooling state has changed, we have to switch things. */
+ if (sc->tz_active == TZ_ACTIVE_UNKNOWN) {
+ /*
+ * We don't know which cooling device is on or off,
+ * so stop them all, because we now know which
+ * should be on (if any).
+ */
+ for (i = 0; i < TZ_NUMLEVELS; i++) {
+ if (sc->tz_zone.al[i].Pointer != NULL) {
+ acpi_ForeachPackageObject(
+ (ACPI_OBJECT *)sc->tz_zone.al[i].Pointer,
+ acpi_tz_switch_cooler_off, sc);
+ }
+ }
+ /* now we know that all devices are off */
+ sc->tz_active = TZ_ACTIVE_NONE;
+ }
+
if (newactive != sc->tz_active) {
/* Turn off the cooling devices that are on, if any are */
if (sc->tz_active != TZ_ACTIVE_NONE)
OpenPOWER on IntegriCloud