patch-2.4.14 linux/drivers/acpi/ospm/thermal/tz.c

Next file: linux/drivers/acpi/ospm/thermal/tz_osl.c
Previous file: linux/drivers/acpi/ospm/system/sm_osl.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.13/linux/drivers/acpi/ospm/thermal/tz.c linux/drivers/acpi/ospm/thermal/tz.c
@@ -1,7 +1,7 @@
 /*****************************************************************************
  *
  * Module Name: tz.c
- *   $Revision: 40 $
+ *   $Revision: 44 $
  *
  *****************************************************************************/
 
@@ -23,22 +23,24 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * TBD: 1. Finish /proc interface (threshold values, _SCP changes, etc.)
- *	2. Update policy for ACPI 2.0 compliance
- *	3. Check for all required methods prior to enabling a threshold
- *	4. Support for multiple processors in a zone (passive cooling devices)
- */
 
 #include <acpi.h>
 #include <bm.h>
 #include "tz.h"
 
+
 #define _COMPONENT		ACPI_THERMAL
 	MODULE_NAME		("tz")
 
 
 /****************************************************************************
+ *                                  Globals
+ ****************************************************************************/
+
+extern int TZP;
+
+
+/****************************************************************************
  *                            Internal Functions
  ****************************************************************************/
 
@@ -46,73 +48,63 @@
  *
  * FUNCTION:    tz_print
  *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION: Prints out information on a specific thermal zone.
- *
  ****************************************************************************/
 
 void
 tz_print (
-	TZ_CONTEXT		*thermal_zone)
+	TZ_CONTEXT		*tz)
 {
 #ifdef ACPI_DEBUG
 	acpi_buffer		buffer;
 	u32			i,j = 0;
-	TZ_THRESHOLD            *threshold = NULL;
+	TZ_THRESHOLDS		*thresholds = NULL;
 
-	PROC_NAME("tz_print");
+	FUNCTION_TRACE("tz_print");
 
-	if (!thermal_zone) {
+	if (!tz)
 		return;
-	}
+
+	thresholds = &(tz->policy.thresholds);
 
 	buffer.length = 256;
 	buffer.pointer = acpi_os_callocate(buffer.length);
-	if (!buffer.pointer) {
+	if (!buffer.pointer)
 		return;
-	}
 
 	/*
 	 * Get the full pathname for this ACPI object.
 	 */
-	acpi_get_name(thermal_zone->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
+	acpi_get_name(tz->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
 
 	/*
 	 * Print out basic thermal zone information.
 	 */
 	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "+------------------------------------------------------------\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Thermal_zone[%02x]:[%p] %s\n", thermal_zone->device_handle, thermal_zone->acpi_handle, buffer.pointer));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   temperature[%d] state[%08x]\n", thermal_zone->policy.temperature, thermal_zone->policy.state));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   cooling_mode[%08x] polling_freq[%d]\n", thermal_zone->policy.cooling_mode, thermal_zone->policy.polling_freq));
-
-	for (i=0; i<thermal_zone->policy.threshold_list.count; i++) {
-
-		threshold = &(thermal_zone->policy.threshold_list.thresholds[i]);
-
-		switch (threshold->type) {
-		case TZ_THRESHOLD_CRITICAL:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   critical[%d]\n", threshold->temperature));
-			break;
-		case TZ_THRESHOLD_PASSIVE:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   passive[%d]: tc1[%d] tc2[%d] tsp[%d]\n", threshold->temperature, thermal_zone->policy.passive.tc1, thermal_zone->policy.passive.tc2, thermal_zone->policy.passive.tsp));
-			break;
-		case TZ_THRESHOLD_ACTIVE:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   active[%d]: index[%d]\n", threshold->temperature, threshold->index));
-			break;
-		default:
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   unknown[%d]\n", threshold->temperature));
-			break;
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "| Thermal_zone[%02x]:[%p] %s\n", tz->device_handle, tz->acpi_handle, (char*)buffer.pointer));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   temperature[%d] state[%08x]\n", tz->policy.temperature, tz->policy.state));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   cooling_mode[%08x] polling_freq[%d]\n", tz->policy.cooling_mode, tz->policy.polling_freq));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   critical[%d]\n", thresholds->critical.temperature));
+	if (thresholds->hot.is_valid)
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   hot[%d]\n", thresholds->hot.temperature));
+	if (thresholds->passive.is_valid) {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   passive[%d]: tc1[%d] tc2[%d] tsp[%d]\n", thresholds->passive.temperature, thresholds->passive.tc1, thresholds->passive.tc2, thresholds->passive.tsp));
+		if (thresholds->passive.devices.count > 0) {
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|     devices"));
+			for (j=0; (j<thresholds->passive.devices.count && j<10); j++) {
+				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "[%02x]", thresholds->passive.devices.handles[j]));
+			}
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
 		}
