Commit 9c864722 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI: thermal: Use library functions to obtain trip point temperature values

Modify the ACPI thermal driver to use functions from the ACPI thermal
library to obtain trip point temperature values instead of duplicating
them locally.

Among other things, this requires the functions in question to be
exported to it, because it can be built as a module.

It effectively changes the behavior of the driver to treat temperature
values out of the reasonable range (-55 centigrade to 175 centigrade) as
invalid, but there is no other expected functional impact.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 6908097a
...@@ -85,6 +85,11 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); ...@@ -85,6 +85,11 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context); acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context);
void acpi_scan_table_notify(void); void acpi_scan_table_notify(void);
int acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp);
int acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp);
int acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp);
int acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp);
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Device Node Initialization / Removal Device Node Initialization / Removal
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/units.h> #include <linux/units.h>
#include "internal.h"
#define ACPI_THERMAL_CLASS "thermal_zone" #define ACPI_THERMAL_CLASS "thermal_zone"
#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone"
#define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 #define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80
...@@ -188,24 +190,19 @@ static int active_trip_index(struct acpi_thermal *tz, ...@@ -188,24 +190,19 @@ static int active_trip_index(struct acpi_thermal *tz,
static long get_passive_temp(struct acpi_thermal *tz) static long get_passive_temp(struct acpi_thermal *tz)
{ {
unsigned long long tmp; int temp;
acpi_status status;
status = acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, &tmp); if (acpi_passive_trip_temp(tz->device, &temp))
if (ACPI_FAILURE(status))
return THERMAL_TEMP_INVALID; return THERMAL_TEMP_INVALID;
return tmp; return temp;
} }
static long get_active_temp(struct acpi_thermal *tz, int index) static long get_active_temp(struct acpi_thermal *tz, int index)
{ {
char method[] = { '_', 'A', 'C', '0' + index, '\0' }; int temp;
unsigned long long tmp;
acpi_status status;
status = acpi_evaluate_integer(tz->device->handle, method, NULL, &tmp); if (acpi_active_trip_temp(tz->device, index, &temp))
if (ACPI_FAILURE(status))
return THERMAL_TEMP_INVALID; return THERMAL_TEMP_INVALID;
/* /*
...@@ -215,10 +212,10 @@ static long get_active_temp(struct acpi_thermal *tz, int index) ...@@ -215,10 +212,10 @@ static long get_active_temp(struct acpi_thermal *tz, int index)
if (act > 0) { if (act > 0) {
unsigned long long override = celsius_to_deci_kelvin(act); unsigned long long override = celsius_to_deci_kelvin(act);
if (tmp > override) if (temp > override)
tmp = override; return override;
} }
return tmp; return temp;
} }
static void acpi_thermal_update_trip(struct acpi_thermal *tz, static void acpi_thermal_update_trip(struct acpi_thermal *tz,
...@@ -339,13 +336,12 @@ static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event) ...@@ -339,13 +336,12 @@ static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event)
dev_name(&adev->dev), event, 0); dev_name(&adev->dev), event, 0);
} }
static long acpi_thermal_get_critical_trip(struct acpi_thermal *tz) static int acpi_thermal_get_critical_trip(struct acpi_thermal *tz)
{ {
unsigned long long tmp; int temp;
acpi_status status;
if (crt > 0) { if (crt > 0) {
tmp = celsius_to_deci_kelvin(crt); temp = celsius_to_deci_kelvin(crt);
goto set; goto set;
} }
if (crt == -1) { if (crt == -1) {
...@@ -353,38 +349,34 @@ static long acpi_thermal_get_critical_trip(struct acpi_thermal *tz) ...@@ -353,38 +349,34 @@ static long acpi_thermal_get_critical_trip(struct acpi_thermal *tz)
return THERMAL_TEMP_INVALID; return THERMAL_TEMP_INVALID;
} }
status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp); if (acpi_critical_trip_temp(tz->device, &temp))
if (ACPI_FAILURE(status)) {
acpi_handle_debug(tz->device->handle, "No critical threshold\n");
return THERMAL_TEMP_INVALID; return THERMAL_TEMP_INVALID;
}
if (tmp <= 2732) { if (temp <= 2732) {
/* /*
* Below zero (Celsius) values clearly aren't right for sure, * Below zero (Celsius) values clearly aren't right for sure,
* so discard them as invalid. * so discard them as invalid.
*/ */
pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp); pr_info(FW_BUG "Invalid critical threshold (%d)\n", temp);
return THERMAL_TEMP_INVALID; return THERMAL_TEMP_INVALID;
} }
set: set:
acpi_handle_debug(tz->device->handle, "Critical threshold [%llu]\n", tmp); acpi_handle_debug(tz->device->handle, "Critical threshold [%d]\n", temp);
return tmp; return temp;
} }
static long acpi_thermal_get_hot_trip(struct acpi_thermal *tz) static int acpi_thermal_get_hot_trip(struct acpi_thermal *tz)
{ {
unsigned long long tmp; int temp;
acpi_status status;
status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp); if (acpi_hot_trip_temp(tz->device, &temp) || temp == THERMAL_TEMP_INVALID) {
if (ACPI_FAILURE(status)) {
acpi_handle_debug(tz->device->handle, "No hot threshold\n"); acpi_handle_debug(tz->device->handle, "No hot threshold\n");
return THERMAL_TEMP_INVALID; return THERMAL_TEMP_INVALID;
} }
acpi_handle_debug(tz->device->handle, "Hot threshold [%llu]\n", tmp); acpi_handle_debug(tz->device->handle, "Hot threshold [%d]\n", temp);
return tmp; return temp;
} }
static bool passive_trip_params_init(struct acpi_thermal *tz) static bool passive_trip_params_init(struct acpi_thermal *tz)
...@@ -1142,6 +1134,7 @@ static void __exit acpi_thermal_exit(void) ...@@ -1142,6 +1134,7 @@ static void __exit acpi_thermal_exit(void)
module_init(acpi_thermal_init); module_init(acpi_thermal_init);
module_exit(acpi_thermal_exit); module_exit(acpi_thermal_exit);
MODULE_IMPORT_NS(ACPI_THERMAL);
MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION("ACPI Thermal Zone Driver"); MODULE_DESCRIPTION("ACPI Thermal Zone Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -52,21 +52,25 @@ int acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp) ...@@ -52,21 +52,25 @@ int acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp)
return acpi_trip_temp(adev, obj_name, ret_temp); return acpi_trip_temp(adev, obj_name, ret_temp);
} }
EXPORT_SYMBOL_NS_GPL(acpi_active_trip_temp, ACPI_THERMAL);
int acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp) int acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp)
{ {
return acpi_trip_temp(adev, "_PSV", ret_temp); return acpi_trip_temp(adev, "_PSV", ret_temp);
} }
EXPORT_SYMBOL_NS_GPL(acpi_passive_trip_temp, ACPI_THERMAL);
int acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp) int acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp)
{ {
return acpi_trip_temp(adev, "_HOT", ret_temp); return acpi_trip_temp(adev, "_HOT", ret_temp);
} }
EXPORT_SYMBOL_NS_GPL(acpi_hot_trip_temp, ACPI_THERMAL);
int acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp) int acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp)
{ {
return acpi_trip_temp(adev, "_CRT", ret_temp); return acpi_trip_temp(adev, "_CRT", ret_temp);
} }
EXPORT_SYMBOL_NS_GPL(acpi_critical_trip_temp, ACPI_THERMAL);
static int thermal_temp(int error, int temp_decik, int *ret_temp) static int thermal_temp(int error, int temp_decik, int *ret_temp)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment