aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/thermal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r--drivers/acpi/thermal.c80
1 files changed, 50 insertions, 30 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 99e6f1f8ea45..1c410ef859c6 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -954,7 +954,8 @@ static void acpi_thermal_check(void *data)
954/* sys I/F for generic thermal sysfs support */ 954/* sys I/F for generic thermal sysfs support */
955#define KELVIN_TO_MILLICELSIUS(t) (t * 100 - 273200) 955#define KELVIN_TO_MILLICELSIUS(t) (t * 100 - 273200)
956 956
957static int thermal_get_temp(struct thermal_zone_device *thermal, char *buf) 957static int thermal_get_temp(struct thermal_zone_device *thermal,
958 unsigned long *temp)
958{ 959{
959 struct acpi_thermal *tz = thermal->devdata; 960 struct acpi_thermal *tz = thermal->devdata;
960 int result; 961 int result;
@@ -966,25 +967,28 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, char *buf)
966 if (result) 967 if (result)
967 return result; 968 return result;
968 969
969 return sprintf(buf, "%ld\n", KELVIN_TO_MILLICELSIUS(tz->temperature)); 970 *temp = KELVIN_TO_MILLICELSIUS(tz->temperature);
971 return 0;
970} 972}
971 973
972static const char enabled[] = "kernel"; 974static const char enabled[] = "kernel";
973static const char disabled[] = "user"; 975static const char disabled[] = "user";
974static int thermal_get_mode(struct thermal_zone_device *thermal, 976static int thermal_get_mode(struct thermal_zone_device *thermal,
975 char *buf) 977 enum thermal_device_mode *mode)
976{ 978{
977 struct acpi_thermal *tz = thermal->devdata; 979 struct acpi_thermal *tz = thermal->devdata;
978 980
979 if (!tz) 981 if (!tz)
980 return -EINVAL; 982 return -EINVAL;
981 983
982 return sprintf(buf, "%s\n", tz->tz_enabled ? 984 *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED :
983 enabled : disabled); 985 THERMAL_DEVICE_DISABLED;
986
987 return 0;
984} 988}
985 989
986static int thermal_set_mode(struct thermal_zone_device *thermal, 990static int thermal_set_mode(struct thermal_zone_device *thermal,
987 const char *buf) 991 enum thermal_device_mode mode)
988{ 992{
989 struct acpi_thermal *tz = thermal->devdata; 993 struct acpi_thermal *tz = thermal->devdata;
990 int enable; 994 int enable;
@@ -995,9 +999,9 @@ static int thermal_set_mode(struct thermal_zone_device *thermal,
995 /* 999 /*
996 * enable/disable thermal management from ACPI thermal driver 1000 * enable/disable thermal management from ACPI thermal driver
997 */ 1001 */
998 if (!strncmp(buf, enabled, sizeof enabled - 1)) 1002 if (mode == THERMAL_DEVICE_ENABLED)
999 enable = 1; 1003 enable = 1;
1000 else if (!strncmp(buf, disabled, sizeof disabled - 1)) 1004 else if (mode == THERMAL_DEVICE_DISABLED)
1001 enable = 0; 1005 enable = 0;
1002 else 1006 else
1003 return -EINVAL; 1007 return -EINVAL;
@@ -1013,7 +1017,7 @@ static int thermal_set_mode(struct thermal_zone_device *thermal,
1013} 1017}
1014 1018
1015static int thermal_get_trip_type(struct thermal_zone_device *thermal, 1019static int thermal_get_trip_type(struct thermal_zone_device *thermal,
1016 int trip, char *buf) 1020 int trip, enum thermal_trip_type *type)
1017{ 1021{
1018 struct acpi_thermal *tz = thermal->devdata; 1022 struct acpi_thermal *tz = thermal->devdata;
1019 int i; 1023 int i;
@@ -1022,27 +1026,35 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
1022 return -EINVAL; 1026 return -EINVAL;
1023 1027
1024 if (tz->trips.critical.flags.valid) { 1028 if (tz->trips.critical.flags.valid) {
1025 if (!trip) 1029 if (!trip) {
1026 return sprintf(buf, "critical\n"); 1030 *type = THERMAL_TRIP_CRITICAL;
1031 return 0;
1032 }
1027 trip--; 1033 trip--;
1028 } 1034 }
1029 1035
1030 if (tz->trips.hot.flags.valid) { 1036 if (tz->trips.hot.flags.valid) {
1031 if (!trip) 1037 if (!trip) {
1032 return sprintf(buf, "hot\n"); 1038 *type = THERMAL_TRIP_HOT;
1039 return 0;
1040 }
1033 trip--; 1041 trip--;
1034 } 1042 }
1035 1043
1036 if (tz->trips.passive.flags.valid) { 1044 if (tz->trips.passive.flags.valid) {
1037 if (!trip) 1045 if (!trip) {
1038 return sprintf(buf, "passive\n"); 1046 *type = THERMAL_TRIP_PASSIVE;
1047 return 0;
1048 }
1039 trip--; 1049 trip--;
1040 } 1050 }
1041 1051
1042 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && 1052 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
1043 tz->trips.active[i].flags.valid; i++) { 1053 tz->trips.active[i].flags.valid; i++) {
1044 if (!trip) 1054 if (!trip) {
1045 return sprintf(buf, "active%d\n", i); 1055 *type = THERMAL_TRIP_ACTIVE;
1056 return 0;
1057 }
1046 trip--; 1058 trip--;
1047 } 1059 }
1048 1060
@@ -1050,7 +1062,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
1050} 1062}
1051 1063
1052static int thermal_get_trip_temp(struct thermal_zone_device *thermal, 1064static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
1053 int trip, char *buf) 1065 int trip, unsigned long *temp)
1054{ 1066{
1055 struct acpi_thermal *tz = thermal->devdata; 1067 struct acpi_thermal *tz = thermal->devdata;
1056 int i; 1068 int i;
@@ -1059,31 +1071,39 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
1059 return -EINVAL; 1071 return -EINVAL;
1060 1072
1061 if (tz->trips.critical.flags.valid) { 1073 if (tz->trips.critical.flags.valid) {
1062 if (!trip) 1074 if (!trip) {
1063 return sprintf(buf, "%ld\n", KELVIN_TO_MILLICELSIUS( 1075 *temp = KELVIN_TO_MILLICELSIUS(
1064 tz->trips.critical.temperature)); 1076 tz->trips.critical.temperature);
1077 return 0;
1078 }
1065 trip--; 1079 trip--;
1066 } 1080 }
1067 1081
1068 if (tz->trips.hot.flags.valid) { 1082 if (tz->trips.hot.flags.valid) {
1069 if (!trip) 1083 if (!trip) {
1070 return sprintf(buf, "%ld\n", KELVIN_TO_MILLICELSIUS( 1084 *temp = KELVIN_TO_MILLICELSIUS(
1071 tz->trips.hot.temperature)); 1085 tz->trips.hot.temperature);
1086 return 0;
1087 }
1072 trip--; 1088 trip--;
1073 } 1089 }
1074 1090
1075 if (tz->trips.passive.flags.valid) { 1091 if (tz->trips.passive.flags.valid) {
1076 if (!trip) 1092 if (!trip) {
1077 return sprintf(buf, "%ld\n", KELVIN_TO_MILLICELSIUS( 1093 *temp = KELVIN_TO_MILLICELSIUS(
1078 tz->trips.passive.temperature)); 1094 tz->trips.passive.temperature);
1095 return 0;
1096 }
1079 trip--; 1097 trip--;
1080 } 1098 }
1081 1099
1082 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && 1100 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
1083 tz->trips.active[i].flags.valid; i++) { 1101 tz->trips.active[i].flags.valid; i++) {
1084 if (!trip) 1102 if (!trip) {
1085 return sprintf(buf, "%ld\n", KELVIN_TO_MILLICELSIUS( 1103 *temp = KELVIN_TO_MILLICELSIUS(
1086 tz->trips.active[i].temperature)); 1104 tz->trips.active[i].temperature);
1105 return 0;
1106 }
1087 trip--; 1107 trip--;
1088 } 1108 }
1089 1109