aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/thermal.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-07-04 00:32:50 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-04 00:32:50 -0400
commite82ca04387dd6c98722f5f48235089839fd04268 (patch)
tree8fb4b0435e57c7dab70dfd4cc71b4cd35686126d /drivers/acpi/thermal.c
parent075395d228641646159dae3dd170fa3fc6ff477a (diff)
parent309b0f125a22ee34c8f6962677255f7bf6af5e3d (diff)
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (44 commits) ACPI: remove function tracing macros from drivers/acpi/*.c ACPI: add support for Smart Battery ACPI: handle battery notify event on broken BIOS ACPI: handle AC notify event on broken BIOS ACPI: asus_acpi: add S1N WLED control ACPI: asus_acpi: correct M6N/M6R display nodes ACPI: asus_acpi: add S1N WLED control ACPI: asus_acpi: rework model detection ACPI: asus_acpi: support L5D ACPI: asus_acpi: handle internal Bluetooth / support W5A ACPI: asus_acpi: support A4G ACPI: asus_acpi: support W3400N ACPI: asus_acpi: LED display support ACPI: asus_acpi: support A3G ACPI: asus_acpi: misc cleanups ACPI: video: Remove unneeded acpi_handle from driver. ACPI: thermal: Remove unneeded acpi_handle from driver. ACPI: power: Remove unneeded acpi_handle from driver. ACPI: pci_root: Remove unneeded acpi_handle from driver. ACPI: pci_link: Remove unneeded acpi_handle from driver. ...
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r--drivers/acpi/thermal.c57
1 files changed, 20 insertions, 37 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index c855f4446b5f..503c0b99db12 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -162,7 +162,7 @@ struct acpi_thermal_flags {
162}; 162};
163 163
164struct acpi_thermal { 164struct acpi_thermal {
165 acpi_handle handle; 165 struct acpi_device * device;
166 acpi_bus_id name; 166 acpi_bus_id name;
167 unsigned long temperature; 167 unsigned long temperature;
168 unsigned long last_temperature; 168 unsigned long last_temperature;
@@ -229,7 +229,7 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
229 tz->last_temperature = tz->temperature; 229 tz->last_temperature = tz->temperature;
230 230
231 status = 231 status =
232 acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); 232 acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tz->temperature);
233 if (ACPI_FAILURE(status)) 233 if (ACPI_FAILURE(status))
234 return -ENODEV; 234 return -ENODEV;
235 235
@@ -248,7 +248,7 @@ static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
248 return -EINVAL; 248 return -EINVAL;
249 249
250 status = 250 status =
251 acpi_evaluate_integer(tz->handle, "_TZP", NULL, 251 acpi_evaluate_integer(tz->device->handle, "_TZP", NULL,
252 &tz->polling_frequency); 252 &tz->polling_frequency);
253 if (ACPI_FAILURE(status)) 253 if (ACPI_FAILURE(status))
254 return -ENODEV; 254 return -ENODEV;
@@ -285,7 +285,7 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
285 if (!tz) 285 if (!tz)
286 return -EINVAL; 286 return -EINVAL;
287 287
288 status = acpi_get_handle(tz->handle, "_SCP", &handle); 288 status = acpi_get_handle(tz->device->handle, "_SCP", &handle);
289 if (ACPI_FAILURE(status)) { 289 if (ACPI_FAILURE(status)) {
290 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); 290 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
291 return -ENODEV; 291 return -ENODEV;
@@ -316,7 +316,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
316 316
317 /* Critical Shutdown (required) */ 317 /* Critical Shutdown (required) */
318 318
319 status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, 319 status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL,
320 &tz->trips.critical.temperature); 320 &tz->trips.critical.temperature);
321 if (ACPI_FAILURE(status)) { 321 if (ACPI_FAILURE(status)) {
322 tz->trips.critical.flags.valid = 0; 322 tz->trips.critical.flags.valid = 0;
@@ -332,7 +332,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
332 /* Critical Sleep (optional) */ 332 /* Critical Sleep (optional) */
333 333
334 status = 334 status =
335 acpi_evaluate_integer(tz->handle, "_HOT", NULL, 335 acpi_evaluate_integer(tz->device->handle, "_HOT", NULL,
336 &tz->trips.hot.temperature); 336 &tz->trips.hot.temperature);
337 if (ACPI_FAILURE(status)) { 337 if (ACPI_FAILURE(status)) {
338 tz->trips.hot.flags.valid = 0; 338 tz->trips.hot.flags.valid = 0;
@@ -346,7 +346,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
346 /* Passive: Processors (optional) */ 346 /* Passive: Processors (optional) */
347 347
348 status = 348 status =
349 acpi_evaluate_integer(tz->handle, "_PSV", NULL, 349 acpi_evaluate_integer(tz->device->handle, "_PSV", NULL,
350 &tz->trips.passive.temperature); 350 &tz->trips.passive.temperature);
351 if (ACPI_FAILURE(status)) { 351 if (ACPI_FAILURE(status)) {
352 tz->trips.passive.flags.valid = 0; 352 tz->trips.passive.flags.valid = 0;
@@ -355,25 +355,25 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
355 tz->trips.passive.flags.valid = 1; 355 tz->trips.passive.flags.valid = 1;
356 356
357 status = 357 status =
358 acpi_evaluate_integer(tz->handle, "_TC1", NULL, 358 acpi_evaluate_integer(tz->device->handle, "_TC1", NULL,
359 &tz->trips.passive.tc1); 359 &tz->trips.passive.tc1);
360 if (ACPI_FAILURE(status)) 360 if (ACPI_FAILURE(status))
361 tz->trips.passive.flags.valid = 0; 361 tz->trips.passive.flags.valid = 0;
362 362
363 status = 363 status =
364 acpi_evaluate_integer(tz->handle, "_TC2", NULL, 364 acpi_evaluate_integer(tz->device->handle, "_TC2", NULL,
365 &tz->trips.passive.tc2); 365 &tz->trips.passive.tc2);
366 if (ACPI_FAILURE(status)) 366 if (ACPI_FAILURE(status))
367 tz->trips.passive.flags.valid = 0; 367 tz->trips.passive.flags.valid = 0;
368 368
369 status = 369 status =
370 acpi_evaluate_integer(tz->handle, "_TSP", NULL, 370 acpi_evaluate_integer(tz->device->handle, "_TSP", NULL,
371 &tz->trips.passive.tsp); 371 &tz->trips.passive.tsp);
372 if (ACPI_FAILURE(status)) 372 if (ACPI_FAILURE(status))
373 tz->trips.passive.flags.valid = 0; 373 tz->trips.passive.flags.valid = 0;
374 374
375 status = 375 status =
376 acpi_evaluate_reference(tz->handle, "_PSL", NULL, 376 acpi_evaluate_reference(tz->device->handle, "_PSL", NULL,
377 &tz->trips.passive.devices); 377 &tz->trips.passive.devices);
378 if (ACPI_FAILURE(status)) 378 if (ACPI_FAILURE(status))
379 tz->trips.passive.flags.valid = 0; 379 tz->trips.passive.flags.valid = 0;
@@ -393,14 +393,14 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
393 char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; 393 char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
394 394
395 status = 395 status =
396 acpi_evaluate_integer(tz->handle, name, NULL, 396 acpi_evaluate_integer(tz->device->handle, name, NULL,
397 &tz->trips.active[i].temperature); 397 &tz->trips.active[i].temperature);
398 if (ACPI_FAILURE(status)) 398 if (ACPI_FAILURE(status))
399 break; 399 break;
400 400
401 name[2] = 'L'; 401 name[2] = 'L';
402 status = 402 status =
403 acpi_evaluate_reference(tz->handle, name, NULL, 403 acpi_evaluate_reference(tz->device->handle, name, NULL,
404 &tz->trips.active[i].devices); 404 &tz->trips.active[i].devices);
405 if (ACPI_SUCCESS(status)) { 405 if (ACPI_SUCCESS(status)) {
406 tz->trips.active[i].flags.valid = 1; 406 tz->trips.active[i].flags.valid = 1;
@@ -424,7 +424,7 @@ static int acpi_thermal_get_devices(struct acpi_thermal *tz)
424 return -EINVAL; 424 return -EINVAL;
425 425
426 status = 426 status =
427 acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); 427 acpi_evaluate_reference(tz->device->handle, "_TZD", NULL, &tz->devices);
428 if (ACPI_FAILURE(status)) 428 if (ACPI_FAILURE(status))
429 return -ENODEV; 429 return -ENODEV;
430 430
@@ -453,10 +453,6 @@ static int acpi_thermal_call_usermode(char *path)
453 453
454static int acpi_thermal_critical(struct acpi_thermal *tz) 454static int acpi_thermal_critical(struct acpi_thermal *tz)
455{ 455{
456 int result = 0;
457 struct acpi_device *device = NULL;
458
459
460 if (!tz || !tz->trips.critical.flags.valid) 456 if (!tz || !tz->trips.critical.flags.valid)
461 return -EINVAL; 457 return -EINVAL;
462 458
@@ -466,14 +462,10 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
466 } else if (tz->trips.critical.flags.enabled) 462 } else if (tz->trips.critical.flags.enabled)
467 tz->trips.critical.flags.enabled = 0; 463 tz->trips.critical.flags.enabled = 0;
468 464
469 result = acpi_bus_get_device(tz->handle, &device);
470 if (result)
471 return result;
472
473 printk(KERN_EMERG 465 printk(KERN_EMERG
474 "Critical temperature reached (%ld C), shutting down.\n", 466 "Critical temperature reached (%ld C), shutting down.\n",
475 KELVIN_TO_CELSIUS(tz->temperature)); 467 KELVIN_TO_CELSIUS(tz->temperature));
476 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, 468 acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
477 tz->trips.critical.flags.enabled); 469 tz->trips.critical.flags.enabled);
478 470
479 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); 471 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
@@ -483,10 +475,6 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
483 475
484static int acpi_thermal_hot(struct acpi_thermal *tz) 476static int acpi_thermal_hot(struct acpi_thermal *tz)
485{ 477{
486 int result = 0;
487 struct acpi_device *device = NULL;
488
489
490 if (!tz || !tz->trips.hot.flags.valid) 478 if (!tz || !tz->trips.hot.flags.valid)
491 return -EINVAL; 479 return -EINVAL;
492 480
@@ -496,11 +484,7 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
496 } else if (tz->trips.hot.flags.enabled) 484 } else if (tz->trips.hot.flags.enabled)
497 tz->trips.hot.flags.enabled = 0; 485 tz->trips.hot.flags.enabled = 0;
498 486
499 result = acpi_bus_get_device(tz->handle, &device); 487 acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
500 if (result)
501 return result;
502
503 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT,
504 tz->trips.hot.flags.enabled); 488 tz->trips.hot.flags.enabled);
505 489
506 /* TBD: Call user-mode "sleep(S4)" function */ 490 /* TBD: Call user-mode "sleep(S4)" function */
@@ -1193,8 +1177,7 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1193 if (!tz) 1177 if (!tz)
1194 return; 1178 return;
1195 1179
1196 if (acpi_bus_get_device(tz->handle, &device)) 1180 device = tz->device;
1197 return;
1198 1181
1199 switch (event) { 1182 switch (event) {
1200 case ACPI_THERMAL_NOTIFY_TEMPERATURE: 1183 case ACPI_THERMAL_NOTIFY_TEMPERATURE:
@@ -1293,7 +1276,7 @@ static int acpi_thermal_add(struct acpi_device *device)
1293 return -ENOMEM; 1276 return -ENOMEM;
1294 memset(tz, 0, sizeof(struct acpi_thermal)); 1277 memset(tz, 0, sizeof(struct acpi_thermal));
1295 1278
1296 tz->handle = device->handle; 1279 tz->device = device;
1297 strcpy(tz->name, device->pnp.bus_id); 1280 strcpy(tz->name, device->pnp.bus_id);
1298 strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); 1281 strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
1299 strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); 1282 strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
@@ -1311,7 +1294,7 @@ static int acpi_thermal_add(struct acpi_device *device)
1311 1294
1312 acpi_thermal_check(tz); 1295 acpi_thermal_check(tz);
1313 1296
1314 status = acpi_install_notify_handler(tz->handle, 1297 status = acpi_install_notify_handler(device->handle,
1315 ACPI_DEVICE_NOTIFY, 1298 ACPI_DEVICE_NOTIFY,
1316 acpi_thermal_notify, tz); 1299 acpi_thermal_notify, tz);
1317 if (ACPI_FAILURE(status)) { 1300 if (ACPI_FAILURE(status)) {
@@ -1352,7 +1335,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1352 /* deferred task may reinsert timer */ 1335 /* deferred task may reinsert timer */
1353 del_timer_sync(&(tz->timer)); 1336 del_timer_sync(&(tz->timer));
1354 1337
1355 status = acpi_remove_notify_handler(tz->handle, 1338 status = acpi_remove_notify_handler(device->handle,
1356 ACPI_DEVICE_NOTIFY, 1339 ACPI_DEVICE_NOTIFY,
1357 acpi_thermal_notify); 1340 acpi_thermal_notify);
1358 1341