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.c801
1 files changed, 400 insertions, 401 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 79c3a686bc44..a24847c08f7f 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -70,9 +70,9 @@
70#define CELSIUS_TO_KELVIN(t) ((t+273)*10) 70#define CELSIUS_TO_KELVIN(t) ((t+273)*10)
71 71
72#define _COMPONENT ACPI_THERMAL_COMPONENT 72#define _COMPONENT ACPI_THERMAL_COMPONENT
73ACPI_MODULE_NAME ("acpi_thermal") 73ACPI_MODULE_NAME("acpi_thermal")
74 74
75MODULE_AUTHOR("Paul Diefenbaugh"); 75 MODULE_AUTHOR("Paul Diefenbaugh");
76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); 76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78 78
@@ -80,143 +80,145 @@ static int tzp;
80module_param(tzp, int, 0); 80module_param(tzp, int, 0);
81MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n"); 81MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n");
82 82
83 83static int acpi_thermal_add(struct acpi_device *device);
84static int acpi_thermal_add (struct acpi_device *device); 84static int acpi_thermal_remove(struct acpi_device *device, int type);
85static int acpi_thermal_remove (struct acpi_device *device, int type);
86static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); 85static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
87static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); 86static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
88static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); 87static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
89static ssize_t acpi_thermal_write_trip_points (struct file*,const char __user *,size_t,loff_t *); 88static ssize_t acpi_thermal_write_trip_points(struct file *,
89 const char __user *, size_t,
90 loff_t *);
90static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); 91static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
91static ssize_t acpi_thermal_write_cooling_mode (struct file*,const char __user *,size_t,loff_t *); 92static ssize_t acpi_thermal_write_cooling_mode(struct file *,
93 const char __user *, size_t,
94 loff_t *);
92static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file); 95static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
93static ssize_t acpi_thermal_write_polling(struct file*,const char __user *,size_t,loff_t *); 96static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
97 size_t, loff_t *);
94 98
95static struct acpi_driver acpi_thermal_driver = { 99static struct acpi_driver acpi_thermal_driver = {
96 .name = ACPI_THERMAL_DRIVER_NAME, 100 .name = ACPI_THERMAL_DRIVER_NAME,
97 .class = ACPI_THERMAL_CLASS, 101 .class = ACPI_THERMAL_CLASS,
98 .ids = ACPI_THERMAL_HID, 102 .ids = ACPI_THERMAL_HID,
99 .ops = { 103 .ops = {
100 .add = acpi_thermal_add, 104 .add = acpi_thermal_add,
101 .remove = acpi_thermal_remove, 105 .remove = acpi_thermal_remove,
102 }, 106 },
103}; 107};
104 108
105struct acpi_thermal_state { 109struct acpi_thermal_state {
106 u8 critical:1; 110 u8 critical:1;
107 u8 hot:1; 111 u8 hot:1;
108 u8 passive:1; 112 u8 passive:1;
109 u8 active:1; 113 u8 active:1;
110 u8 reserved:4; 114 u8 reserved:4;
111 int active_index; 115 int active_index;
112}; 116};
113 117
114struct acpi_thermal_state_flags { 118struct acpi_thermal_state_flags {
115 u8 valid:1; 119 u8 valid:1;
116 u8 enabled:1; 120 u8 enabled:1;
117 u8 reserved:6; 121 u8 reserved:6;
118}; 122};
119 123
120struct acpi_thermal_critical { 124struct acpi_thermal_critical {
121 struct acpi_thermal_state_flags flags; 125 struct acpi_thermal_state_flags flags;
122 unsigned long temperature; 126 unsigned long temperature;
123}; 127};
124 128
125struct acpi_thermal_hot { 129struct acpi_thermal_hot {
126 struct acpi_thermal_state_flags flags; 130 struct acpi_thermal_state_flags flags;
127 unsigned long temperature; 131 unsigned long temperature;
128}; 132};
129 133
130struct acpi_thermal_passive { 134struct acpi_thermal_passive {
131 struct acpi_thermal_state_flags flags; 135 struct acpi_thermal_state_flags flags;
132 unsigned long temperature; 136 unsigned long temperature;
133 unsigned long tc1; 137 unsigned long tc1;
134 unsigned long tc2; 138 unsigned long tc2;
135 unsigned long tsp; 139 unsigned long tsp;
136 struct acpi_handle_list devices; 140 struct acpi_handle_list devices;
137}; 141};
138 142
139struct acpi_thermal_active { 143struct acpi_thermal_active {
140 struct acpi_thermal_state_flags flags; 144 struct acpi_thermal_state_flags flags;
141 unsigned long temperature; 145 unsigned long temperature;
142 struct acpi_handle_list devices; 146 struct acpi_handle_list devices;
143}; 147};
144 148
145struct acpi_thermal_trips { 149struct acpi_thermal_trips {
146 struct acpi_thermal_critical critical; 150 struct acpi_thermal_critical critical;
147 struct acpi_thermal_hot hot; 151 struct acpi_thermal_hot hot;
148 struct acpi_thermal_passive passive; 152 struct acpi_thermal_passive passive;
149 struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE]; 153 struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
150}; 154};
151 155
152struct acpi_thermal_flags { 156struct acpi_thermal_flags {
153 u8 cooling_mode:1; /* _SCP */ 157 u8 cooling_mode:1; /* _SCP */
154 u8 devices:1; /* _TZD */ 158 u8 devices:1; /* _TZD */
155 u8 reserved:6; 159 u8 reserved:6;
156}; 160};
157 161
158struct acpi_thermal { 162struct acpi_thermal {
159 acpi_handle handle; 163 acpi_handle handle;
160 acpi_bus_id name; 164 acpi_bus_id name;
161 unsigned long temperature; 165 unsigned long temperature;
162 unsigned long last_temperature; 166 unsigned long last_temperature;
163 unsigned long polling_frequency; 167 unsigned long polling_frequency;
164 u8 cooling_mode; 168 u8 cooling_mode;
165 volatile u8 zombie; 169 volatile u8 zombie;
166 struct acpi_thermal_flags flags; 170 struct acpi_thermal_flags flags;
167 struct acpi_thermal_state state; 171 struct acpi_thermal_state state;
168 struct acpi_thermal_trips trips; 172 struct acpi_thermal_trips trips;
169 struct acpi_handle_list devices; 173 struct acpi_handle_list devices;
170 struct timer_list timer; 174 struct timer_list timer;
171}; 175};
172 176
173static struct file_operations acpi_thermal_state_fops = { 177static struct file_operations acpi_thermal_state_fops = {
174 .open = acpi_thermal_state_open_fs, 178 .open = acpi_thermal_state_open_fs,
175 .read = seq_read, 179 .read = seq_read,
176 .llseek = seq_lseek, 180 .llseek = seq_lseek,
177 .release = single_release, 181 .release = single_release,
178}; 182};
179 183
180static struct file_operations acpi_thermal_temp_fops = { 184static struct file_operations acpi_thermal_temp_fops = {
181 .open = acpi_thermal_temp_open_fs, 185 .open = acpi_thermal_temp_open_fs,
182 .read = seq_read, 186 .read = seq_read,
183 .llseek = seq_lseek, 187 .llseek = seq_lseek,
184 .release = single_release, 188 .release = single_release,
185}; 189};
186 190
187static struct file_operations acpi_thermal_trip_fops = { 191static struct file_operations acpi_thermal_trip_fops = {
188 .open = acpi_thermal_trip_open_fs, 192 .open = acpi_thermal_trip_open_fs,
189 .read = seq_read, 193 .read = seq_read,
190 .write = acpi_thermal_write_trip_points, 194 .write = acpi_thermal_write_trip_points,
191 .llseek = seq_lseek, 195 .llseek = seq_lseek,
192 .release = single_release, 196 .release = single_release,
193}; 197};
194 198
195static struct file_operations acpi_thermal_cooling_fops = { 199static struct file_operations acpi_thermal_cooling_fops = {
196 .open = acpi_thermal_cooling_open_fs, 200 .open = acpi_thermal_cooling_open_fs,
197 .read = seq_read, 201 .read = seq_read,
198 .write = acpi_thermal_write_cooling_mode, 202 .write = acpi_thermal_write_cooling_mode,
199 .llseek = seq_lseek, 203 .llseek = seq_lseek,
200 .release = single_release, 204 .release = single_release,
201}; 205};
202 206
203static struct file_operations acpi_thermal_polling_fops = { 207static struct file_operations acpi_thermal_polling_fops = {
204 .open = acpi_thermal_polling_open_fs, 208 .open = acpi_thermal_polling_open_fs,
205 .read = seq_read, 209 .read = seq_read,
206 .write = acpi_thermal_write_polling, 210 .write = acpi_thermal_write_polling,
207 .llseek = seq_lseek, 211 .llseek = seq_lseek,
208 .release = single_release, 212 .release = single_release,
209}; 213};
210 214
211/* -------------------------------------------------------------------------- 215/* --------------------------------------------------------------------------
212 Thermal Zone Management 216 Thermal Zone Management
213 -------------------------------------------------------------------------- */ 217 -------------------------------------------------------------------------- */
214 218
215static int 219static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
216acpi_thermal_get_temperature (
217 struct acpi_thermal *tz)
218{ 220{
219 acpi_status status = AE_OK; 221 acpi_status status = AE_OK;
220 222
221 ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature"); 223 ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature");
222 224
@@ -225,41 +227,39 @@ acpi_thermal_get_temperature (
225 227
226 tz->last_temperature = tz->temperature; 228 tz->last_temperature = tz->temperature;
227 229
228 status = acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); 230 status =
231 acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature);
229 if (ACPI_FAILURE(status)) 232 if (ACPI_FAILURE(status))
230 return_VALUE(-ENODEV); 233 return_VALUE(-ENODEV);
231 234
232 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", tz->temperature)); 235 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
236 tz->temperature));
233 237
234 return_VALUE(0); 238 return_VALUE(0);
235} 239}
236 240
237 241static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
238static int
239acpi_thermal_get_polling_frequency (
240 struct acpi_thermal *tz)
241{ 242{
242 acpi_status status = AE_OK; 243 acpi_status status = AE_OK;
243 244
244 ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency"); 245 ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency");
245 246
246 if (!tz) 247 if (!tz)
247 return_VALUE(-EINVAL); 248 return_VALUE(-EINVAL);
248 249
249 status = acpi_evaluate_integer(tz->handle, "_TZP", NULL, &tz->polling_frequency); 250 status =
251 acpi_evaluate_integer(tz->handle, "_TZP", NULL,
252 &tz->polling_frequency);
250 if (ACPI_FAILURE(status)) 253 if (ACPI_FAILURE(status))
251 return_VALUE(-ENODEV); 254 return_VALUE(-ENODEV);
252 255
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", tz->polling_frequency)); 256 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
257 tz->polling_frequency));
254 258
255 return_VALUE(0); 259 return_VALUE(0);
256} 260}
257 261
258 262static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
259static int
260acpi_thermal_set_polling (
261 struct acpi_thermal *tz,
262 int seconds)
263{ 263{
264 ACPI_FUNCTION_TRACE("acpi_thermal_set_polling"); 264 ACPI_FUNCTION_TRACE("acpi_thermal_set_polling");
265 265
@@ -268,21 +268,19 @@ acpi_thermal_set_polling (
268 268
269 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ 269 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */
270 270
271 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency set to %lu seconds\n", tz->polling_frequency)); 271 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
272 "Polling frequency set to %lu seconds\n",
273 tz->polling_frequency));
272 274
273 return_VALUE(0); 275 return_VALUE(0);
274} 276}
275 277
276 278static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
277static int
278acpi_thermal_set_cooling_mode (
279 struct acpi_thermal *tz,
280 int mode)
281{ 279{
282 acpi_status status = AE_OK; 280 acpi_status status = AE_OK;
283 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 281 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
284 struct acpi_object_list arg_list = {1, &arg0}; 282 struct acpi_object_list arg_list = { 1, &arg0 };
285 acpi_handle handle = NULL; 283 acpi_handle handle = NULL;
286 284
287 ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode"); 285 ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode");
288 286
@@ -303,19 +301,16 @@ acpi_thermal_set_cooling_mode (
303 301
304 tz->cooling_mode = mode; 302 tz->cooling_mode = mode;
305 303
306 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", 304 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n",
307 mode?"passive":"active")); 305 mode ? "passive" : "active"));
308 306
309 return_VALUE(0); 307 return_VALUE(0);
310} 308}
311 309
312 310static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
313static int
314acpi_thermal_get_trip_points (
315 struct acpi_thermal *tz)
316{ 311{
317 acpi_status status = AE_OK; 312 acpi_status status = AE_OK;
318 int i = 0; 313 int i = 0;
319 314
320 ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points"); 315 ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points");
321 316
@@ -324,111 +319,128 @@ acpi_thermal_get_trip_points (
324 319
325 /* Critical Shutdown (required) */ 320 /* Critical Shutdown (required) */
326 321
327 status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, 322 status = acpi_evaluate_integer(tz->handle, "_CRT", NULL,
328 &tz->trips.critical.temperature); 323 &tz->trips.critical.temperature);
329 if (ACPI_FAILURE(status)) { 324 if (ACPI_FAILURE(status)) {
330 tz->trips.critical.flags.valid = 0; 325 tz->trips.critical.flags.valid = 0;
331 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n")); 326 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
332 return_VALUE(-ENODEV); 327 return_VALUE(-ENODEV);
333 } 328 } else {
334 else {
335 tz->trips.critical.flags.valid = 1; 329 tz->trips.critical.flags.valid = 1;
336 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found critical threshold [%lu]\n", tz->trips.critical.temperature)); 330 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
331 "Found critical threshold [%lu]\n",
332 tz->trips.critical.temperature));
337 } 333 }
338 334
339 /* Critical Sleep (optional) */ 335 /* Critical Sleep (optional) */
340 336
341 status = acpi_evaluate_integer(tz->handle, "_HOT", NULL, &tz->trips.hot.temperature); 337 status =
338 acpi_evaluate_integer(tz->handle, "_HOT", NULL,
339 &tz->trips.hot.temperature);
342 if (ACPI_FAILURE(status)) { 340 if (ACPI_FAILURE(status)) {
343 tz->trips.hot.flags.valid = 0; 341 tz->trips.hot.flags.valid = 0;
344 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n")); 342 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n"));
345 } 343 } else {
346 else {
347 tz->trips.hot.flags.valid = 1; 344 tz->trips.hot.flags.valid = 1;
348 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n", tz->trips.hot.temperature)); 345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n",
346 tz->trips.hot.temperature));
349 } 347 }
350 348
351 /* Passive: Processors (optional) */ 349 /* Passive: Processors (optional) */
352 350
353 status = acpi_evaluate_integer(tz->handle, "_PSV", NULL, &tz->trips.passive.temperature); 351 status =
352 acpi_evaluate_integer(tz->handle, "_PSV", NULL,
353 &tz->trips.passive.temperature);
354 if (ACPI_FAILURE(status)) { 354 if (ACPI_FAILURE(status)) {
355 tz->trips.passive.flags.valid = 0; 355 tz->trips.passive.flags.valid = 0;
356 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n")); 356 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n"));
357 } 357 } else {
358 else {
359 tz->trips.passive.flags.valid = 1; 358 tz->trips.passive.flags.valid = 1;
360 359
361 status = acpi_evaluate_integer(tz->handle, "_TC1", NULL, &tz->trips.passive.tc1); 360 status =
361 acpi_evaluate_integer(tz->handle, "_TC1", NULL,
362 &tz->trips.passive.tc1);
362 if (ACPI_FAILURE(status)) 363 if (ACPI_FAILURE(status))
363 tz->trips.passive.flags.valid = 0; 364 tz->trips.passive.flags.valid = 0;
364 365
365 status = acpi_evaluate_integer(tz->handle, "_TC2", NULL, &tz->trips.passive.tc2); 366 status =
367 acpi_evaluate_integer(tz->handle, "_TC2", NULL,
368 &tz->trips.passive.tc2);
366 if (ACPI_FAILURE(status)) 369 if (ACPI_FAILURE(status))
367 tz->trips.passive.flags.valid = 0; 370 tz->trips.passive.flags.valid = 0;
368 371
369 status = acpi_evaluate_integer(tz->handle, "_TSP", NULL, &tz->trips.passive.tsp); 372 status =
373 acpi_evaluate_integer(tz->handle, "_TSP", NULL,
374 &tz->trips.passive.tsp);
370 if (ACPI_FAILURE(status)) 375 if (ACPI_FAILURE(status))
371 tz->trips.passive.flags.valid = 0; 376 tz->trips.passive.flags.valid = 0;
372 377
373 status = acpi_evaluate_reference(tz->handle, "_PSL", NULL, &tz->trips.passive.devices); 378 status =
379 acpi_evaluate_reference(tz->handle, "_PSL", NULL,
380 &tz->trips.passive.devices);
374 if (ACPI_FAILURE(status)) 381 if (ACPI_FAILURE(status))
375 tz->trips.passive.flags.valid = 0; 382 tz->trips.passive.flags.valid = 0;
376 383
377 if (!tz->trips.passive.flags.valid) 384 if (!tz->trips.passive.flags.valid)
378 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid passive threshold\n")); 385 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
386 "Invalid passive threshold\n"));
379 else 387 else
380 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%lu]\n", tz->trips.passive.temperature)); 388 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
389 "Found passive threshold [%lu]\n",
390 tz->trips.passive.temperature));
381 } 391 }
382 392
383 /* Active: Fans, etc. (optional) */ 393 /* Active: Fans, etc. (optional) */
384 394
385 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) { 395 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
386 396
387 char name[5] = {'_','A','C',('0'+i),'\0'}; 397 char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
388 398
389 status = acpi_evaluate_integer(tz->handle, name, NULL, &tz->trips.active[i].temperature); 399 status =
400 acpi_evaluate_integer(tz->handle, name, NULL,
401 &tz->trips.active[i].temperature);
390 if (ACPI_FAILURE(status)) 402 if (ACPI_FAILURE(status))
391 break; 403 break;
392 404
393 name[2] = 'L'; 405 name[2] = 'L';
394 status = acpi_evaluate_reference(tz->handle, name, NULL, &tz->trips.active[i].devices); 406 status =
407 acpi_evaluate_reference(tz->handle, name, NULL,
408 &tz->trips.active[i].devices);
395 if (ACPI_SUCCESS(status)) { 409 if (ACPI_SUCCESS(status)) {
396 tz->trips.active[i].flags.valid = 1; 410 tz->trips.active[i].flags.valid = 1;
397 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found active threshold [%d]:[%lu]\n", i, tz->trips.active[i].temperature)); 411 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
398 } 412 "Found active threshold [%d]:[%lu]\n",
399 else 413 i, tz->trips.active[i].temperature));
400 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid active threshold [%d]\n", i)); 414 } else
415 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
416 "Invalid active threshold [%d]\n",
417 i));
401 } 418 }
402 419
403 return_VALUE(0); 420 return_VALUE(0);
404} 421}
405 422
406 423static int acpi_thermal_get_devices(struct acpi_thermal *tz)
407static int
408acpi_thermal_get_devices (
409 struct acpi_thermal *tz)
410{ 424{
411 acpi_status status = AE_OK; 425 acpi_status status = AE_OK;
412 426
413 ACPI_FUNCTION_TRACE("acpi_thermal_get_devices"); 427 ACPI_FUNCTION_TRACE("acpi_thermal_get_devices");
414 428
415 if (!tz) 429 if (!tz)
416 return_VALUE(-EINVAL); 430 return_VALUE(-EINVAL);
417 431
418 status = acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); 432 status =
433 acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices);
419 if (ACPI_FAILURE(status)) 434 if (ACPI_FAILURE(status))
420 return_VALUE(-ENODEV); 435 return_VALUE(-ENODEV);
421 436
422 return_VALUE(0); 437 return_VALUE(0);
423} 438}
424 439
425 440static int acpi_thermal_call_usermode(char *path)
426static int
427acpi_thermal_call_usermode (
428 char *path)
429{ 441{
430 char *argv[2] = {NULL, NULL}; 442 char *argv[2] = { NULL, NULL };
431 char *envp[3] = {NULL, NULL, NULL}; 443 char *envp[3] = { NULL, NULL, NULL };
432 444
433 ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode"); 445 ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode");
434 446
@@ -440,19 +452,16 @@ acpi_thermal_call_usermode (
440 /* minimal command environment */ 452 /* minimal command environment */
441 envp[0] = "HOME=/"; 453 envp[0] = "HOME=/";
442 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 454 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
443 455
444 call_usermodehelper(argv[0], argv, envp, 0); 456 call_usermodehelper(argv[0], argv, envp, 0);
445 457
446 return_VALUE(0); 458 return_VALUE(0);
447} 459}
448 460
449 461static int acpi_thermal_critical(struct acpi_thermal *tz)
450static int
451acpi_thermal_critical (
452 struct acpi_thermal *tz)
453{ 462{
454 int result = 0; 463 int result = 0;
455 struct acpi_device *device = NULL; 464 struct acpi_device *device = NULL;
456 465
457 ACPI_FUNCTION_TRACE("acpi_thermal_critical"); 466 ACPI_FUNCTION_TRACE("acpi_thermal_critical");
458 467
@@ -462,29 +471,28 @@ acpi_thermal_critical (
462 if (tz->temperature >= tz->trips.critical.temperature) { 471 if (tz->temperature >= tz->trips.critical.temperature) {
463 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n")); 472 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n"));
464 tz->trips.critical.flags.enabled = 1; 473 tz->trips.critical.flags.enabled = 1;
465 } 474 } else if (tz->trips.critical.flags.enabled)
466 else if (tz->trips.critical.flags.enabled)
467 tz->trips.critical.flags.enabled = 0; 475 tz->trips.critical.flags.enabled = 0;
468 476
469 result = acpi_bus_get_device(tz->handle, &device); 477 result = acpi_bus_get_device(tz->handle, &device);
470 if (result) 478 if (result)
471 return_VALUE(result); 479 return_VALUE(result);
472 480
473 printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", KELVIN_TO_CELSIUS(tz->temperature)); 481 printk(KERN_EMERG
474 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); 482 "Critical temperature reached (%ld C), shutting down.\n",
483 KELVIN_TO_CELSIUS(tz->temperature));
484 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL,
485 tz->trips.critical.flags.enabled);
475 486
476 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); 487 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
477 488
478 return_VALUE(0); 489 return_VALUE(0);
479} 490}
480 491
481 492static int acpi_thermal_hot(struct acpi_thermal *tz)
482static int
483acpi_thermal_hot (
484 struct acpi_thermal *tz)
485{ 493{
486 int result = 0; 494 int result = 0;
487 struct acpi_device *device = NULL; 495 struct acpi_device *device = NULL;
488 496
489 ACPI_FUNCTION_TRACE("acpi_thermal_hot"); 497 ACPI_FUNCTION_TRACE("acpi_thermal_hot");
490 498
@@ -494,30 +502,27 @@ acpi_thermal_hot (
494 if (tz->temperature >= tz->trips.hot.temperature) { 502 if (tz->temperature >= tz->trips.hot.temperature) {
495 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n")); 503 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n"));
496 tz->trips.hot.flags.enabled = 1; 504 tz->trips.hot.flags.enabled = 1;
497 } 505 } else if (tz->trips.hot.flags.enabled)
498 else if (tz->trips.hot.flags.enabled)
499 tz->trips.hot.flags.enabled = 0; 506 tz->trips.hot.flags.enabled = 0;
500 507
501 result = acpi_bus_get_device(tz->handle, &device); 508 result = acpi_bus_get_device(tz->handle, &device);
502 if (result) 509 if (result)
503 return_VALUE(result); 510 return_VALUE(result);
504 511
505 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); 512 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT,
513 tz->trips.hot.flags.enabled);
506 514
507 /* TBD: Call user-mode "sleep(S4)" function */ 515 /* TBD: Call user-mode "sleep(S4)" function */
508 516
509 return_VALUE(0); 517 return_VALUE(0);
510} 518}
511 519
512 520static int acpi_thermal_passive(struct acpi_thermal *tz)
513static int
514acpi_thermal_passive (
515 struct acpi_thermal *tz)
516{ 521{
517 int result = 0; 522 int result = 0;
518 struct acpi_thermal_passive *passive = NULL; 523 struct acpi_thermal_passive *passive = NULL;
519 int trend = 0; 524 int trend = 0;
520 int i = 0; 525 int i = 0;
521 526
522 ACPI_FUNCTION_TRACE("acpi_thermal_passive"); 527 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
523 528
@@ -534,25 +539,29 @@ acpi_thermal_passive (
534 * accordingly. Note that we assume symmetry. 539 * accordingly. Note that we assume symmetry.
535 */ 540 */
536 if (tz->temperature >= passive->temperature) { 541 if (tz->temperature >= passive->temperature) {
537 trend = (passive->tc1 * (tz->temperature - tz->last_temperature)) + (passive->tc2 * (tz->temperature - passive->temperature)); 542 trend =
538 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 543 (passive->tc1 * (tz->temperature - tz->last_temperature)) +
539 "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", 544 (passive->tc2 * (tz->temperature - passive->temperature));
540 trend, passive->tc1, tz->temperature, 545 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
541 tz->last_temperature, passive->tc2, 546 "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n",
542 tz->temperature, passive->temperature)); 547 trend, passive->tc1, tz->temperature,
548 tz->last_temperature, passive->tc2,
549 tz->temperature, passive->temperature));
543 tz->trips.passive.flags.enabled = 1; 550 tz->trips.passive.flags.enabled = 1;
544 /* Heating up? */ 551 /* Heating up? */
545 if (trend > 0) 552 if (trend > 0)
546 for (i=0; i<passive->devices.count; i++) 553 for (i = 0; i < passive->devices.count; i++)
547 acpi_processor_set_thermal_limit( 554 acpi_processor_set_thermal_limit(passive->
548 passive->devices.handles[i], 555 devices.
549 ACPI_PROCESSOR_LIMIT_INCREMENT); 556 handles[i],
557 ACPI_PROCESSOR_LIMIT_INCREMENT);
550 /* Cooling off? */ 558 /* Cooling off? */
551 else if (trend < 0) 559 else if (trend < 0)
552 for (i=0; i<passive->devices.count; i++) 560 for (i = 0; i < passive->devices.count; i++)
553 acpi_processor_set_thermal_limit( 561 acpi_processor_set_thermal_limit(passive->
554 passive->devices.handles[i], 562 devices.
555 ACPI_PROCESSOR_LIMIT_DECREMENT); 563 handles[i],
564 ACPI_PROCESSOR_LIMIT_DECREMENT);
556 } 565 }
557 566
558 /* 567 /*
@@ -563,37 +572,35 @@ acpi_thermal_passive (
563 * assume symmetry. 572 * assume symmetry.
564 */ 573 */
565 else if (tz->trips.passive.flags.enabled) { 574 else if (tz->trips.passive.flags.enabled) {
566 for (i=0; i<passive->devices.count; i++) 575 for (i = 0; i < passive->devices.count; i++)
567 result = acpi_processor_set_thermal_limit( 576 result =
568 passive->devices.handles[i], 577 acpi_processor_set_thermal_limit(passive->devices.
569 ACPI_PROCESSOR_LIMIT_DECREMENT); 578 handles[i],
579 ACPI_PROCESSOR_LIMIT_DECREMENT);
570 if (result == 1) { 580 if (result == 1) {
571 tz->trips.passive.flags.enabled = 0; 581 tz->trips.passive.flags.enabled = 0;
572 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 582 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
573 "Disabling passive cooling (zone is cool)\n")); 583 "Disabling passive cooling (zone is cool)\n"));
574 } 584 }
575 } 585 }
576 586
577 return_VALUE(0); 587 return_VALUE(0);
578} 588}
579 589
580 590static int acpi_thermal_active(struct acpi_thermal *tz)
581static int
582acpi_thermal_active (
583 struct acpi_thermal *tz)
584{ 591{
585 int result = 0; 592 int result = 0;
586 struct acpi_thermal_active *active = NULL; 593 struct acpi_thermal_active *active = NULL;
587 int i = 0; 594 int i = 0;
588 int j = 0; 595 int j = 0;
589 unsigned long maxtemp = 0; 596 unsigned long maxtemp = 0;
590 597
591 ACPI_FUNCTION_TRACE("acpi_thermal_active"); 598 ACPI_FUNCTION_TRACE("acpi_thermal_active");
592 599
593 if (!tz) 600 if (!tz)
594 return_VALUE(-EINVAL); 601 return_VALUE(-EINVAL);
595 602
596 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) { 603 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
597 604
598 active = &(tz->trips.active[i]); 605 active = &(tz->trips.active[i]);
599 if (!active || !active->flags.valid) 606 if (!active || !active->flags.valid)
@@ -607,16 +614,27 @@ acpi_thermal_active (
607 */ 614 */
608 if (tz->temperature >= active->temperature) { 615 if (tz->temperature >= active->temperature) {
609 if (active->temperature > maxtemp) 616 if (active->temperature > maxtemp)
610 tz->state.active_index = i, maxtemp = active->temperature; 617 tz->state.active_index = i, maxtemp =
618 active->temperature;
611 if (!active->flags.enabled) { 619 if (!active->flags.enabled) {
612 for (j = 0; j < active->devices.count; j++) { 620 for (j = 0; j < active->devices.count; j++) {
613 result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D0); 621 result =
622 acpi_bus_set_power(active->devices.
623 handles[j],
624 ACPI_STATE_D0);
614 if (result) { 625 if (result) {
615 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'on'\n", active->devices.handles[j])); 626 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
627 "Unable to turn cooling device [%p] 'on'\n",
628 active->
629 devices.
630 handles[j]));
616 continue; 631 continue;
617 } 632 }
618 active->flags.enabled = 1; 633 active->flags.enabled = 1;
619 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'on'\n", active->devices.handles[j])); 634 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
635 "Cooling device [%p] now 'on'\n",
636 active->devices.
637 handles[j]));
620 } 638 }
621 } 639 }
622 } 640 }
@@ -628,13 +646,21 @@ acpi_thermal_active (
628 */ 646 */
629 else if (active->flags.enabled) { 647 else if (active->flags.enabled) {
630 for (j = 0; j < active->devices.count; j++) { 648 for (j = 0; j < active->devices.count; j++) {
631 result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3); 649 result =
650 acpi_bus_set_power(active->devices.
651 handles[j],
652 ACPI_STATE_D3);
632 if (result) { 653 if (result) {
633 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to turn cooling device [%p] 'off'\n", active->devices.handles[j])); 654 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
655 "Unable to turn cooling device [%p] 'off'\n",
656 active->devices.
657 handles[j]));
634 continue; 658 continue;
635 } 659 }
636 active->flags.enabled = 0; 660 active->flags.enabled = 0;
637 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling device [%p] now 'off'\n", active->devices.handles[j])); 661 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
662 "Cooling device [%p] now 'off'\n",
663 active->devices.handles[j]));
638 } 664 }
639 } 665 }
640 } 666 }
@@ -642,28 +668,22 @@ acpi_thermal_active (
642 return_VALUE(0); 668 return_VALUE(0);
643} 669}
644 670
671static void acpi_thermal_check(void *context);
645 672
646static void acpi_thermal_check (void *context); 673static void acpi_thermal_run(unsigned long data)
647
648static void
649acpi_thermal_run (
650 unsigned long data)
651{ 674{
652 struct acpi_thermal *tz = (struct acpi_thermal *)data; 675 struct acpi_thermal *tz = (struct acpi_thermal *)data;
653 if (!tz->zombie) 676 if (!tz->zombie)
654 acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 677 acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
655 acpi_thermal_check, (void *) data); 678 acpi_thermal_check, (void *)data);
656} 679}
657 680
658 681static void acpi_thermal_check(void *data)
659static void
660acpi_thermal_check (
661 void *data)
662{ 682{
663 int result = 0; 683 int result = 0;
664 struct acpi_thermal *tz = (struct acpi_thermal *) data; 684 struct acpi_thermal *tz = (struct acpi_thermal *)data;
665 unsigned long sleep_time = 0; 685 unsigned long sleep_time = 0;
666 int i = 0; 686 int i = 0;
667 struct acpi_thermal_state state; 687 struct acpi_thermal_state state;
668 688
669 ACPI_FUNCTION_TRACE("acpi_thermal_check"); 689 ACPI_FUNCTION_TRACE("acpi_thermal_check");
@@ -678,9 +698,9 @@ acpi_thermal_check (
678 result = acpi_thermal_get_temperature(tz); 698 result = acpi_thermal_get_temperature(tz);
679 if (result) 699 if (result)
680 return_VOID; 700 return_VOID;
681 701
682 memset(&tz->state, 0, sizeof(tz->state)); 702 memset(&tz->state, 0, sizeof(tz->state));
683 703
684 /* 704 /*
685 * Check Trip Points 705 * Check Trip Points
686 * ----------------- 706 * -----------------
@@ -690,14 +710,18 @@ acpi_thermal_check (
690 * individual policy decides when it is exited (e.g. hysteresis). 710 * individual policy decides when it is exited (e.g. hysteresis).
691 */ 711 */
692 if (tz->trips.critical.flags.valid) 712 if (tz->trips.critical.flags.valid)
693 state.critical |= (tz->temperature >= tz->trips.critical.temperature); 713 state.critical |=
714 (tz->temperature >= tz->trips.critical.temperature);
694 if (tz->trips.hot.flags.valid) 715 if (tz->trips.hot.flags.valid)
695 state.hot |= (tz->temperature >= tz->trips.hot.temperature); 716 state.hot |= (tz->temperature >= tz->trips.hot.temperature);
696 if (tz->trips.passive.flags.valid) 717 if (tz->trips.passive.flags.valid)
697 state.passive |= (tz->temperature >= tz->trips.passive.temperature); 718 state.passive |=
698 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) 719 (tz->temperature >= tz->trips.passive.temperature);
720 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
699 if (tz->trips.active[i].flags.valid) 721 if (tz->trips.active[i].flags.valid)
700 state.active |= (tz->temperature >= tz->trips.active[i].temperature); 722 state.active |=
723 (tz->temperature >=
724 tz->trips.active[i].temperature);
701 725
702 /* 726 /*
703 * Invoke Policy 727 * Invoke Policy
@@ -726,7 +750,7 @@ acpi_thermal_check (
726 tz->state.hot = 1; 750 tz->state.hot = 1;
727 if (tz->trips.passive.flags.enabled) 751 if (tz->trips.passive.flags.enabled)
728 tz->state.passive = 1; 752 tz->state.passive = 1;
729 for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) 753 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
730 if (tz->trips.active[i].flags.enabled) 754 if (tz->trips.active[i].flags.enabled)
731 tz->state.active = 1; 755 tz->state.active = 1;
732 756
@@ -744,8 +768,8 @@ acpi_thermal_check (
744 else if (tz->polling_frequency > 0) 768 else if (tz->polling_frequency > 0)
745 sleep_time = tz->polling_frequency * 100; 769 sleep_time = tz->polling_frequency * 100;
746 770
747 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", 771 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n",
748 tz->name, tz->temperature, sleep_time)); 772 tz->name, tz->temperature, sleep_time));
749 773
750 /* 774 /*
751 * Schedule Next Poll 775 * Schedule Next Poll
@@ -754,12 +778,11 @@ acpi_thermal_check (
754 if (!sleep_time) { 778 if (!sleep_time) {
755 if (timer_pending(&(tz->timer))) 779 if (timer_pending(&(tz->timer)))
756 del_timer(&(tz->timer)); 780 del_timer(&(tz->timer));
757 } 781 } else {
758 else {
759 if (timer_pending(&(tz->timer))) 782 if (timer_pending(&(tz->timer)))
760 mod_timer(&(tz->timer), (HZ * sleep_time) / 1000); 783 mod_timer(&(tz->timer), (HZ * sleep_time) / 1000);
761 else { 784 else {
762 tz->timer.data = (unsigned long) tz; 785 tz->timer.data = (unsigned long)tz;
763 tz->timer.function = acpi_thermal_run; 786 tz->timer.function = acpi_thermal_run;
764 tz->timer.expires = jiffies + (HZ * sleep_time) / 1000; 787 tz->timer.expires = jiffies + (HZ * sleep_time) / 1000;
765 add_timer(&(tz->timer)); 788 add_timer(&(tz->timer));
@@ -769,16 +792,15 @@ acpi_thermal_check (
769 return_VOID; 792 return_VOID;
770} 793}
771 794
772
773/* -------------------------------------------------------------------------- 795/* --------------------------------------------------------------------------
774 FS Interface (/proc) 796 FS Interface (/proc)
775 -------------------------------------------------------------------------- */ 797 -------------------------------------------------------------------------- */
776 798
777static struct proc_dir_entry *acpi_thermal_dir; 799static struct proc_dir_entry *acpi_thermal_dir;
778 800
779static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) 801static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
780{ 802{
781 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 803 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
782 804
783 ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show"); 805 ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show");
784 806
@@ -787,7 +809,8 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
787 809
788 seq_puts(seq, "state: "); 810 seq_puts(seq, "state: ");
789 811
790 if (!tz->state.critical && !tz->state.hot && !tz->state.passive && !tz->state.active) 812 if (!tz->state.critical && !tz->state.hot && !tz->state.passive
813 && !tz->state.active)
791 seq_puts(seq, "ok\n"); 814 seq_puts(seq, "ok\n");
792 else { 815 else {
793 if (tz->state.critical) 816 if (tz->state.critical)
@@ -801,7 +824,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
801 seq_puts(seq, "\n"); 824 seq_puts(seq, "\n");
802 } 825 }
803 826
804end: 827 end:
805 return_VALUE(0); 828 return_VALUE(0);
806} 829}
807 830
@@ -810,11 +833,10 @@ static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
810 return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data); 833 return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data);
811} 834}
812 835
813
814static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) 836static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
815{ 837{
816 int result = 0; 838 int result = 0;
817 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 839 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
818 840
819 ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show"); 841 ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show");
820 842
@@ -825,10 +847,10 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
825 if (result) 847 if (result)
826 goto end; 848 goto end;
827 849
828 seq_printf(seq, "temperature: %ld C\n", 850 seq_printf(seq, "temperature: %ld C\n",
829 KELVIN_TO_CELSIUS(tz->temperature)); 851 KELVIN_TO_CELSIUS(tz->temperature));
830 852
831end: 853 end:
832 return_VALUE(0); 854 return_VALUE(0);
833} 855}
834 856
@@ -837,12 +859,11 @@ static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
837 return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data); 859 return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data);
838} 860}
839 861
840
841static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) 862static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
842{ 863{
843 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 864 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
844 int i = 0; 865 int i = 0;
845 int j = 0; 866 int j = 0;
846 867
847 ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show"); 868 ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show");
848 869
@@ -851,21 +872,22 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
851 872
852 if (tz->trips.critical.flags.valid) 873 if (tz->trips.critical.flags.valid)
853 seq_printf(seq, "critical (S5): %ld C\n", 874 seq_printf(seq, "critical (S5): %ld C\n",
854 KELVIN_TO_CELSIUS(tz->trips.critical.temperature)); 875 KELVIN_TO_CELSIUS(tz->trips.critical.temperature));
855 876
856 if (tz->trips.hot.flags.valid) 877 if (tz->trips.hot.flags.valid)
857 seq_printf(seq, "hot (S4): %ld C\n", 878 seq_printf(seq, "hot (S4): %ld C\n",
858 KELVIN_TO_CELSIUS(tz->trips.hot.temperature)); 879 KELVIN_TO_CELSIUS(tz->trips.hot.temperature));
859 880
860 if (tz->trips.passive.flags.valid) { 881 if (tz->trips.passive.flags.valid) {
861 seq_printf(seq, "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=", 882 seq_printf(seq,
862 KELVIN_TO_CELSIUS(tz->trips.passive.temperature), 883 "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
863 tz->trips.passive.tc1, 884 KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
864 tz->trips.passive.tc2, 885 tz->trips.passive.tc1, tz->trips.passive.tc2,
865 tz->trips.passive.tsp); 886 tz->trips.passive.tsp);
866 for (j=0; j<tz->trips.passive.devices.count; j++) { 887 for (j = 0; j < tz->trips.passive.devices.count; j++) {
867 888
868 seq_printf(seq, "0x%p ", tz->trips.passive.devices.handles[j]); 889 seq_printf(seq, "0x%p ",
890 tz->trips.passive.devices.handles[j]);
869 } 891 }
870 seq_puts(seq, "\n"); 892 seq_puts(seq, "\n");
871 } 893 }
@@ -874,14 +896,15 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
874 if (!(tz->trips.active[i].flags.valid)) 896 if (!(tz->trips.active[i].flags.valid))
875 break; 897 break;
876 seq_printf(seq, "active[%d]: %ld C: devices=", 898 seq_printf(seq, "active[%d]: %ld C: devices=",
877 i, KELVIN_TO_CELSIUS(tz->trips.active[i].temperature)); 899 i,
878 for (j = 0; j < tz->trips.active[i].devices.count; j++) 900 KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
901 for (j = 0; j < tz->trips.active[i].devices.count; j++)
879 seq_printf(seq, "0x%p ", 902 seq_printf(seq, "0x%p ",
880 tz->trips.active[i].devices.handles[j]); 903 tz->trips.active[i].devices.handles[j]);
881 seq_puts(seq, "\n"); 904 seq_puts(seq, "\n");
882 } 905 }
883 906
884end: 907 end:
885 return_VALUE(0); 908 return_VALUE(0);
886} 909}
887 910
@@ -891,30 +914,28 @@ static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
891} 914}
892 915
893static ssize_t 916static ssize_t
894acpi_thermal_write_trip_points ( 917acpi_thermal_write_trip_points(struct file *file,
895 struct file *file, 918 const char __user * buffer,
896 const char __user *buffer, 919 size_t count, loff_t * ppos)
897 size_t count,
898 loff_t *ppos)
899{ 920{
900 struct seq_file *m = (struct seq_file *)file->private_data; 921 struct seq_file *m = (struct seq_file *)file->private_data;
901 struct acpi_thermal *tz = (struct acpi_thermal *)m->private; 922 struct acpi_thermal *tz = (struct acpi_thermal *)m->private;
902 923
903 char *limit_string; 924 char *limit_string;
904 int num, critical, hot, passive; 925 int num, critical, hot, passive;
905 int *active; 926 int *active;
906 int i = 0; 927 int i = 0;
907 928
908 ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points"); 929 ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points");
909 930
910 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); 931 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
911 if(!limit_string) 932 if (!limit_string)
912 return_VALUE(-ENOMEM); 933 return_VALUE(-ENOMEM);
913 934
914 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); 935 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
915 936
916 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE *sizeof(int), GFP_KERNEL); 937 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
917 if(!active) 938 if (!active)
918 return_VALUE(-ENOMEM); 939 return_VALUE(-ENOMEM);
919 940
920 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { 941 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
@@ -922,20 +943,21 @@ acpi_thermal_write_trip_points (
922 count = -EINVAL; 943 count = -EINVAL;
923 goto end; 944 goto end;
924 } 945 }
925 946
926 if (copy_from_user(limit_string, buffer, count)) { 947 if (copy_from_user(limit_string, buffer, count)) {
927 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); 948 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
928 count = -EFAULT; 949 count = -EFAULT;
929 goto end; 950 goto end;
930 } 951 }
931 952
932 limit_string[count] = '\0'; 953 limit_string[count] = '\0';
933 954
934 num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", 955 num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
935 &critical, &hot, &passive, 956 &critical, &hot, &passive,
936 &active[0], &active[1], &active[2], &active[3], &active[4], 957 &active[0], &active[1], &active[2], &active[3], &active[4],
937 &active[5], &active[6], &active[7], &active[8], &active[9]); 958 &active[5], &active[6], &active[7], &active[8],
938 if(!(num >=5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { 959 &active[9]);
960 if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) {
939 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); 961 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
940 count = -EINVAL; 962 count = -EINVAL;
941 goto end; 963 goto end;
@@ -949,17 +971,16 @@ acpi_thermal_write_trip_points (
949 break; 971 break;
950 tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]); 972 tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]);
951 } 973 }
952 974
953end: 975 end:
954 kfree(active); 976 kfree(active);
955 kfree(limit_string); 977 kfree(limit_string);
956 return_VALUE(count); 978 return_VALUE(count);
957} 979}
958 980
959
960static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) 981static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
961{ 982{
962 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 983 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
963 984
964 ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show"); 985 ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show");
965 986
@@ -970,33 +991,31 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
970 seq_puts(seq, "<setting not supported>\n"); 991 seq_puts(seq, "<setting not supported>\n");
971 } 992 }
972 993
973 if ( tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL ) 994 if (tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL)
974 seq_printf(seq, "cooling mode: critical\n"); 995 seq_printf(seq, "cooling mode: critical\n");
975 else 996 else
976 seq_printf(seq, "cooling mode: %s\n", 997 seq_printf(seq, "cooling mode: %s\n",
977 tz->cooling_mode?"passive":"active"); 998 tz->cooling_mode ? "passive" : "active");
978 999
979end: 1000 end:
980 return_VALUE(0); 1001 return_VALUE(0);
981} 1002}
982 1003
983static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) 1004static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
984{ 1005{
985 return single_open(file, acpi_thermal_cooling_seq_show, 1006 return single_open(file, acpi_thermal_cooling_seq_show,
986 PDE(inode)->data); 1007 PDE(inode)->data);
987} 1008}
988 1009
989static ssize_t 1010static ssize_t
990acpi_thermal_write_cooling_mode ( 1011acpi_thermal_write_cooling_mode(struct file *file,
991 struct file *file, 1012 const char __user * buffer,
992 const char __user *buffer, 1013 size_t count, loff_t * ppos)
993 size_t count,
994 loff_t *ppos)
995{ 1014{
996 struct seq_file *m = (struct seq_file *)file->private_data; 1015 struct seq_file *m = (struct seq_file *)file->private_data;
997 struct acpi_thermal *tz = (struct acpi_thermal *)m->private; 1016 struct acpi_thermal *tz = (struct acpi_thermal *)m->private;
998 int result = 0; 1017 int result = 0;
999 char mode_string[12] = {'\0'}; 1018 char mode_string[12] = { '\0' };
1000 1019
1001 ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode"); 1020 ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode");
1002 1021
@@ -1008,11 +1027,12 @@ acpi_thermal_write_cooling_mode (
1008 1027
1009 if (copy_from_user(mode_string, buffer, count)) 1028 if (copy_from_user(mode_string, buffer, count))
1010 return_VALUE(-EFAULT); 1029 return_VALUE(-EFAULT);
1011 1030
1012 mode_string[count] = '\0'; 1031 mode_string[count] = '\0';
1013 1032
1014 result = acpi_thermal_set_cooling_mode(tz, 1033 result = acpi_thermal_set_cooling_mode(tz,
1015 simple_strtoul(mode_string, NULL, 0)); 1034 simple_strtoul(mode_string, NULL,
1035 0));
1016 if (result) 1036 if (result)
1017 return_VALUE(result); 1037 return_VALUE(result);
1018 1038
@@ -1021,10 +1041,9 @@ acpi_thermal_write_cooling_mode (
1021 return_VALUE(count); 1041 return_VALUE(count);
1022} 1042}
1023 1043
1024
1025static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) 1044static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1026{ 1045{
1027 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 1046 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
1028 1047
1029 ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show"); 1048 ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show");
1030 1049
@@ -1037,43 +1056,41 @@ static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1037 } 1056 }
1038 1057
1039 seq_printf(seq, "polling frequency: %lu seconds\n", 1058 seq_printf(seq, "polling frequency: %lu seconds\n",
1040 (tz->polling_frequency / 10)); 1059 (tz->polling_frequency / 10));
1041 1060
1042end: 1061 end:
1043 return_VALUE(0); 1062 return_VALUE(0);
1044} 1063}
1045 1064
1046static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) 1065static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
1047{ 1066{
1048 return single_open(file, acpi_thermal_polling_seq_show, 1067 return single_open(file, acpi_thermal_polling_seq_show,
1049 PDE(inode)->data); 1068 PDE(inode)->data);
1050} 1069}
1051 1070
1052static ssize_t 1071static ssize_t
1053acpi_thermal_write_polling ( 1072acpi_thermal_write_polling(struct file *file,
1054 struct file *file, 1073 const char __user * buffer,
1055 const char __user *buffer, 1074 size_t count, loff_t * ppos)
1056 size_t count,
1057 loff_t *ppos)
1058{ 1075{
1059 struct seq_file *m = (struct seq_file *)file->private_data; 1076 struct seq_file *m = (struct seq_file *)file->private_data;
1060 struct acpi_thermal *tz = (struct acpi_thermal *)m->private; 1077 struct acpi_thermal *tz = (struct acpi_thermal *)m->private;
1061 int result = 0; 1078 int result = 0;
1062 char polling_string[12] = {'\0'}; 1079 char polling_string[12] = { '\0' };
1063 int seconds = 0; 1080 int seconds = 0;
1064 1081
1065 ACPI_FUNCTION_TRACE("acpi_thermal_write_polling"); 1082 ACPI_FUNCTION_TRACE("acpi_thermal_write_polling");
1066 1083
1067 if (!tz || (count > sizeof(polling_string) - 1)) 1084 if (!tz || (count > sizeof(polling_string) - 1))
1068 return_VALUE(-EINVAL); 1085 return_VALUE(-EINVAL);
1069 1086
1070 if (copy_from_user(polling_string, buffer, count)) 1087 if (copy_from_user(polling_string, buffer, count))
1071 return_VALUE(-EFAULT); 1088 return_VALUE(-EFAULT);
1072 1089
1073 polling_string[count] = '\0'; 1090 polling_string[count] = '\0';
1074 1091
1075 seconds = simple_strtoul(polling_string, NULL, 0); 1092 seconds = simple_strtoul(polling_string, NULL, 0);
1076 1093
1077 result = acpi_thermal_set_polling(tz, seconds); 1094 result = acpi_thermal_set_polling(tz, seconds);
1078 if (result) 1095 if (result)
1079 return_VALUE(result); 1096 return_VALUE(result);
@@ -1083,18 +1100,15 @@ acpi_thermal_write_polling (
1083 return_VALUE(count); 1100 return_VALUE(count);
1084} 1101}
1085 1102
1086 1103static int acpi_thermal_add_fs(struct acpi_device *device)
1087static int
1088acpi_thermal_add_fs (
1089 struct acpi_device *device)
1090{ 1104{
1091 struct proc_dir_entry *entry = NULL; 1105 struct proc_dir_entry *entry = NULL;
1092 1106
1093 ACPI_FUNCTION_TRACE("acpi_thermal_add_fs"); 1107 ACPI_FUNCTION_TRACE("acpi_thermal_add_fs");
1094 1108
1095 if (!acpi_device_dir(device)) { 1109 if (!acpi_device_dir(device)) {
1096 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1110 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1097 acpi_thermal_dir); 1111 acpi_thermal_dir);
1098 if (!acpi_device_dir(device)) 1112 if (!acpi_device_dir(device))
1099 return_VALUE(-ENODEV); 1113 return_VALUE(-ENODEV);
1100 acpi_device_dir(device)->owner = THIS_MODULE; 1114 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -1102,11 +1116,11 @@ acpi_thermal_add_fs (
1102 1116
1103 /* 'state' [R] */ 1117 /* 'state' [R] */
1104 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, 1118 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
1105 S_IRUGO, acpi_device_dir(device)); 1119 S_IRUGO, acpi_device_dir(device));
1106 if (!entry) 1120 if (!entry)
1107 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1108 "Unable to create '%s' fs entry\n", 1122 "Unable to create '%s' fs entry\n",
1109 ACPI_THERMAL_FILE_STATE)); 1123 ACPI_THERMAL_FILE_STATE));
1110 else { 1124 else {
1111 entry->proc_fops = &acpi_thermal_state_fops; 1125 entry->proc_fops = &acpi_thermal_state_fops;
1112 entry->data = acpi_driver_data(device); 1126 entry->data = acpi_driver_data(device);
@@ -1115,11 +1129,11 @@ acpi_thermal_add_fs (
1115 1129
1116 /* 'temperature' [R] */ 1130 /* 'temperature' [R] */
1117 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, 1131 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
1118 S_IRUGO, acpi_device_dir(device)); 1132 S_IRUGO, acpi_device_dir(device));
1119 if (!entry) 1133 if (!entry)
1120 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1134 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1121 "Unable to create '%s' fs entry\n", 1135 "Unable to create '%s' fs entry\n",
1122 ACPI_THERMAL_FILE_TEMPERATURE)); 1136 ACPI_THERMAL_FILE_TEMPERATURE));
1123 else { 1137 else {
1124 entry->proc_fops = &acpi_thermal_temp_fops; 1138 entry->proc_fops = &acpi_thermal_temp_fops;
1125 entry->data = acpi_driver_data(device); 1139 entry->data = acpi_driver_data(device);
@@ -1128,11 +1142,12 @@ acpi_thermal_add_fs (
1128 1142
1129 /* 'trip_points' [R/W] */ 1143 /* 'trip_points' [R/W] */
1130 entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, 1144 entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
1131 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 1145 S_IFREG | S_IRUGO | S_IWUSR,
1146 acpi_device_dir(device));
1132 if (!entry) 1147 if (!entry)
1133 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1148 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1134 "Unable to create '%s' fs entry\n", 1149 "Unable to create '%s' fs entry\n",
1135 ACPI_THERMAL_FILE_TRIP_POINTS)); 1150 ACPI_THERMAL_FILE_TRIP_POINTS));
1136 else { 1151 else {
1137 entry->proc_fops = &acpi_thermal_trip_fops; 1152 entry->proc_fops = &acpi_thermal_trip_fops;
1138 entry->data = acpi_driver_data(device); 1153 entry->data = acpi_driver_data(device);
@@ -1141,11 +1156,12 @@ acpi_thermal_add_fs (
1141 1156
1142 /* 'cooling_mode' [R/W] */ 1157 /* 'cooling_mode' [R/W] */
1143 entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, 1158 entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
1144 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 1159 S_IFREG | S_IRUGO | S_IWUSR,
1160 acpi_device_dir(device));
1145 if (!entry) 1161 if (!entry)
1146 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1147 "Unable to create '%s' fs entry\n", 1163 "Unable to create '%s' fs entry\n",
1148 ACPI_THERMAL_FILE_COOLING_MODE)); 1164 ACPI_THERMAL_FILE_COOLING_MODE));
1149 else { 1165 else {
1150 entry->proc_fops = &acpi_thermal_cooling_fops; 1166 entry->proc_fops = &acpi_thermal_cooling_fops;
1151 entry->data = acpi_driver_data(device); 1167 entry->data = acpi_driver_data(device);
@@ -1154,11 +1170,12 @@ acpi_thermal_add_fs (
1154 1170
1155 /* 'polling_frequency' [R/W] */ 1171 /* 'polling_frequency' [R/W] */
1156 entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, 1172 entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
1157 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 1173 S_IFREG | S_IRUGO | S_IWUSR,
1174 acpi_device_dir(device));
1158 if (!entry) 1175 if (!entry)
1159 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1176 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1160 "Unable to create '%s' fs entry\n", 1177 "Unable to create '%s' fs entry\n",
1161 ACPI_THERMAL_FILE_POLLING_FREQ)); 1178 ACPI_THERMAL_FILE_POLLING_FREQ));
1162 else { 1179 else {
1163 entry->proc_fops = &acpi_thermal_polling_fops; 1180 entry->proc_fops = &acpi_thermal_polling_fops;
1164 entry->data = acpi_driver_data(device); 1181 entry->data = acpi_driver_data(device);
@@ -1168,10 +1185,7 @@ acpi_thermal_add_fs (
1168 return_VALUE(0); 1185 return_VALUE(0);
1169} 1186}
1170 1187
1171 1188static int acpi_thermal_remove_fs(struct acpi_device *device)
1172static int
1173acpi_thermal_remove_fs (
1174 struct acpi_device *device)
1175{ 1189{
1176 ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs"); 1190 ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs");
1177 1191
@@ -1193,19 +1207,14 @@ acpi_thermal_remove_fs (
1193 return_VALUE(0); 1207 return_VALUE(0);
1194} 1208}
1195 1209
1196
1197/* -------------------------------------------------------------------------- 1210/* --------------------------------------------------------------------------
1198 Driver Interface 1211 Driver Interface
1199 -------------------------------------------------------------------------- */ 1212 -------------------------------------------------------------------------- */
1200 1213
1201static void 1214static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1202acpi_thermal_notify (
1203 acpi_handle handle,
1204 u32 event,
1205 void *data)
1206{ 1215{
1207 struct acpi_thermal *tz = (struct acpi_thermal *) data; 1216 struct acpi_thermal *tz = (struct acpi_thermal *)data;
1208 struct acpi_device *device = NULL; 1217 struct acpi_device *device = NULL;
1209 1218
1210 ACPI_FUNCTION_TRACE("acpi_thermal_notify"); 1219 ACPI_FUNCTION_TRACE("acpi_thermal_notify");
1211 1220
@@ -1231,19 +1240,16 @@ acpi_thermal_notify (
1231 break; 1240 break;
1232 default: 1241 default:
1233 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1242 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1234 "Unsupported event [0x%x]\n", event)); 1243 "Unsupported event [0x%x]\n", event));
1235 break; 1244 break;
1236 } 1245 }
1237 1246
1238 return_VOID; 1247 return_VOID;
1239} 1248}
1240 1249
1241 1250static int acpi_thermal_get_info(struct acpi_thermal *tz)
1242static int
1243acpi_thermal_get_info (
1244 struct acpi_thermal *tz)
1245{ 1251{
1246 int result = 0; 1252 int result = 0;
1247 1253
1248 ACPI_FUNCTION_TRACE("acpi_thermal_get_info"); 1254 ACPI_FUNCTION_TRACE("acpi_thermal_get_info");
1249 1255
@@ -1262,20 +1268,24 @@ acpi_thermal_get_info (
1262 1268
1263 /* Set the cooling mode [_SCP] to active cooling (default) */ 1269 /* Set the cooling mode [_SCP] to active cooling (default) */
1264 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); 1270 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
1265 if (!result) 1271 if (!result)
1266 tz->flags.cooling_mode = 1; 1272 tz->flags.cooling_mode = 1;
1267 else { 1273 else {
1268 /* Oh,we have not _SCP method. 1274 /* Oh,we have not _SCP method.
1269 Generally show cooling_mode by _ACx, _PSV,spec 12.2*/ 1275 Generally show cooling_mode by _ACx, _PSV,spec 12.2 */
1270 tz->flags.cooling_mode = 0; 1276 tz->flags.cooling_mode = 0;
1271 if ( tz->trips.active[0].flags.valid && tz->trips.passive.flags.valid ) { 1277 if (tz->trips.active[0].flags.valid
1272 if ( tz->trips.passive.temperature > tz->trips.active[0].temperature ) 1278 && tz->trips.passive.flags.valid) {
1279 if (tz->trips.passive.temperature >
1280 tz->trips.active[0].temperature)
1273 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; 1281 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE;
1274 else 1282 else
1275 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; 1283 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE;
1276 } else if ( !tz->trips.active[0].flags.valid && tz->trips.passive.flags.valid ) { 1284 } else if (!tz->trips.active[0].flags.valid
1285 && tz->trips.passive.flags.valid) {
1277 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; 1286 tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE;
1278 } else if ( tz->trips.active[0].flags.valid && !tz->trips.passive.flags.valid ) { 1287 } else if (tz->trips.active[0].flags.valid
1288 && !tz->trips.passive.flags.valid) {
1279 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; 1289 tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE;
1280 } else { 1290 } else {
1281 /* _ACx and _PSV are optional, but _CRT is required */ 1291 /* _ACx and _PSV are optional, but _CRT is required */
@@ -1297,14 +1307,11 @@ acpi_thermal_get_info (
1297 return_VALUE(0); 1307 return_VALUE(0);
1298} 1308}
1299 1309
1300 1310static int acpi_thermal_add(struct acpi_device *device)
1301static int
1302acpi_thermal_add (
1303 struct acpi_device *device)
1304{ 1311{
1305 int result = 0; 1312 int result = 0;
1306 acpi_status status = AE_OK; 1313 acpi_status status = AE_OK;
1307 struct acpi_thermal *tz = NULL; 1314 struct acpi_thermal *tz = NULL;
1308 1315
1309 ACPI_FUNCTION_TRACE("acpi_thermal_add"); 1316 ACPI_FUNCTION_TRACE("acpi_thermal_add");
1310 1317
@@ -1335,19 +1342,20 @@ acpi_thermal_add (
1335 acpi_thermal_check(tz); 1342 acpi_thermal_check(tz);
1336 1343
1337 status = acpi_install_notify_handler(tz->handle, 1344 status = acpi_install_notify_handler(tz->handle,
1338 ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz); 1345 ACPI_DEVICE_NOTIFY,
1346 acpi_thermal_notify, tz);
1339 if (ACPI_FAILURE(status)) { 1347 if (ACPI_FAILURE(status)) {
1340 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1348 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1341 "Error installing notify handler\n")); 1349 "Error installing notify handler\n"));
1342 result = -ENODEV; 1350 result = -ENODEV;
1343 goto end; 1351 goto end;
1344 } 1352 }
1345 1353
1346 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", 1354 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
1347 acpi_device_name(device), acpi_device_bid(device), 1355 acpi_device_name(device), acpi_device_bid(device),
1348 KELVIN_TO_CELSIUS(tz->temperature)); 1356 KELVIN_TO_CELSIUS(tz->temperature));
1349 1357
1350end: 1358 end:
1351 if (result) { 1359 if (result) {
1352 acpi_thermal_remove_fs(device); 1360 acpi_thermal_remove_fs(device);
1353 kfree(tz); 1361 kfree(tz);
@@ -1356,21 +1364,17 @@ end:
1356 return_VALUE(result); 1364 return_VALUE(result);
1357} 1365}
1358 1366
1359 1367static int acpi_thermal_remove(struct acpi_device *device, int type)
1360static int
1361acpi_thermal_remove (
1362 struct acpi_device *device,
1363 int type)
1364{ 1368{
1365 acpi_status status = AE_OK; 1369 acpi_status status = AE_OK;
1366 struct acpi_thermal *tz = NULL; 1370 struct acpi_thermal *tz = NULL;
1367 1371
1368 ACPI_FUNCTION_TRACE("acpi_thermal_remove"); 1372 ACPI_FUNCTION_TRACE("acpi_thermal_remove");
1369 1373
1370 if (!device || !acpi_driver_data(device)) 1374 if (!device || !acpi_driver_data(device))
1371 return_VALUE(-EINVAL); 1375 return_VALUE(-EINVAL);
1372 1376
1373 tz = (struct acpi_thermal *) acpi_driver_data(device); 1377 tz = (struct acpi_thermal *)acpi_driver_data(device);
1374 1378
1375 /* avoid timer adding new defer task */ 1379 /* avoid timer adding new defer task */
1376 tz->zombie = 1; 1380 tz->zombie = 1;
@@ -1382,19 +1386,19 @@ acpi_thermal_remove (
1382 del_timer_sync(&(tz->timer)); 1386 del_timer_sync(&(tz->timer));
1383 1387
1384 status = acpi_remove_notify_handler(tz->handle, 1388 status = acpi_remove_notify_handler(tz->handle,
1385 ACPI_DEVICE_NOTIFY, acpi_thermal_notify); 1389 ACPI_DEVICE_NOTIFY,
1390 acpi_thermal_notify);
1386 if (ACPI_FAILURE(status)) 1391 if (ACPI_FAILURE(status))
1387 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1392 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1388 "Error removing notify handler\n")); 1393 "Error removing notify handler\n"));
1389 1394
1390 /* Terminate policy */ 1395 /* Terminate policy */
1391 if (tz->trips.passive.flags.valid 1396 if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) {
1392 && tz->trips.passive.flags.enabled) {
1393 tz->trips.passive.flags.enabled = 0; 1397 tz->trips.passive.flags.enabled = 0;
1394 acpi_thermal_passive(tz); 1398 acpi_thermal_passive(tz);
1395 } 1399 }
1396 if (tz->trips.active[0].flags.valid 1400 if (tz->trips.active[0].flags.valid
1397 && tz->trips.active[0].flags.enabled) { 1401 && tz->trips.active[0].flags.enabled) {
1398 tz->trips.active[0].flags.enabled = 0; 1402 tz->trips.active[0].flags.enabled = 0;
1399 acpi_thermal_active(tz); 1403 acpi_thermal_active(tz);
1400 } 1404 }
@@ -1405,11 +1409,9 @@ acpi_thermal_remove (
1405 return_VALUE(0); 1409 return_VALUE(0);
1406} 1410}
1407 1411
1408 1412static int __init acpi_thermal_init(void)
1409static int __init
1410acpi_thermal_init (void)
1411{ 1413{
1412 int result = 0; 1414 int result = 0;
1413 1415
1414 ACPI_FUNCTION_TRACE("acpi_thermal_init"); 1416 ACPI_FUNCTION_TRACE("acpi_thermal_init");
1415 1417
@@ -1427,9 +1429,7 @@ acpi_thermal_init (void)
1427 return_VALUE(0); 1429 return_VALUE(0);
1428} 1430}
1429 1431
1430 1432static void __exit acpi_thermal_exit(void)
1431static void __exit
1432acpi_thermal_exit (void)
1433{ 1433{
1434 ACPI_FUNCTION_TRACE("acpi_thermal_exit"); 1434 ACPI_FUNCTION_TRACE("acpi_thermal_exit");
1435 1435
@@ -1440,6 +1440,5 @@ acpi_thermal_exit (void)
1440 return_VOID; 1440 return_VOID;
1441} 1441}
1442 1442
1443
1444module_init(acpi_thermal_init); 1443module_init(acpi_thermal_init);
1445module_exit(acpi_thermal_exit); 1444module_exit(acpi_thermal_exit);