aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/asus_acpi.c14
-rw-r--r--drivers/acpi/bay.c101
-rw-r--r--drivers/acpi/ec.c4
-rw-r--r--drivers/acpi/events/evgpe.c11
-rw-r--r--drivers/acpi/glue.c62
-rw-r--r--drivers/acpi/i2c_ec.c2
-rw-r--r--drivers/acpi/ibm_acpi.c13
-rw-r--r--drivers/acpi/namespace/nsinit.c9
-rw-r--r--drivers/acpi/osl.c22
-rw-r--r--drivers/acpi/processor_core.c4
-rw-r--r--drivers/acpi/processor_idle.c122
-rw-r--r--drivers/acpi/sleep/poweroff.c1
-rw-r--r--drivers/acpi/tables.c1
-rw-r--r--drivers/acpi/tables/tbxface.c9
-rw-r--r--drivers/acpi/thermal.c5
-rw-r--r--drivers/acpi/toshiba_acpi.c2
17 files changed, 217 insertions, 166 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 20eacc2c9e0e..2d21fed402b5 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -13,6 +13,7 @@ config ACPI
13 depends on IA64 || X86 13 depends on IA64 || X86
14 depends on PCI 14 depends on PCI
15 depends on PM 15 depends on PM
16 select PNP
16 default y 17 default y
17 ---help--- 18 ---help---
18 Advanced Configuration and Power Interface (ACPI) support for 19 Advanced Configuration and Power Interface (ACPI) support for
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index 40a2f4cb4ac3..84de0887a0da 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -141,6 +141,7 @@ struct asus_hotk {
141 W5A, //W5A 141 W5A, //W5A
142 W3V, //W3030V 142 W3V, //W3030V
143 xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N 143 xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N
144 A4S, //Z81sp
144 //(Centrino) 145 //(Centrino)
145 END_MODEL 146 END_MODEL
146 } model; //Models currently supported 147 } model; //Models currently supported
@@ -397,7 +398,16 @@ static struct model_data model_conf[END_MODEL] = {
397 .brightness_set = "SPLV", 398 .brightness_set = "SPLV",
398 .brightness_get = "GPLV", 399 .brightness_get = "GPLV",
399 .display_set = "SDSP", 400 .display_set = "SDSP",
400 .display_get = "\\ADVG"} 401 .display_get = "\\ADVG"},
402
403 {
404 .name = "A4S",
405 .brightness_set = "SPLV",
406 .brightness_get = "GPLV",
407 .mt_bt_switch = "BLED",
408 .mt_wled = "WLED"
409 }
410
401}; 411};
402 412
403/* procdir we use */ 413/* procdir we use */
@@ -1117,6 +1127,8 @@ static int asus_model_match(char *model)
1117 return W3V; 1127 return W3V;
1118 else if (strncmp(model, "W5A", 3) == 0) 1128 else if (strncmp(model, "W5A", 3) == 0)
1119 return W5A; 1129 return W5A;
1130 else if (strncmp(model, "A4S", 3) == 0)
1131 return A4S;
1120 else 1132 else
1121 return END_MODEL; 1133 return END_MODEL;
1122} 1134}
diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c
index 36dcb899b23c..fb3f31b5e69f 100644
--- a/drivers/acpi/bay.c
+++ b/drivers/acpi/bay.c
@@ -45,18 +45,6 @@ MODULE_LICENSE("GPL");
45 acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\ 45 acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
46 printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); } 46 printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); }
47static void bay_notify(acpi_handle handle, u32 event, void *data); 47static void bay_notify(acpi_handle handle, u32 event, void *data);
48static int acpi_bay_add(struct acpi_device *device);
49static int acpi_bay_remove(struct acpi_device *device, int type);
50
51static struct acpi_driver acpi_bay_driver = {
52 .name = "bay",
53 .class = ACPI_BAY_CLASS,
54 .ids = ACPI_BAY_HID,
55 .ops = {
56 .add = acpi_bay_add,
57 .remove = acpi_bay_remove,
58 },
59};
60 48
61struct bay { 49struct bay {
62 acpi_handle handle; 50 acpi_handle handle;
@@ -232,14 +220,6 @@ int eject_removable_drive(struct device *dev)
232} 220}
233EXPORT_SYMBOL_GPL(eject_removable_drive); 221EXPORT_SYMBOL_GPL(eject_removable_drive);
234 222
235static int acpi_bay_add(struct acpi_device *device)
236{
237 bay_dprintk(device->handle, "adding bay device");
238 strcpy(acpi_device_name(device), "Dockable Bay");
239 strcpy(acpi_device_class(device), "bay");
240 return 0;
241}
242
243static int acpi_bay_add_fs(struct bay *bay) 223static int acpi_bay_add_fs(struct bay *bay)
244{ 224{
245 int ret; 225 int ret;
@@ -301,7 +281,7 @@ static int bay_add(acpi_handle handle, int id)
301 281
302 /* initialize platform device stuff */ 282 /* initialize platform device stuff */
303 pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0); 283 pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0);
304 if (pdev == NULL) { 284 if (IS_ERR(pdev)) {
305 printk(KERN_ERR PREFIX "Error registering bay device\n"); 285 printk(KERN_ERR PREFIX "Error registering bay device\n");
306 goto bay_add_err; 286 goto bay_add_err;
307 } 287 }
@@ -337,52 +317,6 @@ bay_add_err:
337 return -ENODEV; 317 return -ENODEV;
338} 318}
339 319
340static int acpi_bay_remove(struct acpi_device *device, int type)
341{
342 /*** FIXME: do something here */
343 return 0;
344}
345
346/**
347 * bay_create_acpi_device - add new devices to acpi
348 * @handle - handle of the device to add
349 *
350 * This function will create a new acpi_device for the given
351 * handle if one does not exist already. This should cause
352 * acpi to scan for drivers for the given devices, and call
353 * matching driver's add routine.
354 *
355 * Returns a pointer to the acpi_device corresponding to the handle.
356 */
357static struct acpi_device * bay_create_acpi_device(acpi_handle handle)
358{
359 struct acpi_device *device = NULL;
360 struct acpi_device *parent_device;
361 acpi_handle parent;
362 int ret;
363
364 bay_dprintk(handle, "Trying to get device");
365 if (acpi_bus_get_device(handle, &device)) {
366 /*
367 * no device created for this object,
368 * so we should create one.
369 */
370 bay_dprintk(handle, "No device for handle");
371 acpi_get_parent(handle, &parent);
372 if (acpi_bus_get_device(parent, &parent_device))
373 parent_device = NULL;
374
375 ret = acpi_bus_add(&device, parent_device, handle,
376 ACPI_BUS_TYPE_DEVICE);
377 if (ret) {
378 pr_debug("error adding bus, %x\n",
379 -ret);
380 return NULL;
381 }
382 }
383 return device;
384}
385
386/** 320/**
387 * bay_notify - act upon an acpi bay notification 321 * bay_notify - act upon an acpi bay notification
388 * @handle: the bay handle 322 * @handle: the bay handle
@@ -392,38 +326,19 @@ static struct acpi_device * bay_create_acpi_device(acpi_handle handle)
392 */ 326 */
393static void bay_notify(acpi_handle handle, u32 event, void *data) 327static void bay_notify(acpi_handle handle, u32 event, void *data)
394{ 328{
395 struct acpi_device *dev; 329 struct bay *bay_dev = (struct bay *)data;
330 struct device *dev = &bay_dev->pdev->dev;
396 331
397 bay_dprintk(handle, "Bay event"); 332 bay_dprintk(handle, "Bay event");
398 333
399 switch(event) { 334 switch(event) {
400 case ACPI_NOTIFY_BUS_CHECK: 335 case ACPI_NOTIFY_BUS_CHECK:
401 printk("Bus Check\n");
402 case ACPI_NOTIFY_DEVICE_CHECK: 336 case ACPI_NOTIFY_DEVICE_CHECK:
403 printk("Device Check\n");
404 dev = bay_create_acpi_device(handle);
405 if (dev)
406 acpi_bus_generate_event(dev, event, 0);
407 else
408 printk("No device for generating event\n");
409 /* wouldn't it be a good idea to just rescan SATA
410 * right here?
411 */
412 break;
413 case ACPI_NOTIFY_EJECT_REQUEST: 337 case ACPI_NOTIFY_EJECT_REQUEST:
414 printk("Eject request\n"); 338 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
415 dev = bay_create_acpi_device(handle);
416 if (dev)
417 acpi_bus_generate_event(dev, event, 0);
418 else
419 printk("No device for generating eventn");
420
421 /* wouldn't it be a good idea to just call the
422 * eject_device here if we were a SATA device?
423 */
424 break; 339 break;
425 default: 340 default:
426 printk("unknown event %d\n", event); 341 printk(KERN_ERR PREFIX "Bay: unknown event %d\n", event);
427 } 342 }
428} 343}
429 344
@@ -455,10 +370,6 @@ static int __init bay_init(void)
455 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 370 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
456 ACPI_UINT32_MAX, find_bay, &bays, NULL); 371 ACPI_UINT32_MAX, find_bay, &bays, NULL);
457 372
458 if (bays)
459 if ((acpi_bus_register_driver(&acpi_bay_driver) < 0))
460 printk(KERN_ERR "Unable to register bay driver\n");
461
462 if (!bays) 373 if (!bays)
463 return -ENODEV; 374 return -ENODEV;
464 375
@@ -479,8 +390,6 @@ static void __exit bay_exit(void)
479 kfree(bay->name); 390 kfree(bay->name);
480 kfree(bay); 391 kfree(bay);
481 } 392 }
482
483 acpi_bus_unregister_driver(&acpi_bay_driver);
484} 393}
485 394
486postcore_initcall(bay_init); 395postcore_initcall(bay_init);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index c1f6251a80a3..ab6888373795 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -279,8 +279,10 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
279 mutex_lock(&ec->lock); 279 mutex_lock(&ec->lock);
280 if (ec->global_lock) { 280 if (ec->global_lock) {
281 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 281 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
282 if (ACPI_FAILURE(status)) 282 if (ACPI_FAILURE(status)) {
283 mutex_unlock(&ec->lock);
283 return -ENODEV; 284 return -ENODEV;
285 }
284 } 286 }
285 287
286 /* Make sure GPE is enabled before doing transaction */ 288 /* Make sure GPE is enabled before doing transaction */
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index dfac3ecc596e..635ba449ebc2 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -636,17 +636,6 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
636 } 636 }
637 } 637 }
638 638
639 if (!acpi_gbl_system_awake_and_running) {
640 /*
641 * We just woke up because of a wake GPE. Disable any further GPEs
642 * until we are fully up and running (Only wake GPEs should be enabled
643 * at this time, but we just brute-force disable them all.)
644 * 1) We must disable this particular wake GPE so it won't fire again
645 * 2) We want to disable all wake GPEs, since we are now awake
646 */
647 (void)acpi_hw_disable_all_gpes();
648 }
649
650 /* 639 /*
651 * Dispatch the GPE to either an installed handler, or the control method 640 * Dispatch the GPE to either an installed handler, or the control method
652 * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke 641 * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 7b6c9ff9bebe..4334c208841a 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -241,3 +241,65 @@ static int __init init_acpi_device_notify(void)
241} 241}
242 242
243arch_initcall(init_acpi_device_notify); 243arch_initcall(init_acpi_device_notify);
244
245
246#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE)
247
248/* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find
249 * its device node and pass extra config data. This helps its driver use
250 * capabilities that the now-obsolete mc146818 didn't have, and informs it
251 * that this board's RTC is wakeup-capable (per ACPI spec).
252 */
253#include <linux/mc146818rtc.h>
254
255static struct cmos_rtc_board_info rtc_info;
256
257
258/* PNP devices are registered in a subsys_initcall();
259 * ACPI specifies the PNP IDs to use.
260 */
261#include <linux/pnp.h>
262
263static int __init pnp_match(struct device *dev, void *data)
264{
265 static const char *ids[] = { "PNP0b00", "PNP0b01", "PNP0b02", };
266 struct pnp_dev *pnp = to_pnp_dev(dev);
267 int i;
268
269 for (i = 0; i < ARRAY_SIZE(ids); i++) {
270 if (compare_pnp_id(pnp->id, ids[i]) != 0)
271 return 1;
272 }
273 return 0;
274}
275
276static struct device *__init get_rtc_dev(void)
277{
278 return bus_find_device(&pnp_bus_type, NULL, NULL, pnp_match);
279}
280
281static int __init acpi_rtc_init(void)
282{
283 struct device *dev = get_rtc_dev();
284
285 if (dev) {
286 rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm;
287 rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm;
288 rtc_info.rtc_century = acpi_gbl_FADT.century;
289
290 /* NOTE: acpi_gbl_FADT->rtcs4 is NOT currently useful */
291
292 dev->platform_data = &rtc_info;
293
294 /* RTC always wakes from S1/S2/S3, and often S4/STD */
295 device_init_wakeup(dev, 1);
296
297 put_device(dev);
298 } else
299 pr_debug("ACPI: RTC unavailable?\n");
300 return 0;
301}
302/* do this between RTC subsys_initcall() and rtc_cmos driver_initcall() */
303fs_initcall(acpi_rtc_init);
304
305#endif
diff --git a/drivers/acpi/i2c_ec.c b/drivers/acpi/i2c_ec.c
index a29b82793797..acab4a481897 100644
--- a/drivers/acpi/i2c_ec.c
+++ b/drivers/acpi/i2c_ec.c
@@ -14,7 +14,6 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/stddef.h> 16#include <linux/stddef.h>
17#include <linux/sched.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/i2c.h> 18#include <linux/i2c.h>
20#include <linux/acpi.h> 19#include <linux/acpi.h>
@@ -339,6 +338,7 @@ static int acpi_ec_hc_add(struct acpi_device *device)
339 smbus->adapter.owner = THIS_MODULE; 338 smbus->adapter.owner = THIS_MODULE;
340 smbus->adapter.algo = &acpi_ec_smbus_algorithm; 339 smbus->adapter.algo = &acpi_ec_smbus_algorithm;
341 smbus->adapter.algo_data = smbus; 340 smbus->adapter.algo_data = smbus;
341 smbus->adapter.dev.parent = &device->dev;
342 342
343 if (i2c_add_adapter(&smbus->adapter)) { 343 if (i2c_add_adapter(&smbus->adapter)) {
344 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 344 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index c6144ca66638..2429e1180fa9 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -496,6 +496,10 @@ static int ibm_acpi_driver_init(void)
496 printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION); 496 printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION);
497 printk(IBM_INFO "%s\n", IBM_URL); 497 printk(IBM_INFO "%s\n", IBM_URL);
498 498
499 if (ibm_thinkpad_ec_found)
500 printk(IBM_INFO "ThinkPad EC firmware %s\n",
501 ibm_thinkpad_ec_found);
502
499 return 0; 503 return 0;
500} 504}
501 505
@@ -2617,7 +2621,7 @@ static void __init ibm_handle_init(char *name,
2617 ibm_handle_init(#object, &object##_handle, *object##_parent, \ 2621 ibm_handle_init(#object, &object##_handle, *object##_parent, \
2618 object##_paths, ARRAY_SIZE(object##_paths), &object##_path) 2622 object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
2619 2623
2620static int set_ibm_param(const char *val, struct kernel_param *kp) 2624static int __init set_ibm_param(const char *val, struct kernel_param *kp)
2621{ 2625{
2622 unsigned int i; 2626 unsigned int i;
2623 2627
@@ -2659,7 +2663,8 @@ static void acpi_ibm_exit(void)
2659 for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--) 2663 for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--)
2660 ibm_exit(&ibms[i]); 2664 ibm_exit(&ibms[i]);
2661 2665
2662 remove_proc_entry(IBM_DIR, acpi_root_dir); 2666 if (proc_dir)
2667 remove_proc_entry(IBM_DIR, acpi_root_dir);
2663 2668
2664 if (ibm_thinkpad_ec_found) 2669 if (ibm_thinkpad_ec_found)
2665 kfree(ibm_thinkpad_ec_found); 2670 kfree(ibm_thinkpad_ec_found);
@@ -2710,9 +2715,6 @@ static int __init acpi_ibm_init(void)
2710 2715
2711 /* Models with newer firmware report the EC in DMI */ 2716 /* Models with newer firmware report the EC in DMI */
2712 ibm_thinkpad_ec_found = check_dmi_for_ec(); 2717 ibm_thinkpad_ec_found = check_dmi_for_ec();
2713 if (ibm_thinkpad_ec_found)
2714 printk(IBM_INFO "ThinkPad EC firmware %s\n",
2715 ibm_thinkpad_ec_found);
2716 2718
2717 /* these handles are not required */ 2719 /* these handles are not required */
2718 IBM_HANDLE_INIT(vid); 2720 IBM_HANDLE_INIT(vid);
@@ -2742,6 +2744,7 @@ static int __init acpi_ibm_init(void)
2742 proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); 2744 proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
2743 if (!proc_dir) { 2745 if (!proc_dir) {
2744 printk(IBM_ERR "unable to create proc dir %s", IBM_DIR); 2746 printk(IBM_ERR "unable to create proc dir %s", IBM_DIR);
2747 acpi_ibm_exit();
2745 return -ENODEV; 2748 return -ENODEV;
2746 } 2749 }
2747 proc_dir->owner = THIS_MODULE; 2750 proc_dir->owner = THIS_MODULE;
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 326af8fc0ce7..33db2241044e 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -45,6 +45,7 @@
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
47#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
48#include <linux/nmi.h>
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsinit") 51ACPI_MODULE_NAME("nsinit")
@@ -534,7 +535,15 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
534 info->parameter_type = ACPI_PARAM_ARGS; 535 info->parameter_type = ACPI_PARAM_ARGS;
535 info->flags = ACPI_IGNORE_RETURN_VALUE; 536 info->flags = ACPI_IGNORE_RETURN_VALUE;
536 537
538 /*
539 * Some hardware relies on this being executed as atomically
540 * as possible (without an NMI being received in the middle of
541 * this) - so disable NMIs and initialize the device:
542 */
543 acpi_nmi_disable();
537 status = acpi_ns_evaluate(info); 544 status = acpi_ns_evaluate(info);
545 acpi_nmi_enable();
546
538 if (ACPI_SUCCESS(status)) { 547 if (ACPI_SUCCESS(status)) {
539 walk_info->num_INI++; 548 walk_info->num_INI++;
540 549
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 851ac492dbbc..ee0b9f761f76 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -205,7 +205,7 @@ void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
205{ 205{
206 if (phys > ULONG_MAX) { 206 if (phys > ULONG_MAX) {
207 printk(KERN_ERR PREFIX "Cannot map memory that high\n"); 207 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
208 return 0; 208 return NULL;
209 } 209 }
210 if (acpi_gbl_permanent_mmap) 210 if (acpi_gbl_permanent_mmap)
211 /* 211 /*
@@ -890,26 +890,6 @@ u32 acpi_os_get_line(char *buffer)
890} 890}
891#endif /* ACPI_FUTURE_USAGE */ 891#endif /* ACPI_FUTURE_USAGE */
892 892
893/* Assumes no unreadable holes inbetween */
894u8 acpi_os_readable(void *ptr, acpi_size len)
895{
896#if defined(__i386__) || defined(__x86_64__)
897 char tmp;
898 return !__get_user(tmp, (char __user *)ptr)
899 && !__get_user(tmp, (char __user *)ptr + len - 1);
900#endif
901 return 1;
902}
903
904#ifdef ACPI_FUTURE_USAGE
905u8 acpi_os_writable(void *ptr, acpi_size len)
906{
907 /* could do dummy write (racy) or a kernel page table lookup.
908 The later may be difficult at early boot when kmap doesn't work yet. */
909 return 1;
910}
911#endif
912
913acpi_status acpi_os_signal(u32 function, void *info) 893acpi_status acpi_os_signal(u32 function, void *info)
914{ 894{
915 switch (function) { 895 switch (function) {
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 911fc8cae0c1..99d1516d1e70 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -403,7 +403,7 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
403 if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { 403 if (lsapic->lapic_flags & ACPI_MADT_ENABLED) {
404 /* First check against id */ 404 /* First check against id */
405 if (lsapic->processor_id == acpi_id) { 405 if (lsapic->processor_id == acpi_id) {
406 *apic_id = lsapic->id; 406 *apic_id = (lsapic->id << 8) | lsapic->eid;
407 return 1; 407 return 1;
408 /* Check against optional uid */ 408 /* Check against optional uid */
409 } else if (entry->length >= 16 && 409 } else if (entry->length >= 16 &&
@@ -1004,7 +1004,7 @@ static int __init acpi_processor_init(void)
1004#ifdef CONFIG_SMP 1004#ifdef CONFIG_SMP
1005 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, 1005 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0,
1006 (struct acpi_table_header **)&madt))) 1006 (struct acpi_table_header **)&madt)))
1007 madt = 0; 1007 madt = NULL;
1008#endif 1008#endif
1009 1009
1010 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 1010 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 92f5185464d2..60773005b8af 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -39,6 +39,25 @@
39#include <linux/moduleparam.h> 39#include <linux/moduleparam.h>
40#include <linux/sched.h> /* need_resched() */ 40#include <linux/sched.h> /* need_resched() */
41#include <linux/latency.h> 41#include <linux/latency.h>
42#include <linux/clockchips.h>
43
44/*
45 * Include the apic definitions for x86 to have the APIC timer related defines
46 * available also for UP (on SMP it gets magically included via linux/smp.h).
47 * asm/acpi.h is not an option, as it would require more include magic. Also
48 * creating an empty asm-ia64/apic.h would just trade pest vs. cholera.
49 */
50#ifdef CONFIG_X86
51#include <asm/apic.h>
52#endif
53
54/*
55 * Include the apic definitions for x86 to have the APIC timer related defines
56 * available also for UP (on SMP it gets magically included via linux/smp.h).
57 */
58#ifdef CONFIG_X86
59#include <asm/apic.h>
60#endif
42 61
43#include <asm/io.h> 62#include <asm/io.h>
44#include <asm/uaccess.h> 63#include <asm/uaccess.h>
@@ -237,6 +256,81 @@ static void acpi_cstate_enter(struct acpi_processor_cx *cstate)
237 } 256 }
238} 257}
239 258
259#ifdef ARCH_APICTIMER_STOPS_ON_C3
260
261/*
262 * Some BIOS implementations switch to C3 in the published C2 state.
263 * This seems to be a common problem on AMD boxen, but other vendors
264 * are affected too. We pick the most conservative approach: we assume
265 * that the local APIC stops in both C2 and C3.
266 */
267static void acpi_timer_check_state(int state, struct acpi_processor *pr,
268 struct acpi_processor_cx *cx)
269{
270 struct acpi_processor_power *pwr = &pr->power;
271
272 /*
273 * Check, if one of the previous states already marked the lapic
274 * unstable
275 */
276 if (pwr->timer_broadcast_on_state < state)
277 return;
278
279 if (cx->type >= ACPI_STATE_C2)
280 pr->power.timer_broadcast_on_state = state;
281}
282
283static void acpi_propagate_timer_broadcast(struct acpi_processor *pr)
284{
285#ifdef CONFIG_GENERIC_CLOCKEVENTS
286 unsigned long reason;
287
288 reason = pr->power.timer_broadcast_on_state < INT_MAX ?
289 CLOCK_EVT_NOTIFY_BROADCAST_ON : CLOCK_EVT_NOTIFY_BROADCAST_OFF;
290
291 clockevents_notify(reason, &pr->id);
292#else
293 cpumask_t mask = cpumask_of_cpu(pr->id);
294
295 if (pr->power.timer_broadcast_on_state < INT_MAX)
296 on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1);
297 else
298 on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1);
299#endif
300}
301
302/* Power(C) State timer broadcast control */
303static void acpi_state_timer_broadcast(struct acpi_processor *pr,
304 struct acpi_processor_cx *cx,
305 int broadcast)
306{
307#ifdef CONFIG_GENERIC_CLOCKEVENTS
308
309 int state = cx - pr->power.states;
310
311 if (state >= pr->power.timer_broadcast_on_state) {
312 unsigned long reason;
313
314 reason = broadcast ? CLOCK_EVT_NOTIFY_BROADCAST_ENTER :
315 CLOCK_EVT_NOTIFY_BROADCAST_EXIT;
316 clockevents_notify(reason, &pr->id);
317 }
318#endif
319}
320
321#else
322
323static void acpi_timer_check_state(int state, struct acpi_processor *pr,
324 struct acpi_processor_cx *cstate) { }
325static void acpi_propagate_timer_broadcast(struct acpi_processor *pr) { }
326static void acpi_state_timer_broadcast(struct acpi_processor *pr,
327 struct acpi_processor_cx *cx,
328 int broadcast)
329{
330}
331
332#endif
333
240static void acpi_processor_idle(void) 334static void acpi_processor_idle(void)
241{ 335{
242 struct acpi_processor *pr = NULL; 336 struct acpi_processor *pr = NULL;
@@ -381,6 +475,7 @@ static void acpi_processor_idle(void)
381 /* Get start time (ticks) */ 475 /* Get start time (ticks) */
382 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 476 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
383 /* Invoke C2 */ 477 /* Invoke C2 */
478 acpi_state_timer_broadcast(pr, cx, 1);
384 acpi_cstate_enter(cx); 479 acpi_cstate_enter(cx);
385 /* Get end time (ticks) */ 480 /* Get end time (ticks) */
386 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 481 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
@@ -395,6 +490,7 @@ static void acpi_processor_idle(void)
395 /* Compute time (ticks) that we were actually asleep */ 490 /* Compute time (ticks) that we were actually asleep */
396 sleep_ticks = 491 sleep_ticks =
397 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; 492 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
493 acpi_state_timer_broadcast(pr, cx, 0);
398 break; 494 break;
399 495
400 case ACPI_STATE_C3: 496 case ACPI_STATE_C3:
@@ -416,6 +512,7 @@ static void acpi_processor_idle(void)
416 /* Get start time (ticks) */ 512 /* Get start time (ticks) */
417 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 513 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
418 /* Invoke C3 */ 514 /* Invoke C3 */
515 acpi_state_timer_broadcast(pr, cx, 1);
419 acpi_cstate_enter(cx); 516 acpi_cstate_enter(cx);
420 /* Get end time (ticks) */ 517 /* Get end time (ticks) */
421 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 518 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
@@ -435,6 +532,7 @@ static void acpi_processor_idle(void)
435 /* Compute time (ticks) that we were actually asleep */ 532 /* Compute time (ticks) that we were actually asleep */
436 sleep_ticks = 533 sleep_ticks =
437 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; 534 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
535 acpi_state_timer_broadcast(pr, cx, 0);
438 break; 536 break;
439 537
440 default: 538 default:
@@ -903,11 +1001,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
903 unsigned int i; 1001 unsigned int i;
904 unsigned int working = 0; 1002 unsigned int working = 0;
905 1003
906#ifdef ARCH_APICTIMER_STOPS_ON_C3 1004 pr->power.timer_broadcast_on_state = INT_MAX;
907 int timer_broadcast = 0;
908 cpumask_t mask = cpumask_of_cpu(pr->id);
909 on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1);
910#endif
911 1005
912 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 1006 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
913 struct acpi_processor_cx *cx = &pr->power.states[i]; 1007 struct acpi_processor_cx *cx = &pr->power.states[i];
@@ -919,21 +1013,14 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
919 1013
920 case ACPI_STATE_C2: 1014 case ACPI_STATE_C2:
921 acpi_processor_power_verify_c2(cx); 1015 acpi_processor_power_verify_c2(cx);
922#ifdef ARCH_APICTIMER_STOPS_ON_C3 1016 if (cx->valid)
923 /* Some AMD systems fake C3 as C2, but still 1017 acpi_timer_check_state(i, pr, cx);
924 have timer troubles */
925 if (cx->valid &&
926 boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
927 timer_broadcast++;
928#endif
929 break; 1018 break;
930 1019
931 case ACPI_STATE_C3: 1020 case ACPI_STATE_C3:
932 acpi_processor_power_verify_c3(pr, cx); 1021 acpi_processor_power_verify_c3(pr, cx);
933#ifdef ARCH_APICTIMER_STOPS_ON_C3
934 if (cx->valid) 1022 if (cx->valid)
935 timer_broadcast++; 1023 acpi_timer_check_state(i, pr, cx);
936#endif
937 break; 1024 break;
938 } 1025 }
939 1026
@@ -941,10 +1028,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
941 working++; 1028 working++;
942 } 1029 }
943 1030
944#ifdef ARCH_APICTIMER_STOPS_ON_C3 1031 acpi_propagate_timer_broadcast(pr);
945 if (timer_broadcast)
946 on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1);
947#endif
948 1032
949 return (working); 1033 return (working);
950} 1034}
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index 47fb4b394eec..d9801eff6489 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -12,7 +12,6 @@
12#include <linux/pm.h> 12#include <linux/pm.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <acpi/acpi_bus.h> 14#include <acpi/acpi_bus.h>
15#include <linux/sched.h>
16#include <linux/sysdev.h> 15#include <linux/sysdev.h>
17#include <asm/io.h> 16#include <asm/io.h>
18#include "sleep.h" 17#include "sleep.h"
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 4ed640031e9a..849e2c361804 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -25,7 +25,6 @@
25 25
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/sched.h>
29#include <linux/smp.h> 28#include <linux/smp.h>
30#include <linux/string.h> 29#include <linux/string.h>
31#include <linux/types.h> 30#include <linux/types.h>
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 807978d5381a..417ef5fa7666 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -338,9 +338,9 @@ acpi_status acpi_unload_table_id(acpi_owner_id id)
338 int i; 338 int i;
339 acpi_status status = AE_NOT_EXIST; 339 acpi_status status = AE_NOT_EXIST;
340 340
341 ACPI_FUNCTION_TRACE(acpi_unload_table); 341 ACPI_FUNCTION_TRACE(acpi_unload_table_id);
342 342
343 /* Find table from the requested type list */ 343 /* Find table in the global table list */
344 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { 344 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
345 if (id != acpi_gbl_root_table_list.tables[i].owner_id) { 345 if (id != acpi_gbl_root_table_list.tables[i].owner_id) {
346 continue; 346 continue;
@@ -352,8 +352,9 @@ acpi_status acpi_unload_table_id(acpi_owner_id id)
352 * simply a position within the hierarchy 352 * simply a position within the hierarchy
353 */ 353 */
354 acpi_tb_delete_namespace_by_owner(i); 354 acpi_tb_delete_namespace_by_owner(i);
355 acpi_tb_release_owner_id(i); 355 status = acpi_tb_release_owner_id(i);
356 acpi_tb_set_table_loaded_flag(i, FALSE); 356 acpi_tb_set_table_loaded_flag(i, FALSE);
357 break;
357 } 358 }
358 return_ACPI_STATUS(status); 359 return_ACPI_STATUS(status);
359} 360}
@@ -408,7 +409,7 @@ acpi_get_table(char *signature,
408 } 409 }
409 410
410 if (!acpi_gbl_permanent_mmap) { 411 if (!acpi_gbl_permanent_mmap) {
411 acpi_gbl_root_table_list.tables[i].pointer = 0; 412 acpi_gbl_root_table_list.tables[i].pointer = NULL;
412 } 413 }
413 414
414 return (status); 415 return (status);
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index f50a405d0134..15022bc86336 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -36,7 +36,8 @@
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/types.h> 37#include <linux/types.h>
38#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
39#include <linux/sched.h> 39#include <linux/timer.h>
40#include <linux/jiffies.h>
40#include <linux/kmod.h> 41#include <linux/kmod.h>
41#include <linux/seq_file.h> 42#include <linux/seq_file.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
@@ -268,7 +269,7 @@ static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
268 269
269 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 270 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
270 "Polling frequency set to %lu seconds\n", 271 "Polling frequency set to %lu seconds\n",
271 tz->polling_frequency)); 272 tz->polling_frequency/10));
272 273
273 return 0; 274 return 0;
274} 275}
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index d9b651ffcdc0..0208d3a3f598 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -125,7 +125,7 @@ static int write_acpi_int(const char *methodName, int val)
125 union acpi_object in_objs[1]; 125 union acpi_object in_objs[1];
126 acpi_status status; 126 acpi_status status;
127 127
128 params.count = sizeof(in_objs) / sizeof(in_objs[0]); 128 params.count = ARRAY_SIZE(in_objs);
129 params.pointer = in_objs; 129 params.pointer = in_objs;
130 in_objs[0].type = ACPI_TYPE_INTEGER; 130 in_objs[0].type = ACPI_TYPE_INTEGER;
131 in_objs[0].integer.value = val; 131 in_objs[0].integer.value = val;