diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2006-09-17 12:17:19 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2006-09-17 12:19:31 -0400 |
commit | 9b4f2e9576658c4e52d95dc8d309f51b2e2db096 (patch) | |
tree | 7b1902b0f931783fccc6fee45c6f9c16b4fde5ce /drivers/acpi/thermal.c | |
parent | 3c6c65f5ed5a6d307bd607aecd06d658c0934d88 (diff) | |
parent | 803db244b9f71102e366fd689000c1417b9a7508 (diff) |
ieee1394: merge from Linus
Conflicts: drivers/ieee1394/hosts.c
Patch "lockdep: annotate ieee1394 skb-queue-head locking" was meddling
with patch "ieee1394: fix kerneldoc of hpsb_alloc_host".
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r-- | drivers/acpi/thermal.c | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index c855f4446b5f..5753d06b7860 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -162,7 +162,7 @@ struct acpi_thermal_flags { | |||
162 | }; | 162 | }; |
163 | 163 | ||
164 | struct acpi_thermal { | 164 | struct 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; |
@@ -176,21 +176,21 @@ struct acpi_thermal { | |||
176 | struct timer_list timer; | 176 | struct timer_list timer; |
177 | }; | 177 | }; |
178 | 178 | ||
179 | static struct file_operations acpi_thermal_state_fops = { | 179 | static const struct file_operations acpi_thermal_state_fops = { |
180 | .open = acpi_thermal_state_open_fs, | 180 | .open = acpi_thermal_state_open_fs, |
181 | .read = seq_read, | 181 | .read = seq_read, |
182 | .llseek = seq_lseek, | 182 | .llseek = seq_lseek, |
183 | .release = single_release, | 183 | .release = single_release, |
184 | }; | 184 | }; |
185 | 185 | ||
186 | static struct file_operations acpi_thermal_temp_fops = { | 186 | static const struct file_operations acpi_thermal_temp_fops = { |
187 | .open = acpi_thermal_temp_open_fs, | 187 | .open = acpi_thermal_temp_open_fs, |
188 | .read = seq_read, | 188 | .read = seq_read, |
189 | .llseek = seq_lseek, | 189 | .llseek = seq_lseek, |
190 | .release = single_release, | 190 | .release = single_release, |
191 | }; | 191 | }; |
192 | 192 | ||
193 | static struct file_operations acpi_thermal_trip_fops = { | 193 | static const struct file_operations acpi_thermal_trip_fops = { |
194 | .open = acpi_thermal_trip_open_fs, | 194 | .open = acpi_thermal_trip_open_fs, |
195 | .read = seq_read, | 195 | .read = seq_read, |
196 | .write = acpi_thermal_write_trip_points, | 196 | .write = acpi_thermal_write_trip_points, |
@@ -198,7 +198,7 @@ static struct file_operations acpi_thermal_trip_fops = { | |||
198 | .release = single_release, | 198 | .release = single_release, |
199 | }; | 199 | }; |
200 | 200 | ||
201 | static struct file_operations acpi_thermal_cooling_fops = { | 201 | static const struct file_operations acpi_thermal_cooling_fops = { |
202 | .open = acpi_thermal_cooling_open_fs, | 202 | .open = acpi_thermal_cooling_open_fs, |
203 | .read = seq_read, | 203 | .read = seq_read, |
204 | .write = acpi_thermal_write_cooling_mode, | 204 | .write = acpi_thermal_write_cooling_mode, |
@@ -206,7 +206,7 @@ static struct file_operations acpi_thermal_cooling_fops = { | |||
206 | .release = single_release, | 206 | .release = single_release, |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static struct file_operations acpi_thermal_polling_fops = { | 209 | static const struct file_operations acpi_thermal_polling_fops = { |
210 | .open = acpi_thermal_polling_open_fs, | 210 | .open = acpi_thermal_polling_open_fs, |
211 | .read = seq_read, | 211 | .read = seq_read, |
212 | .write = acpi_thermal_write_polling, | 212 | .write = acpi_thermal_write_polling, |
@@ -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 | ||
454 | static int acpi_thermal_critical(struct acpi_thermal *tz) | 454 | static 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 | ||
484 | static int acpi_thermal_hot(struct acpi_thermal *tz) | 476 | static 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 | ||
@@ -1376,13 +1359,28 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) | |||
1376 | static int acpi_thermal_resume(struct acpi_device *device, int state) | 1359 | static int acpi_thermal_resume(struct acpi_device *device, int state) |
1377 | { | 1360 | { |
1378 | struct acpi_thermal *tz = NULL; | 1361 | struct acpi_thermal *tz = NULL; |
1362 | int i; | ||
1379 | 1363 | ||
1380 | if (!device || !acpi_driver_data(device)) | 1364 | if (!device || !acpi_driver_data(device)) |
1381 | return -EINVAL; | 1365 | return -EINVAL; |
1382 | 1366 | ||
1383 | tz = (struct acpi_thermal *)acpi_driver_data(device); | 1367 | tz = (struct acpi_thermal *)acpi_driver_data(device); |
1384 | 1368 | ||
1385 | acpi_thermal_check(tz); | 1369 | acpi_thermal_get_temperature(tz); |
1370 | |||
1371 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { | ||
1372 | if (tz->trips.active[i].flags.valid) { | ||
1373 | tz->temperature = tz->trips.active[i].temperature; | ||
1374 | tz->trips.active[i].flags.enabled = 0; | ||
1375 | |||
1376 | acpi_thermal_active(tz); | ||
1377 | |||
1378 | tz->state.active |= tz->trips.active[i].flags.enabled; | ||
1379 | tz->state.active_index = i; | ||
1380 | } | ||
1381 | } | ||
1382 | |||
1383 | acpi_thermal_check(tz); | ||
1386 | 1384 | ||
1387 | return AE_OK; | 1385 | return AE_OK; |
1388 | } | 1386 | } |