aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/thermal.c436
1 files changed, 1 insertions, 435 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 2f8f17131d9f..5a27b0a31315 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -37,12 +37,6 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/types.h> 39#include <linux/types.h>
40
41#ifdef CONFIG_ACPI_PROCFS
42#include <linux/proc_fs.h>
43#include <linux/seq_file.h>
44#endif
45
46#include <linux/jiffies.h> 40#include <linux/jiffies.h>
47#include <linux/kmod.h> 41#include <linux/kmod.h>
48#include <linux/reboot.h> 42#include <linux/reboot.h>
@@ -195,61 +189,6 @@ struct acpi_thermal {
195 struct mutex lock; 189 struct mutex lock;
196}; 190};
197 191
198#ifdef CONFIG_ACPI_PROCFS
199static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
200static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
201static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
202static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
203static ssize_t acpi_thermal_write_cooling_mode(struct file *,
204 const char __user *, size_t,
205 loff_t *);
206static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
207static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
208 size_t, loff_t *);
209
210static const struct file_operations acpi_thermal_state_fops = {
211 .owner = THIS_MODULE,
212 .open = acpi_thermal_state_open_fs,
213 .read = seq_read,
214 .llseek = seq_lseek,
215 .release = single_release,
216};
217
218static const struct file_operations acpi_thermal_temp_fops = {
219 .owner = THIS_MODULE,
220 .open = acpi_thermal_temp_open_fs,
221 .read = seq_read,
222 .llseek = seq_lseek,
223 .release = single_release,
224};
225
226static const struct file_operations acpi_thermal_trip_fops = {
227 .owner = THIS_MODULE,
228 .open = acpi_thermal_trip_open_fs,
229 .read = seq_read,
230 .llseek = seq_lseek,
231 .release = single_release,
232};
233
234static const struct file_operations acpi_thermal_cooling_fops = {
235 .owner = THIS_MODULE,
236 .open = acpi_thermal_cooling_open_fs,
237 .read = seq_read,
238 .write = acpi_thermal_write_cooling_mode,
239 .llseek = seq_lseek,
240 .release = single_release,
241};
242
243static const struct file_operations acpi_thermal_polling_fops = {
244 .owner = THIS_MODULE,
245 .open = acpi_thermal_polling_open_fs,
246 .read = seq_read,
247 .write = acpi_thermal_write_polling,
248 .llseek = seq_lseek,
249 .release = single_release,
250};
251#endif /* CONFIG_ACPI_PROCFS*/
252
253/* -------------------------------------------------------------------------- 192/* --------------------------------------------------------------------------
254 Thermal Zone Management 193 Thermal Zone Management
255 -------------------------------------------------------------------------- */ 194 -------------------------------------------------------------------------- */
@@ -958,358 +897,6 @@ static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
958 897
959 898
960/* -------------------------------------------------------------------------- 899/* --------------------------------------------------------------------------
961 FS Interface (/proc)
962 -------------------------------------------------------------------------- */
963#ifdef CONFIG_ACPI_PROCFS
964static struct proc_dir_entry *acpi_thermal_dir;
965
966static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
967{
968 struct acpi_thermal *tz = seq->private;
969
970
971 if (!tz)
972 goto end;
973
974 seq_puts(seq, "state: ");
975
976 if (!tz->state.critical && !tz->state.hot && !tz->state.passive
977 && !tz->state.active)
978 seq_puts(seq, "ok\n");
979 else {
980 if (tz->state.critical)
981 seq_puts(seq, "critical ");
982 if (tz->state.hot)
983 seq_puts(seq, "hot ");
984 if (tz->state.passive)
985 seq_puts(seq, "passive ");
986 if (tz->state.active)
987 seq_printf(seq, "active[%d]", tz->state.active_index);
988 seq_puts(seq, "\n");
989 }
990
991 end:
992 return 0;
993}
994
995static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
996{
997 return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data);
998}
999
1000static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
1001{
1002 int result = 0;
1003 struct acpi_thermal *tz = seq->private;
1004
1005
1006 if (!tz)
1007 goto end;
1008
1009 result = acpi_thermal_get_temperature(tz);
1010 if (result)
1011 goto end;
1012
1013 seq_printf(seq, "temperature: %ld C\n",
1014 KELVIN_TO_CELSIUS(tz->temperature));
1015
1016 end:
1017 return 0;
1018}
1019
1020static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
1021{
1022 return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data);
1023}
1024
1025static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
1026{
1027 struct acpi_thermal *tz = seq->private;
1028 struct acpi_device *device;
1029 acpi_status status;
1030
1031 int i = 0;
1032 int j = 0;
1033
1034
1035 if (!tz)
1036 goto end;
1037
1038 if (tz->trips.critical.flags.valid)
1039 seq_printf(seq, "critical (S5): %ld C%s",
1040 KELVIN_TO_CELSIUS(tz->trips.critical.temperature),
1041 nocrt ? " <disabled>\n" : "\n");
1042
1043 if (tz->trips.hot.flags.valid)
1044 seq_printf(seq, "hot (S4): %ld C%s",
1045 KELVIN_TO_CELSIUS(tz->trips.hot.temperature),
1046 nocrt ? " <disabled>\n" : "\n");
1047
1048 if (tz->trips.passive.flags.valid) {
1049 seq_printf(seq,
1050 "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
1051 KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
1052 tz->trips.passive.tc1, tz->trips.passive.tc2,
1053 tz->trips.passive.tsp);
1054 for (j = 0; j < tz->trips.passive.devices.count; j++) {
1055 status = acpi_bus_get_device(tz->trips.passive.devices.
1056 handles[j], &device);
1057 seq_printf(seq, "%4.4s ", status ? "" :
1058 acpi_device_bid(device));
1059 }
1060 seq_puts(seq, "\n");
1061 } else {
1062 seq_printf(seq, "passive (forced):");
1063 if (tz->thermal_zone->forced_passive)
1064 seq_printf(seq, " %i C\n",
1065 tz->thermal_zone->forced_passive / 1000);
1066 else
1067 seq_printf(seq, "<not set>\n");
1068 }
1069
1070 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
1071 if (!(tz->trips.active[i].flags.valid))
1072 break;
1073 seq_printf(seq, "active[%d]: %ld C: devices=",
1074 i,
1075 KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
1076 for (j = 0; j < tz->trips.active[i].devices.count; j++){
1077 status = acpi_bus_get_device(tz->trips.active[i].
1078 devices.handles[j],
1079 &device);
1080 seq_printf(seq, "%4.4s ", status ? "" :
1081 acpi_device_bid(device));
1082 }
1083 seq_puts(seq, "\n");
1084 }
1085
1086 end:
1087 return 0;
1088}
1089
1090static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
1091{
1092 return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data);
1093}
1094
1095static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
1096{
1097 struct acpi_thermal *tz = seq->private;
1098
1099
1100 if (!tz)
1101 goto end;
1102
1103 if (!tz->flags.cooling_mode)
1104 seq_puts(seq, "<setting not supported>\n");
1105 else
1106 seq_puts(seq, "0 - Active; 1 - Passive\n");
1107
1108 end:
1109 return 0;
1110}
1111
1112static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
1113{
1114 return single_open(file, acpi_thermal_cooling_seq_show,
1115 PDE(inode)->data);
1116}
1117
1118static ssize_t
1119acpi_thermal_write_cooling_mode(struct file *file,
1120 const char __user * buffer,
1121 size_t count, loff_t * ppos)
1122{
1123 struct seq_file *m = file->private_data;
1124 struct acpi_thermal *tz = m->private;
1125 int result = 0;
1126 char mode_string[12] = { '\0' };
1127
1128
1129 if (!tz || (count > sizeof(mode_string) - 1))
1130 return -EINVAL;
1131
1132 if (!tz->flags.cooling_mode)
1133 return -ENODEV;
1134
1135 if (copy_from_user(mode_string, buffer, count))
1136 return -EFAULT;
1137
1138 mode_string[count] = '\0';
1139
1140 result = acpi_thermal_set_cooling_mode(tz,
1141 simple_strtoul(mode_string, NULL,
1142 0));
1143 if (result)
1144 return result;
1145
1146 acpi_thermal_check(tz);
1147
1148 return count;
1149}
1150
1151static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1152{
1153 struct acpi_thermal *tz = seq->private;
1154
1155
1156 if (!tz)
1157 goto end;
1158
1159 if (!tz->thermal_zone->polling_delay) {
1160 seq_puts(seq, "<polling disabled>\n");
1161 goto end;
1162 }
1163
1164 seq_printf(seq, "polling frequency: %d seconds\n",
1165 (tz->thermal_zone->polling_delay / 1000));
1166
1167 end:
1168 return 0;
1169}
1170
1171static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
1172{
1173 return single_open(file, acpi_thermal_polling_seq_show,
1174 PDE(inode)->data);
1175}
1176
1177static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
1178{
1179 if (!tz)
1180 return -EINVAL;
1181
1182 /* Convert value to deci-seconds */
1183 tz->polling_frequency = seconds * 10;
1184
1185 tz->thermal_zone->polling_delay = seconds * 1000;
1186
1187 if (tz->tz_enabled)
1188 thermal_zone_device_update(tz->thermal_zone);
1189
1190 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1191 "Polling frequency set to %lu seconds\n",
1192 tz->polling_frequency/10));
1193
1194 return 0;
1195}
1196
1197static ssize_t
1198acpi_thermal_write_polling(struct file *file,
1199 const char __user * buffer,
1200 size_t count, loff_t * ppos)
1201{
1202 struct seq_file *m = file->private_data;
1203 struct acpi_thermal *tz = m->private;
1204 int result = 0;
1205 char polling_string[12] = { '\0' };
1206 int seconds = 0;
1207
1208
1209 if (!tz || (count > sizeof(polling_string) - 1))
1210 return -EINVAL;
1211
1212 if (copy_from_user(polling_string, buffer, count))
1213 return -EFAULT;
1214
1215 polling_string[count] = '\0';
1216
1217 seconds = simple_strtoul(polling_string, NULL, 0);
1218
1219 result = acpi_thermal_set_polling(tz, seconds);
1220 if (result)
1221 return result;
1222
1223 acpi_thermal_check(tz);
1224
1225 return count;
1226}
1227
1228static int acpi_thermal_add_fs(struct acpi_device *device)
1229{
1230 struct proc_dir_entry *entry = NULL;
1231
1232
1233 if (!acpi_device_dir(device)) {
1234 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1235 acpi_thermal_dir);
1236 if (!acpi_device_dir(device))
1237 return -ENODEV;
1238 }
1239
1240 /* 'state' [R] */
1241 entry = proc_create_data(ACPI_THERMAL_FILE_STATE,
1242 S_IRUGO, acpi_device_dir(device),
1243 &acpi_thermal_state_fops,
1244 acpi_driver_data(device));
1245 if (!entry)
1246 return -ENODEV;
1247
1248 /* 'temperature' [R] */
1249 entry = proc_create_data(ACPI_THERMAL_FILE_TEMPERATURE,
1250 S_IRUGO, acpi_device_dir(device),
1251 &acpi_thermal_temp_fops,
1252 acpi_driver_data(device));
1253 if (!entry)
1254 return -ENODEV;
1255
1256 /* 'trip_points' [R] */
1257 entry = proc_create_data(ACPI_THERMAL_FILE_TRIP_POINTS,
1258 S_IRUGO,
1259 acpi_device_dir(device),
1260 &acpi_thermal_trip_fops,
1261 acpi_driver_data(device));
1262 if (!entry)
1263 return -ENODEV;
1264
1265 /* 'cooling_mode' [R/W] */
1266 entry = proc_create_data(ACPI_THERMAL_FILE_COOLING_MODE,
1267 S_IFREG | S_IRUGO | S_IWUSR,
1268 acpi_device_dir(device),
1269 &acpi_thermal_cooling_fops,
1270 acpi_driver_data(device));
1271 if (!entry)
1272 return -ENODEV;
1273
1274 /* 'polling_frequency' [R/W] */
1275 entry = proc_create_data(ACPI_THERMAL_FILE_POLLING_FREQ,
1276 S_IFREG | S_IRUGO | S_IWUSR,
1277 acpi_device_dir(device),
1278 &acpi_thermal_polling_fops,
1279 acpi_driver_data(device));
1280 if (!entry)
1281 return -ENODEV;
1282 return 0;
1283}
1284
1285static int acpi_thermal_remove_fs(struct acpi_device *device)
1286{
1287
1288 if (acpi_device_dir(device)) {
1289 remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
1290 acpi_device_dir(device));
1291 remove_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
1292 acpi_device_dir(device));
1293 remove_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
1294 acpi_device_dir(device));
1295 remove_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
1296 acpi_device_dir(device));
1297 remove_proc_entry(ACPI_THERMAL_FILE_STATE,
1298 acpi_device_dir(device));
1299 remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir);
1300 acpi_device_dir(device) = NULL;
1301 }
1302
1303 return 0;
1304}
1305#else
1306static inline int acpi_thermal_add_fs(struct acpi_device *device) { return 0; }
1307static inline int acpi_thermal_remove_fs(struct acpi_device *device)
1308{
1309 return 0;
1310}
1311#endif /* CONFIG_ACPI_PROCFS */
1312/* --------------------------------------------------------------------------
1313 Driver Interface 900 Driver Interface
1314 -------------------------------------------------------------------------- */ 901 -------------------------------------------------------------------------- */
1315 902
@@ -1428,17 +1015,11 @@ static int acpi_thermal_add(struct acpi_device *device)
1428 if (result) 1015 if (result)
1429 goto free_memory; 1016 goto free_memory;
1430 1017
1431 result = acpi_thermal_add_fs(device);
1432 if (result)
1433 goto unregister_thermal_zone;
1434
1435 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", 1018 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
1436 acpi_device_name(device), acpi_device_bid(device), 1019 acpi_device_name(device), acpi_device_bid(device),
1437 KELVIN_TO_CELSIUS(tz->temperature)); 1020 KELVIN_TO_CELSIUS(tz->temperature));
1438 goto end; 1021 goto end;
1439 1022
1440unregister_thermal_zone:
1441 thermal_zone_device_unregister(tz->thermal_zone);
1442free_memory: 1023free_memory:
1443 kfree(tz); 1024 kfree(tz);
1444end: 1025end:
@@ -1454,7 +1035,6 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1454 1035
1455 tz = acpi_driver_data(device); 1036 tz = acpi_driver_data(device);
1456 1037
1457 acpi_thermal_remove_fs(device);
1458 acpi_thermal_unregister_thermal_zone(tz); 1038 acpi_thermal_unregister_thermal_zone(tz);
1459 mutex_destroy(&tz->lock); 1039 mutex_destroy(&tz->lock);
1460 kfree(tz); 1040 kfree(tz);
@@ -1580,19 +1160,9 @@ static int __init acpi_thermal_init(void)
1580 return -ENODEV; 1160 return -ENODEV;
1581 } 1161 }
1582 1162
1583#ifdef CONFIG_ACPI_PROCFS
1584 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
1585 if (!acpi_thermal_dir)
1586 return -ENODEV;
1587#endif
1588
1589 result = acpi_bus_register_driver(&acpi_thermal_driver); 1163 result = acpi_bus_register_driver(&acpi_thermal_driver);
1590 if (result < 0) { 1164 if (result < 0)
1591#ifdef CONFIG_ACPI_PROCFS
1592 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1593#endif
1594 return -ENODEV; 1165 return -ENODEV;
1595 }
1596 1166
1597 return 0; 1167 return 0;
1598} 1168}
@@ -1602,10 +1172,6 @@ static void __exit acpi_thermal_exit(void)
1602 1172
1603 acpi_bus_unregister_driver(&acpi_thermal_driver); 1173 acpi_bus_unregister_driver(&acpi_thermal_driver);
1604 1174
1605#ifdef CONFIG_ACPI_PROCFS
1606 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1607#endif
1608
1609 return; 1175 return;
1610} 1176}
1611 1177