static int tz_osl_proc_write_info ( struct file *file, const char *buffer, unsigned long count, void *data) { TZ_CONTEXT *tz = NULL; u32 state = 0; u32 size = 0; if (!buffer || (count==0) || !data) { goto end; } tz = (TZ_CONTEXT*)data; size = strlen(buffer); if (size < 4) goto end; /* Cooling preference: "scp=0" (active) or "scp=1" (passive) */ if (0 == strncmp(buffer, "scp=", 4)) { tz_set_cooling_preference(tz, (buffer[4] - '0')); } /* Polling frequency: "tzp=X" (poll every X [0-9] seconds) */ else if (0 == strncmp(buffer, "tzp=", 4)) { tz->policy.polling_freq = (buffer[4] - '0') * 10; tz_policy_check(tz); } end: return count; }
acpi_status tz_add_device ( BM_HANDLE device_handle, void **context) { acpi_status status = AE_OK; TZ_CONTEXT *tz = NULL; BM_DEVICE *device = NULL; acpi_handle tmp_handle = NULL; static u32 zone_count = 0; FUNCTION_TRACE("tz_add_device"); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding thermal zone [%02x].\n", device_handle)); if (!context || *context) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Invalid context for device [%02x].\n", device_handle)); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * Get information on this device. */ status = bm_get_device_info(device_handle, &device); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Allocate a new Thermal Zone device. */ tz = acpi_os_callocate(sizeof(TZ_CONTEXT)); if (!tz) { return_ACPI_STATUS(AE_NO_MEMORY); } tz->device_handle = device->handle; tz->acpi_handle = device->acpi_handle; /* TBD: How to manage 'uid' when zones are Pn_p? */ sprintf(tz->uid, "%d", zone_count++); /* * 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 = tz_get_temperature(tz); if (ACPI_FAILURE(status)) goto end; /* * Polling Frequency: * ------------------ * If _TZP doesn't exist use the OS default polling frequency. */ status = bm_evaluate_simple_integer(tz->acpi_handle, "_TZP", &(tz->policy.polling_freq)); if (ACPI_FAILURE(status)) { tz->policy.polling_freq = TZP; } status = AE_OK; /* * 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; status = tz_osl_add_device(tz); if (ACPI_FAILURE(status)) goto end; *context = tz; tz_print(tz); end: if (ACPI_FAILURE(status)) acpi_os_free(tz); return_ACPI_STATUS(status); }