From edbb029388dbf6767b29eb7b03ca6e5278a328cc Mon Sep 17 00:00:00 2001 From: Rui Paulo Date: Fri, 25 Apr 2008 16:45:13 +0000 Subject: [PATCH] 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 Reviewed by: njl --- sys/dev/acpica/acpi_thermal.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index 4f901427e62f..08cd15be89cd 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)