-
-		if (threshold->cooling_devices.count > 0) {
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|     cooling_devices"));
-			for (j=0; (j<threshold->cooling_devices.count && j<10); j++) {
-				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "[%02x]", threshold->cooling_devices.handles[j]));
+	}
+	for (i=0; i<TZ_MAX_ACTIVE_THRESHOLDS; i++) {
+		if (!thresholds->active[i].is_valid)
+			break;
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|   active[%d]: index[%d]\n", thresholds->active[i].temperature, i));
+		if (thresholds->active[i].devices.count > 0) {
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "|     devices"));
+			for (j=0; (j<thresholds->active[i].devices.count && j<10); j++) {
+				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "[%02x]", thresholds->active[i].devices.handles[j]));
 			}
-			
 			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
 		}
 	}
@@ -130,32 +122,29 @@
  *
  * FUNCTION:    tz_get_temperaturee
  *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
 
 acpi_status
 tz_get_temperature (
-	TZ_CONTEXT              *thermal_zone,
-	u32                     *temperature)
+	TZ_CONTEXT		*tz)
 {
 	acpi_status             status = AE_OK;
 
 	FUNCTION_TRACE("tz_get_temperature");
 
-	if (!thermal_zone || !temperature) {
+	if (!tz) {
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
 	/*
-	 * Evaluate the _TMP driver method to get the current temperature.
+	 * Evaluate the _TMP method to get the current temperature.
 	 */
-	status = bm_evaluate_simple_integer(thermal_zone->acpi_handle,
-		"_TMP", temperature);
+	status = bm_evaluate_simple_integer(tz->acpi_handle, "_TMP", &(tz->policy.temperature));
+	if (ACPI_FAILURE(status)) {
+		return_ACPI_STATUS(status);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %d d_k\n", tz->policy.temperature));
 
 	return_ACPI_STATUS(status);
 }
@@ -165,17 +154,11 @@
  *
  * FUNCTION:    tz_set_cooling_preference
  *
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
 
 acpi_status
 tz_set_cooling_preference (
-	TZ_CONTEXT              *thermal_zone,
+	TZ_CONTEXT              *tz,
 	TZ_COOLING_MODE         cooling_mode)
 {
 	acpi_status             status = AE_OK;
@@ -184,8 +167,7 @@
 
 	FUNCTION_TRACE("tz_set_cooling_preference");
 
-	if (!thermal_zone || ((cooling_mode != TZ_COOLING_MODE_ACTIVE) &&
-		(cooling_mode != TZ_COOLING_MODE_PASSIVE))) {
+	if (!tz || ((cooling_mode != TZ_COOLING_MODE_ACTIVE) && (cooling_mode != TZ_COOLING_MODE_PASSIVE))) {
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
@@ -193,204 +175,143 @@
 	 * Build the argument list, which simply consists of the current
 	 * cooling preference.
 	 */
-	MEMSET(&arg_list, 0, sizeof(acpi_object));
+	memset(&arg_list, 0, sizeof(acpi_object));
 	arg_list.count = 1;
 	arg_list.pointer = &arg0;
 
-	MEMSET(&arg0, 0, sizeof(acpi_object));
+	memset(&arg0, 0, sizeof(acpi_object));
 	arg0.type = ACPI_TYPE_INTEGER;
 	arg0.integer.value = cooling_mode;
 
 	/*
 	 * Evaluate "_SCP" - setting the new cooling preference.
 	 */
-	status = acpi_evaluate_object(thermal_zone->acpi_handle, "_SCP",
-		&arg_list, NULL);
+	status = acpi_evaluate_object(tz->acpi_handle, "_SCP", &arg_list, NULL);
+	if (ACPI_FAILURE(status)) {
+		tz->policy.cooling_mode = -1;
+		return_ACPI_STATUS(status);
+	}
+
+	tz->policy.cooling_mode = cooling_mode;
 
 	return_ACPI_STATUS(status);
 }
 
 
-/***************************************************************************
- *
- * FUNCTION:    tz_get_single_threshold
- *
- * PARAMETERS:
- *
- * RETURN:
+/****************************************************************************
  *
- * DESCRIPTION:
+ * FUNCTION:    tz_get_thresholds
  *
  ****************************************************************************/
 
 acpi_status
-tz_get_single_threshold (
-	TZ_CONTEXT              *thermal_zone,
-	TZ_THRESHOLD            *threshold)
+tz_get_thresholds (
+	TZ_CONTEXT		*tz)
 {
-	acpi_status             status = AE_OK;
+	acpi_status		status = AE_OK;
+	TZ_THRESHOLDS		*thresholds = NULL;
+	u32			value = 0;
+	u32                     i = 0;
 
-	FUNCTION_TRACE("tz_get_single_threshold");
+	FUNCTION_TRACE("acpi_tz_get_thresholds");
 
-	if (!thermal_zone || !threshold) {
+	if (!tz) {
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
-	switch (threshold->type) {
+	thresholds = &(tz->policy.thresholds);
 
-	/*
-	 * Critical Threshold:
-	 * -------------------
-	 */
-	case TZ_THRESHOLD_CRITICAL:
-		threshold->index = 0;
-		threshold->cooling_devices.count = 0;
-		status = bm_evaluate_simple_integer(
-			thermal_zone->acpi_handle, "_CRT",
-			&(threshold->temperature));
-		break;
-
-	/*
-	 * Passive Threshold:
-	 * ------------------
-	 * Evaluate _PSV to get the threshold temperature and _PSL to get
-	 * references to all passive cooling devices.
-	 */
-	case TZ_THRESHOLD_PASSIVE:
-		threshold->index = 0;
-		threshold->cooling_devices.count = 0;
-		status = bm_evaluate_simple_integer(
-			thermal_zone->acpi_handle, "_PSV",
-			&(threshold->temperature));
-		if (ACPI_SUCCESS(status)) {
-			status = bm_evaluate_reference_list(
-				thermal_zone->acpi_handle, "_PSL",
-				&(threshold->cooling_devices));
-		}
+	/* Critical Shutdown (required) */
 
-		break;
-
-	/*
-	 * Active Thresholds:
-	 * ------------------
-	 * Evaluate _ACx to get all threshold temperatures, and _ALx to get
-	 * references to all passive cooling devices.
-	 */
-	case TZ_THRESHOLD_ACTIVE:
-		 {
-			char object_name[5] = {'_','A', 'C',
-				('0'+threshold->index),'\0'};
-			status = bm_evaluate_simple_integer(
-				thermal_zone->acpi_handle, object_name,
-				&(threshold->temperature));
-			if (ACPI_SUCCESS(status)) {
-				object_name[2] = 'L';
-				status = bm_evaluate_reference_list(
-					thermal_zone->acpi_handle,
-					object_name,
-					&(threshold->cooling_devices));
-			}
-		}
-		break;
+	status = bm_evaluate_simple_integer(tz->acpi_handle, "_CRT", &value);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
+		return_ACPI_STATUS(status);
+	}
+	else {
+		thresholds->critical.temperature = value;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found critical threshold [%d]\n", thresholds->critical.temperature));
 
-	default:
-		status = AE_SUPPORT;
-		break;
 	}
 
-	return_ACPI_STATUS(status);
-}
+	/* Critical Sleep (optional) */
 
+	status = bm_evaluate_simple_integer(tz->acpi_handle, "_HOT", &value);
+	if (ACPI_FAILURE(status)) {
+		thresholds->hot.is_valid = 0;
+		thresholds->hot.temperature = 0;
+	}
+	else {
+		thresholds->hot.is_valid = 1;
+		thresholds->hot.temperature = value;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%d]\n", thresholds->hot.temperature));
+	}
 
-/****************************************************************************
- *
- * FUNCTION:    tz_get_thresholds
- *
- * PARAMETERS:  thermal_zone          - Identifies the thermal zone to parse.
- *              buffer      - Output buffer.
- *
- * RETURN:      acpi_status result code.
- *
- * DESCRIPTION: Builds a TZ_THRESHOLD_LIST structure containing information
- *              on all thresholds for a given thermal zone.
- *
- * NOTES:       The current design limits the number of cooling devices
- *              per theshold to the value specified by BM_MAX_HANDLES.
- *              This simplifies parsing of thresholds by allowing a maximum
- *              threshold list size to be computed (and enforced) -- which
- *              allows all thresholds to be parsed in a single pass (since
- *              memory must be contiguous when returned in the acpi_buffer).
- *
- ****************************************************************************/
+	/* Passive: Processors (optional) */
 
-acpi_status
-tz_get_thresholds (
-	TZ_CONTEXT              *thermal_zone,
-	TZ_THRESHOLD_LIST       *threshold_list)
-{
-	acpi_status             status = AE_OK;
-	TZ_THRESHOLD            *threshold = NULL;
-	u32                     i = 0;
+	status = bm_evaluate_simple_integer(tz->acpi_handle, "_PSV", &value);
+	if (ACPI_FAILURE(status)) {
+		thresholds->passive.is_valid = 0;
+		thresholds->passive.temperature = 0;
+	}
+	else {
+		thresholds->passive.is_valid = 1;
+		thresholds->passive.temperature = value;
 
-	FUNCTION_TRACE("tz_get_thresholds");
+		status = bm_evaluate_simple_integer(tz->acpi_handle, "_TC1", &value);
+		if (ACPI_FAILURE(status)) {
+			thresholds->passive.is_valid = 0;
+		}
+		thresholds->passive.tc1 = value;
 
-	if (!thermal_zone || !threshold_list) {
-		return_ACPI_STATUS(AE_BAD_PARAMETER);
-	}
+		status = bm_evaluate_simple_integer(tz->acpi_handle, "_TC2", &value);
+		if (ACPI_FAILURE(status)) {
+			thresholds->passive.is_valid = 0;
+		}
+		thresholds->passive.tc2 = value;
 
-	threshold_list->count = 0;
+		status = bm_evaluate_simple_integer(tz->acpi_handle, "_TSP", &value);
+		if (ACPI_FAILURE(status)) {
+			thresholds->passive.is_valid = 0;
+		}
+		thresholds->passive.tsp = value;
 
-	/*
-	 * Critical threshold:
-	 * -------------------
-	 * Every thermal zone must have one!
-	 */
-	threshold = &(threshold_list->thresholds[threshold_list->count]);
-	threshold->type = TZ_THRESHOLD_CRITICAL;
+		status = bm_evaluate_reference_list(tz->acpi_handle, "_PSL", &(thresholds->passive.devices));
+		if (ACPI_FAILURE(status)) {
+			thresholds->passive.is_valid = 0;
+		}
 
-	status = tz_get_single_threshold(thermal_zone, threshold);
-	if (ACPI_SUCCESS(status)) {
-		(threshold_list->count)++;
-	}
-	else {
-		return_ACPI_STATUS(status);
+		if (thresholds->passive.is_valid) {
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%d]\n", thresholds->passive.temperature));
+		}
+		else {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid passive threshold\n"));
+		}
 	}
 
+	/* Active: Fans, etc. (optional) */
 
-	/*
-	 * Passive threshold:
-	 * ------------------
-	 */
-	threshold = &(threshold_list->thresholds[threshold_list->count]);
-	threshold->type = TZ_THRESHOLD_PASSIVE;
+	for (i=0; i<TZ_MAX_ACTIVE_THRESHOLDS; i++) {
 
-	status = tz_get_single_threshold(thermal_zone, threshold);
-	if (ACPI_SUCCESS(status)) {
-		(threshold_list->count)++;
-	}
+		char name[5] = {'_','A','C',('0'+i),'\0'};
 
-	/*
-	 * Active threshold:
-	 * -----------------
-	 * Note that active thresholds are sorted by index (e.g. _AC0,
-	 * _AC1, ...), and thus from highest (_AC0) to lowest (_AC9)
-	 * temperature.
-	 */
-	for (i = 0; i < TZ_MAX_ACTIVE_THRESHOLDS; i++) {
+		status = bm_evaluate_simple_integer(tz->acpi_handle, name, &value);
+		if (ACPI_FAILURE(status)) {
+			thresholds->active[i].is_valid = 0;
+			thresholds->active[i].temperature = 0;
+			break;
+		}
 
-		threshold = &(threshold_list->thresholds[threshold_list->count]);
-		threshold->type = TZ_THRESHOLD_ACTIVE;
-		threshold->index = i;
+		thresholds->active[i].temperature = value;
+		name[2] = 'L';
 
-		status = tz_get_single_threshold(thermal_zone, threshold);
+		status = bm_evaluate_reference_list(tz->acpi_handle, name, &(thresholds->active[i].devices));
 		if (ACPI_SUCCESS(status)) {
-			(threshold_list->count)++;
+			thresholds->active[i].is_valid = 1;
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found active threshold [%d]:[%d]\n", i, thresholds->active[i].temperature));
 		}
 		else {
-			threshold->type = TZ_THRESHOLD_UNKNOWN;
-			threshold->index = 0;
-			thermal_zone->policy.active.threshold_count = i;
-			break;
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid active threshold [%d]\n", i));
 		}
 	}
 
@@ -402,12 +323,6 @@
  *
  * FUNCTION:    tz_add_device
  *
- * PARAMETERS:  <none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
 
 acpi_status
@@ -416,7 +331,7 @@
 	void                    **context)
 {
 	acpi_status             status = AE_OK;
-	TZ_CONTEXT              *thermal_zone = NULL;
+	TZ_CONTEXT              *tz = NULL;
 	BM_DEVICE		*device = NULL;
 	acpi_handle             tmp_handle = NULL;
 	static u32		zone_count = 0;
@@ -441,50 +356,67 @@
 	/*
 	 * Allocate a new Thermal Zone device.
 	 */
-	thermal_zone = acpi_os_callocate(sizeof(TZ_CONTEXT));
-	if (!thermal_zone) {
-		return AE_NO_MEMORY;
+	tz = acpi_os_callocate(sizeof(TZ_CONTEXT));
+	if (!tz) {
+		return_ACPI_STATUS(AE_NO_MEMORY);
 	}
 
-	thermal_zone->device_handle = device->handle;
-	thermal_zone->acpi_handle = device->acpi_handle;
+	tz->device_handle = device->handle;
+	tz->acpi_handle = device->acpi_handle;
 
 	/* TBD: How to manage 'uid' when zones are Pn_p? */
-	sprintf(thermal_zone->uid, "%d", zone_count++);
+	sprintf(tz->uid, "%d", zone_count++);
 
 	/*
-	 * _TMP?
-	 * -----
+	 * Temperature:
+	 * ------------
+	 * Make sure we can read the zone's current temperature (_TMP).
+	 * If we can't, there's no use in doing any policy (abort).
 	 */
-	status = acpi_get_handle(thermal_zone->acpi_handle, "_TMP",
-		&tmp_handle);
-	if (ACPI_FAILURE(status)) {
+	status = tz_get_temperature(tz);
+	if (ACPI_FAILURE(status))
 		goto end;
-	}
 
 	/*
-	 * Initialize Policy:
+	 * Polling Frequency:
 	 * ------------------
-	 * TBD: Move all thermal zone policy to user-mode daemon...
+	 * If _TZP doesn't exist use the OS default polling frequency.
 	 */
-	status = tz_policy_add_device(thermal_zone);
+	status = bm_evaluate_simple_integer(tz->acpi_handle, "_TZP", &(tz->policy.polling_freq));
 	if (ACPI_FAILURE(status)) {
-		goto end;
+		tz->policy.polling_freq = TZP;
 	}
+	status = AE_OK;
 
-	status = tz_osl_add_device(thermal_zone);
-	if (ACPI_FAILURE(status)) {
+	/*
+	 * Cooling Preference:
+	 * -------------------
+	 * Default to ACTIVE (noisy) cooling until policy decides otherwise.
+	 * Note that _SCP is optional.
+	 */
+	tz_set_cooling_preference(tz, TZ_COOLING_MODE_ACTIVE);
+
+	/*
+	 * Start Policy:
+	 * -------------
+	 * Thermal policy is included in the kernel (this driver) because
+	 * of the critical role it plays in avoiding nuclear meltdown. =O
+	 */
+	status = tz_policy_add_device(tz);
+	if (ACPI_FAILURE(status))
 		goto end;
-	}
 
-	*context = thermal_zone;
+	status = tz_osl_add_device(tz);
+	if (ACPI_FAILURE(status))
+		goto end;
 
-	tz_print(thermal_zone);
+	*context = tz;
+
+	tz_print(tz);
 
 end:
-	if (ACPI_FAILURE(status)) {
-		acpi_os_free(thermal_zone);
-	}
+	if (ACPI_FAILURE(status))
+		acpi_os_free(tz);
 
 	return_ACPI_STATUS(status);
 }
@@ -494,12 +426,6 @@
  *
  * FUNCTION:    tz_remove_device
  *
- * PARAMETERS:  <none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
 
 acpi_status
@@ -507,7 +433,7 @@
 	void			**context)
 {
 	acpi_status		status = AE_OK;
-	TZ_CONTEXT		*thermal_zone = NULL;
+	TZ_CONTEXT		*tz = NULL;
 
 	FUNCTION_TRACE("tz_remove_device");
 
@@ -515,23 +441,23 @@
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
-	thermal_zone = (TZ_CONTEXT*)(*context);
+	tz = (TZ_CONTEXT*)(*context);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing thermal zone [%02x].\n", thermal_zone->device_handle));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing thermal zone [%02x].\n", tz->device_handle));
 
-	status = tz_osl_remove_device(thermal_zone);
+	status = tz_osl_remove_device(tz);
 
 	/*
 	 * Remove Policy:
 	 * --------------
 	 * TBD: Move all thermal zone policy to user-mode daemon...
 	 */
-	status = tz_policy_remove_device(thermal_zone);
+	status = tz_policy_remove_device(tz);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
 	}
 
-	acpi_os_free(thermal_zone);
+	acpi_os_free(tz);
 
 	return_ACPI_STATUS(status);
 }
@@ -545,12 +471,6 @@
  *
  * FUNCTION:    tz_initialize
  *
- * PARAMETERS:  <none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
 
 acpi_status
@@ -562,8 +482,8 @@
 
 	FUNCTION_TRACE("tz_initialize");
 
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
+	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
+	memset(&driver, 0, sizeof(BM_DRIVER));
 
 	/*
 	 * Register driver for thermal zone devices.
@@ -583,12 +503,6 @@
  *
  * FUNCTION:    tz_terminate
  *
- * PARAMETERS:  <none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
 
 acpi_status
@@ -600,8 +514,8 @@
 
 	FUNCTION_TRACE("tz_terminate");
 
-	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
-	MEMSET(&driver, 0, sizeof(BM_DRIVER));
+	memset(&criteria, 0, sizeof(BM_DEVICE_ID));
+	memset(&driver, 0, sizeof(BM_DRIVER));
 
 	/*
 	 * Unregister driver for thermal zone devices.
@@ -621,13 +535,8 @@
  *
  * FUNCTION:    tz_notify
  *
- * PARAMETERS:  <none>
- *
- * RETURN:	
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
+
 acpi_status
 tz_notify (
 	BM_NOTIFY               notify_type,
@@ -635,7 +544,7 @@
 	void                    **context)
 {
 	acpi_status             status = AE_OK;
-	TZ_CONTEXT		*thermal_zone = NULL;
+	TZ_CONTEXT		*tz = NULL;
 
 	FUNCTION_TRACE("tz_notify");
 
@@ -643,7 +552,7 @@
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
-	thermal_zone = (TZ_CONTEXT*)*context;
+	tz = (TZ_CONTEXT*)*context;
 
 	switch (notify_type) {
 
@@ -657,40 +566,29 @@
 
 	case TZ_NOTIFY_TEMPERATURE_CHANGE:
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Temperature (_TMP) change event detected.\n"));
-		/* -------------------------------------------- */
-		/* TBD: Remove when policy moves to user-mode. */
 		tz_policy_check(*context);
-		/* -------------------------------------------- */
-		status = tz_get_temperature(thermal_zone,
-			&(thermal_zone->policy.temperature));
+		status = tz_get_temperature(tz);
 		if (ACPI_SUCCESS(status)) {
-			status = tz_osl_generate_event(notify_type,
-				thermal_zone);
+			status = tz_osl_generate_event(notify_type, tz);
 		}
 		break;
 
 	case TZ_NOTIFY_THRESHOLD_CHANGE:
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Threshold (_SCP) change event detected.\n"));
-		/* -------------------------------------------- */
-		/* TBD: Remove when policy moves to user-mode. */
-		status = tz_policy_remove_device(thermal_zone);
+		status = tz_policy_remove_device(tz);
 		if (ACPI_SUCCESS(status)) {
-			status = tz_policy_add_device(thermal_zone);
+			status = tz_policy_add_device(tz);
 		}
-		/* -------------------------------------------- */
-		status = tz_osl_generate_event(notify_type, thermal_zone);
+		status = tz_osl_generate_event(notify_type, tz);
 		break;
 
 	case TZ_NOTIFY_DEVICE_LISTS_CHANGE:
 		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Device lists (_ALx, _PSL, _TZD) change event detected.\n"));
-		/* -------------------------------------------- */
-		/* TBD: Remove when policy moves to user-mode. */
-		status = tz_policy_remove_device(thermal_zone);
+		status = tz_policy_remove_device(tz);
 		if (ACPI_SUCCESS(status)) {
-			status = tz_policy_add_device(thermal_zone);
+			status = tz_policy_add_device(tz);
 		}
-		/* -------------------------------------------- */
-		status = tz_osl_generate_event(notify_type, thermal_zone);
+		status = tz_osl_generate_event(notify_type, tz);
 		break;
 
 	default:
@@ -706,12 +604,6 @@
  *
  * FUNCTION:    tz_request
  *
- * PARAMETERS:
- *
- * RETURN:      Exception code.
- *
- * DESCRIPTION:
- *
  ****************************************************************************/
 
 acpi_status
@@ -720,7 +612,7 @@
 	void                    *context)
 {
 	acpi_status             status = AE_OK;
-	TZ_CONTEXT              *thermal_zone = NULL;
+	TZ_CONTEXT              *tz = NULL;
 
 	FUNCTION_TRACE("tz_request");
 
@@ -731,7 +623,7 @@
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
-	thermal_zone = (TZ_CONTEXT*)context;
+	tz = (TZ_CONTEXT*)context;
 
 	/*
 	 * Handle request:

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)