aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig6
-rw-r--r--drivers/acpi/ac.c4
-rw-r--r--drivers/acpi/acpi_memhotplug.c21
-rw-r--r--drivers/acpi/battery.c9
-rw-r--r--drivers/acpi/bus.c13
-rw-r--r--drivers/acpi/button.c4
-rw-r--r--drivers/acpi/cm_sbs.c46
-rw-r--r--drivers/acpi/dispatcher/dsinit.c10
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c23
-rw-r--r--drivers/acpi/dispatcher/dswexec.c4
-rw-r--r--drivers/acpi/dock.c14
-rw-r--r--drivers/acpi/ec.c2
-rw-r--r--drivers/acpi/event.c2
-rw-r--r--drivers/acpi/events/evregion.c44
-rw-r--r--drivers/acpi/events/evxface.c44
-rw-r--r--drivers/acpi/events/evxfregn.c13
-rw-r--r--drivers/acpi/executer/exconfig.c1
-rw-r--r--drivers/acpi/executer/exconvrt.c3
-rw-r--r--drivers/acpi/executer/exmutex.c4
-rw-r--r--drivers/acpi/executer/exsystem.c8
-rw-r--r--drivers/acpi/fan.c2
-rw-r--r--drivers/acpi/hotkey.c291
-rw-r--r--drivers/acpi/i2c_ec.c2
-rw-r--r--drivers/acpi/namespace/nsalloc.c13
-rw-r--r--drivers/acpi/osl.c100
-rw-r--r--drivers/acpi/parser/psutils.c2
-rw-r--r--drivers/acpi/pci_link.c7
-rw-r--r--drivers/acpi/power.c2
-rw-r--r--drivers/acpi/processor_core.c2
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/acpi/sbs.c3
-rw-r--r--drivers/acpi/scan.c12
-rw-r--r--drivers/acpi/sleep/proc.c6
-rw-r--r--drivers/acpi/system.c6
-rw-r--r--drivers/acpi/tables/tbget.c12
-rw-r--r--drivers/acpi/tables/tbinstal.c21
-rw-r--r--drivers/acpi/tables/tbrsdt.c27
-rw-r--r--drivers/acpi/tables/tbxface.c32
-rw-r--r--drivers/acpi/thermal.c27
-rw-r--r--drivers/acpi/utilities/utalloc.c2
-rw-r--r--drivers/acpi/utilities/utdebug.c4
-rw-r--r--drivers/acpi/utilities/utdelete.c13
-rw-r--r--drivers/acpi/utilities/utmisc.c25
-rw-r--r--drivers/acpi/utilities/utmutex.c8
-rw-r--r--drivers/acpi/utilities/utstate.c7
-rw-r--r--drivers/acpi/utils.c2
46 files changed, 460 insertions, 445 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index fef7bab12244..56c5ba874623 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -107,7 +107,6 @@ config ACPI_BUTTON
107config ACPI_VIDEO 107config ACPI_VIDEO
108 tristate "Video" 108 tristate "Video"
109 depends on X86 109 depends on X86
110 default y
111 help 110 help
112 This driver implement the ACPI Extensions For Display Adapters 111 This driver implement the ACPI Extensions For Display Adapters
113 for integrated graphics devices on motherboard, as specified in 112 for integrated graphics devices on motherboard, as specified in
@@ -135,8 +134,7 @@ config ACPI_FAN
135 134
136config ACPI_DOCK 135config ACPI_DOCK
137 tristate "Dock" 136 tristate "Dock"
138 depends on !ACPI_IBM_DOCK 137 depends on EXPERIMENTAL
139 default y
140 help 138 help
141 This driver adds support for ACPI controlled docking stations 139 This driver adds support for ACPI controlled docking stations
142 140
@@ -214,6 +212,7 @@ config ACPI_IBM
214config ACPI_IBM_DOCK 212config ACPI_IBM_DOCK
215 bool "Legacy Docking Station Support" 213 bool "Legacy Docking Station Support"
216 depends on ACPI_IBM 214 depends on ACPI_IBM
215 depends on ACPI_DOCK=n
217 default n 216 default n
218 ---help--- 217 ---help---
219 Allows the ibm_acpi driver to handle docking station events. 218 Allows the ibm_acpi driver to handle docking station events.
@@ -357,7 +356,6 @@ config ACPI_SBS
357 tristate "Smart Battery System (EXPERIMENTAL)" 356 tristate "Smart Battery System (EXPERIMENTAL)"
358 depends on X86 && I2C 357 depends on X86 && I2C
359 depends on EXPERIMENTAL 358 depends on EXPERIMENTAL
360 default y
361 help 359 help
362 This driver adds support for the Smart Battery System. 360 This driver adds support for the Smart Battery System.
363 Depends on I2C (Device Drivers ---> I2C support) 361 Depends on I2C (Device Drivers ---> I2C support)
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 24ccf81d135f..11abc7bf777e 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -72,7 +72,7 @@ struct acpi_ac {
72 unsigned long state; 72 unsigned long state;
73}; 73};
74 74
75static struct file_operations acpi_ac_fops = { 75static const struct file_operations acpi_ac_fops = {
76 .open = acpi_ac_open_fs, 76 .open = acpi_ac_open_fs,
77 .read = seq_read, 77 .read = seq_read,
78 .llseek = seq_lseek, 78 .llseek = seq_lseek,
@@ -285,6 +285,8 @@ static int __init acpi_ac_init(void)
285{ 285{
286 int result; 286 int result;
287 287
288 if (acpi_disabled)
289 return -ENODEV;
288 290
289 acpi_ac_dir = acpi_lock_ac_dir(); 291 acpi_ac_dir = acpi_lock_ac_dir();
290 if (!acpi_ac_dir) 292 if (!acpi_ac_dir)
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 81e970adeab3..1dda370f402b 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -129,11 +129,15 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
129 struct acpi_memory_info *info, *n; 129 struct acpi_memory_info *info, *n;
130 130
131 131
132 if (!list_empty(&mem_device->res_list))
133 return 0;
134
132 status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS, 135 status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
133 acpi_memory_get_resource, mem_device); 136 acpi_memory_get_resource, mem_device);
134 if (ACPI_FAILURE(status)) { 137 if (ACPI_FAILURE(status)) {
135 list_for_each_entry_safe(info, n, &mem_device->res_list, list) 138 list_for_each_entry_safe(info, n, &mem_device->res_list, list)
136 kfree(info); 139 kfree(info);
140 INIT_LIST_HEAD(&mem_device->res_list);
137 return -EINVAL; 141 return -EINVAL;
138 } 142 }
139 143
@@ -230,17 +234,10 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
230 * (i.e. memory-hot-remove function) 234 * (i.e. memory-hot-remove function)
231 */ 235 */
232 list_for_each_entry(info, &mem_device->res_list, list) { 236 list_for_each_entry(info, &mem_device->res_list, list) {
233 u64 start_pfn, end_pfn; 237 if (info->enabled) { /* just sanity check...*/
234
235 start_pfn = info->start_addr >> PAGE_SHIFT;
236 end_pfn = (info->start_addr + info->length - 1) >> PAGE_SHIFT;
237
238 if (pfn_valid(start_pfn) || pfn_valid(end_pfn)) {
239 /* already enabled. try next area */
240 num_enabled++; 238 num_enabled++;
241 continue; 239 continue;
242 } 240 }
243
244 result = add_memory(node, info->start_addr, info->length); 241 result = add_memory(node, info->start_addr, info->length);
245 if (result) 242 if (result)
246 continue; 243 continue;
@@ -487,10 +484,8 @@ acpi_memory_register_notify_handler(acpi_handle handle,
487 484
488 485
489 status = is_memory_device(handle); 486 status = is_memory_device(handle);
490 if (ACPI_FAILURE(status)){ 487 if (ACPI_FAILURE(status))
491 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
492 return AE_OK; /* continue */ 488 return AE_OK; /* continue */
493 }
494 489
495 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 490 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
496 acpi_memory_device_notify, NULL); 491 acpi_memory_device_notify, NULL);
@@ -506,10 +501,8 @@ acpi_memory_deregister_notify_handler(acpi_handle handle,
506 501
507 502
508 status = is_memory_device(handle); 503 status = is_memory_device(handle);
509 if (ACPI_FAILURE(status)){ 504 if (ACPI_FAILURE(status))
510 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
511 return AE_OK; /* continue */ 505 return AE_OK; /* continue */
512 }
513 506
514 status = acpi_remove_notify_handler(handle, 507 status = acpi_remove_notify_handler(handle,
515 ACPI_SYSTEM_NOTIFY, 508 ACPI_SYSTEM_NOTIFY,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 24bf4dca88cc..9810e2a55d0a 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -557,7 +557,7 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
557 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data); 557 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
558} 558}
559 559
560static struct file_operations acpi_battery_info_ops = { 560static const struct file_operations acpi_battery_info_ops = {
561 .open = acpi_battery_info_open_fs, 561 .open = acpi_battery_info_open_fs,
562 .read = seq_read, 562 .read = seq_read,
563 .llseek = seq_lseek, 563 .llseek = seq_lseek,
@@ -565,7 +565,7 @@ static struct file_operations acpi_battery_info_ops = {
565 .owner = THIS_MODULE, 565 .owner = THIS_MODULE,
566}; 566};
567 567
568static struct file_operations acpi_battery_state_ops = { 568static const struct file_operations acpi_battery_state_ops = {
569 .open = acpi_battery_state_open_fs, 569 .open = acpi_battery_state_open_fs,
570 .read = seq_read, 570 .read = seq_read,
571 .llseek = seq_lseek, 571 .llseek = seq_lseek,
@@ -573,7 +573,7 @@ static struct file_operations acpi_battery_state_ops = {
573 .owner = THIS_MODULE, 573 .owner = THIS_MODULE,
574}; 574};
575 575
576static struct file_operations acpi_battery_alarm_ops = { 576static const struct file_operations acpi_battery_alarm_ops = {
577 .open = acpi_battery_alarm_open_fs, 577 .open = acpi_battery_alarm_open_fs,
578 .read = seq_read, 578 .read = seq_read,
579 .write = acpi_battery_write_alarm, 579 .write = acpi_battery_write_alarm,
@@ -757,6 +757,9 @@ static int __init acpi_battery_init(void)
757{ 757{
758 int result; 758 int result;
759 759
760 if (acpi_disabled)
761 return -ENODEV;
762
760 acpi_battery_dir = acpi_lock_battery_dir(); 763 acpi_battery_dir = acpi_lock_battery_dir();
761 if (!acpi_battery_dir) 764 if (!acpi_battery_dir)
762 return -ENODEV; 765 return -ENODEV;
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index ea5a0496a4fd..279c4bac92e5 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -25,6 +25,7 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/kernel.h>
28#include <linux/list.h> 29#include <linux/list.h>
29#include <linux/sched.h> 30#include <linux/sched.h>
30#include <linux/pm.h> 31#include <linux/pm.h>
@@ -68,7 +69,8 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
68 69
69 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); 70 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
70 if (ACPI_FAILURE(status) || !*device) { 71 if (ACPI_FAILURE(status) || !*device) {
71 ACPI_EXCEPTION((AE_INFO, status, "No context for object [%p]", handle)); 72 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
73 handle));
72 return -ENODEV; 74 return -ENODEV;
73 } 75 }
74 76
@@ -192,8 +194,8 @@ int acpi_bus_set_power(acpi_handle handle, int state)
192 /* Make sure this is a valid target state */ 194 /* Make sure this is a valid target state */
193 195
194 if (!device->flags.power_manageable) { 196 if (!device->flags.power_manageable) {
195 printk(KERN_DEBUG "Device `[%s]' is not power manageable", 197 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable\n",
196 device->kobj.name); 198 device->kobj.name));
197 return -ENODEV; 199 return -ENODEV;
198 } 200 }
199 /* 201 /*
@@ -738,7 +740,10 @@ static int __init acpi_init(void)
738 return -ENODEV; 740 return -ENODEV;
739 } 741 }
740 742
741 firmware_register(&acpi_subsys); 743 result = firmware_register(&acpi_subsys);
744 if (result < 0)
745 printk(KERN_WARNING "%s: firmware_register error: %d\n",
746 __FUNCTION__, result);
742 747
743 result = acpi_bus_init(); 748 result = acpi_bus_init();
744 749
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index fd1ba05eab68..5ef885e82c78 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -87,14 +87,14 @@ struct acpi_button {
87 unsigned long pushed; 87 unsigned long pushed;
88}; 88};
89 89
90static struct file_operations acpi_button_info_fops = { 90static const struct file_operations acpi_button_info_fops = {
91 .open = acpi_button_info_open_fs, 91 .open = acpi_button_info_open_fs,
92 .read = seq_read, 92 .read = seq_read,
93 .llseek = seq_lseek, 93 .llseek = seq_lseek,
94 .release = single_release, 94 .release = single_release,
95}; 95};
96 96
97static struct file_operations acpi_button_state_fops = { 97static const struct file_operations acpi_button_state_fops = {
98 .open = acpi_button_state_open_fs, 98 .open = acpi_button_state_open_fs,
99 .read = seq_read, 99 .read = seq_read,
100 .llseek = seq_lseek, 100 .llseek = seq_lseek,
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
index 574a75a166c5..a01ce6700bfe 100644
--- a/drivers/acpi/cm_sbs.c
+++ b/drivers/acpi/cm_sbs.c
@@ -39,50 +39,43 @@ ACPI_MODULE_NAME("cm_sbs")
39static struct proc_dir_entry *acpi_ac_dir; 39static struct proc_dir_entry *acpi_ac_dir;
40static struct proc_dir_entry *acpi_battery_dir; 40static struct proc_dir_entry *acpi_battery_dir;
41 41
42static struct semaphore cm_sbs_sem; 42static DEFINE_MUTEX(cm_sbs_mutex);
43 43
44static int lock_ac_dir_cnt = 0; 44static int lock_ac_dir_cnt;
45static int lock_battery_dir_cnt = 0; 45static int lock_battery_dir_cnt;
46 46
47struct proc_dir_entry *acpi_lock_ac_dir(void) 47struct proc_dir_entry *acpi_lock_ac_dir(void)
48{ 48{
49 49 mutex_lock(&cm_sbs_mutex);
50 down(&cm_sbs_sem); 50 if (!acpi_ac_dir)
51 if (!acpi_ac_dir) {
52 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); 51 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
53 }
54 if (acpi_ac_dir) { 52 if (acpi_ac_dir) {
55 lock_ac_dir_cnt++; 53 lock_ac_dir_cnt++;
56 } else { 54 } else {
57 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 55 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
58 "Cannot create %s\n", ACPI_AC_CLASS)); 56 "Cannot create %s\n", ACPI_AC_CLASS));
59 } 57 }
60 up(&cm_sbs_sem); 58 mutex_unlock(&cm_sbs_mutex);
61 return acpi_ac_dir; 59 return acpi_ac_dir;
62} 60}
63
64EXPORT_SYMBOL(acpi_lock_ac_dir); 61EXPORT_SYMBOL(acpi_lock_ac_dir);
65 62
66void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param) 63void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param)
67{ 64{
68 65 mutex_lock(&cm_sbs_mutex);
69 down(&cm_sbs_sem); 66 if (acpi_ac_dir_param)
70 if (acpi_ac_dir_param) {
71 lock_ac_dir_cnt--; 67 lock_ac_dir_cnt--;
72 }
73 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) { 68 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) {
74 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 69 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
75 acpi_ac_dir = 0; 70 acpi_ac_dir = 0;
76 } 71 }
77 up(&cm_sbs_sem); 72 mutex_unlock(&cm_sbs_mutex);
78} 73}
79
80EXPORT_SYMBOL(acpi_unlock_ac_dir); 74EXPORT_SYMBOL(acpi_unlock_ac_dir);
81 75
82struct proc_dir_entry *acpi_lock_battery_dir(void) 76struct proc_dir_entry *acpi_lock_battery_dir(void)
83{ 77{
84 78 mutex_lock(&cm_sbs_mutex);
85 down(&cm_sbs_sem);
86 if (!acpi_battery_dir) { 79 if (!acpi_battery_dir) {
87 acpi_battery_dir = 80 acpi_battery_dir =
88 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); 81 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
@@ -93,39 +86,28 @@ struct proc_dir_entry *acpi_lock_battery_dir(void)
93 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 86 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
94 "Cannot create %s\n", ACPI_BATTERY_CLASS)); 87 "Cannot create %s\n", ACPI_BATTERY_CLASS));
95 } 88 }
96 up(&cm_sbs_sem); 89 mutex_unlock(&cm_sbs_mutex);
97 return acpi_battery_dir; 90 return acpi_battery_dir;
98} 91}
99
100EXPORT_SYMBOL(acpi_lock_battery_dir); 92EXPORT_SYMBOL(acpi_lock_battery_dir);
101 93
102void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param) 94void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
103{ 95{
104 96 mutex_lock(&cm_sbs_mutex);
105 down(&cm_sbs_sem); 97 if (acpi_battery_dir_param)
106 if (acpi_battery_dir_param) {
107 lock_battery_dir_cnt--; 98 lock_battery_dir_cnt--;
108 }
109 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param 99 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param
110 && acpi_battery_dir) { 100 && acpi_battery_dir) {
111 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 101 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
112 acpi_battery_dir = 0; 102 acpi_battery_dir = 0;
113 } 103 }
114 up(&cm_sbs_sem); 104 mutex_unlock(&cm_sbs_mutex);
115 return; 105 return;
116} 106}
117
118EXPORT_SYMBOL(acpi_unlock_battery_dir); 107EXPORT_SYMBOL(acpi_unlock_battery_dir);
119 108
120static int __init acpi_cm_sbs_init(void) 109static int __init acpi_cm_sbs_init(void)
121{ 110{
122
123 if (acpi_disabled)
124 return 0;
125
126 init_MUTEX(&cm_sbs_sem);
127
128 return 0; 111 return 0;
129} 112}
130
131subsys_initcall(acpi_cm_sbs_init); 113subsys_initcall(acpi_cm_sbs_init);
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index daf51b5b5875..1888c055d10f 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -116,16 +116,6 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
116 116
117 case ACPI_TYPE_METHOD: 117 case ACPI_TYPE_METHOD:
118 118
119 /*
120 * Set the execution data width (32 or 64) based upon the
121 * revision number of the parent ACPI table.
122 * TBD: This is really for possible future support of integer width
123 * on a per-table basis. Currently, we just use a global for the width.
124 */
125 if (info->table_desc->pointer->revision == 1) {
126 node->flags |= ANOBJ_DATA_WIDTH_32;
127 }
128
129 info->method_count++; 119 info->method_count++;
130 break; 120 break;
131 121
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index a39a33f4847a..cf888add3191 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -134,7 +134,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
134 union acpi_operand_object *mutex_desc; 134 union acpi_operand_object *mutex_desc;
135 acpi_status status; 135 acpi_status status;
136 136
137 ACPI_FUNCTION_NAME(ds_create_method_mutex); 137 ACPI_FUNCTION_TRACE(ds_create_method_mutex);
138 138
139 /* Create the new mutex object */ 139 /* Create the new mutex object */
140 140
@@ -493,7 +493,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
493 493
494 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 494 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
495 "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", 495 "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
496 (char *)&walk_state->method_node->name, 496 acpi_ut_get_node_name(walk_state->method_node),
497 walk_state->method_call_op, return_desc)); 497 walk_state->method_call_op, return_desc));
498 498
499 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 499 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
@@ -610,6 +610,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
610 610
611 acpi_os_release_mutex(method_desc->method.mutex->mutex. 611 acpi_os_release_mutex(method_desc->method.mutex->mutex.
612 os_mutex); 612 os_mutex);
613 method_desc->method.mutex->mutex.owner_thread = NULL;
613 } 614 }
614 } 615 }
615 616
@@ -620,27 +621,11 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
620 */ 621 */
621 method_node = walk_state->method_node; 622 method_node = walk_state->method_node;
622 623
623 /* Lock namespace for possible update */
624
625 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
626 if (ACPI_FAILURE(status)) {
627 return_VOID;
628 }
629
630 /*
631 * Delete any namespace entries created immediately underneath
632 * the method
633 */
634 if (method_node && method_node->child) {
635 acpi_ns_delete_namespace_subtree(method_node);
636 }
637
638 /* 624 /*
639 * Delete any namespace entries created anywhere else within 625 * Delete any namespace objects created anywhere within
640 * the namespace by the execution of this method 626 * the namespace by the execution of this method
641 */ 627 */
642 acpi_ns_delete_namespace_by_owner(method_desc->method.owner_id); 628 acpi_ns_delete_namespace_by_owner(method_desc->method.owner_id);
643 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
644 } 629 }
645 630
646 /* Decrement the thread count on the method */ 631 /* Decrement the thread count on the method */
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index b1ded62d0df1..d7a616c3104e 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -313,10 +313,10 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
313 case AML_CLASS_EXECUTE: 313 case AML_CLASS_EXECUTE:
314 case AML_CLASS_CREATE: 314 case AML_CLASS_CREATE:
315 /* 315 /*
316 * Most operators with arguments. 316 * Most operators with arguments (except create_xxx_field operators)
317 * Start a new result/operand state 317 * Start a new result/operand state
318 */ 318 */
319 if (walk_state->opcode != AML_CREATE_FIELD_OP) { 319 if (walk_state->op_info->object_type != ACPI_TYPE_BUFFER_FIELD) {
320 status = acpi_ds_result_stack_push(walk_state); 320 status = acpi_ds_result_stack_push(walk_state);
321 } 321 }
322 break; 322 break;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 510a94524298..578b99b71d9c 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -58,8 +58,8 @@ struct dock_dependent_device {
58}; 58};
59 59
60#define DOCK_DOCKING 0x00000001 60#define DOCK_DOCKING 0x00000001
61#define DOCK_EVENT KOBJ_DOCK 61#define DOCK_EVENT 3
62#define UNDOCK_EVENT KOBJ_UNDOCK 62#define UNDOCK_EVENT 2
63 63
64static struct dock_station *dock_station; 64static struct dock_station *dock_station;
65 65
@@ -322,11 +322,10 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
322 322
323static void dock_event(struct dock_station *ds, u32 event, int num) 323static void dock_event(struct dock_station *ds, u32 event, int num)
324{ 324{
325 struct acpi_device *device; 325 /*
326 326 * we don't do events until someone tells me that
327 device = dock_create_acpi_device(ds->handle); 327 * they would like to have them.
328 if (device) 328 */
329 kobject_uevent(&device->kobj, num);
330} 329}
331 330
332/** 331/**
@@ -627,6 +626,7 @@ static int dock_add(acpi_handle handle)
627 INIT_LIST_HEAD(&dock_station->hotplug_devices); 626 INIT_LIST_HEAD(&dock_station->hotplug_devices);
628 spin_lock_init(&dock_station->dd_lock); 627 spin_lock_init(&dock_station->dd_lock);
629 spin_lock_init(&dock_station->hp_lock); 628 spin_lock_init(&dock_station->hp_lock);
629 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
630 630
631 /* Find dependent devices */ 631 /* Find dependent devices */
632 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 632 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 8c5d7df7d343..e5d796362854 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -929,7 +929,7 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
929 return single_open(file, acpi_ec_read_info, PDE(inode)->data); 929 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
930} 930}
931 931
932static struct file_operations acpi_ec_info_ops = { 932static const struct file_operations acpi_ec_info_ops = {
933 .open = acpi_ec_info_open_fs, 933 .open = acpi_ec_info_open_fs,
934 .read = seq_read, 934 .read = seq_read,
935 .llseek = seq_lseek, 935 .llseek = seq_lseek,
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index a901b23e95e7..959a893c8d1f 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -99,7 +99,7 @@ static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait)
99 return 0; 99 return 0;
100} 100}
101 101
102static struct file_operations acpi_system_event_ops = { 102static const struct file_operations acpi_system_event_ops = {
103 .open = acpi_system_open_event, 103 .open = acpi_system_open_event,
104 .read = acpi_system_read_event, 104 .read = acpi_system_read_event,
105 .release = acpi_system_close_event, 105 .release = acpi_system_close_event,
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index 094a17e4c86d..21caae04fe85 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -528,34 +528,40 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
528 } 528 }
529 } 529 }
530 530
531 /* Call the setup handler with the deactivate notification */ 531 /*
532 * If the region has been activated, call the setup handler
533 * with the deactivate notification
534 */
535 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
536 region_setup = handler_obj->address_space.setup;
537 status =
538 region_setup(region_obj,
539 ACPI_REGION_DEACTIVATE,
540 handler_obj->address_space.
541 context, region_context);
532 542
533 region_setup = handler_obj->address_space.setup; 543 /* Init routine may fail, Just ignore errors */
534 status =
535 region_setup(region_obj, ACPI_REGION_DEACTIVATE,
536 handler_obj->address_space.context,
537 region_context);
538 544
539 /* Init routine may fail, Just ignore errors */ 545 if (ACPI_FAILURE(status)) {
546 ACPI_EXCEPTION((AE_INFO, status,
547 "from region handler - deactivate, [%s]",
548 acpi_ut_get_region_name
549 (region_obj->region.
550 space_id)));
551 }
540 552
541 if (ACPI_FAILURE(status)) { 553 region_obj->region.flags &=
542 ACPI_EXCEPTION((AE_INFO, status, 554 ~(AOPOBJ_SETUP_COMPLETE);
543 "from region init, [%s]",
544 acpi_ut_get_region_name
545 (region_obj->region.space_id)));
546 } 555 }
547 556
548 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
549
550 /* 557 /*
551 * Remove handler reference in the region 558 * Remove handler reference in the region
552 * 559 *
553 * NOTE: this doesn't mean that the region goes away 560 * NOTE: this doesn't mean that the region goes away, the region
554 * The region is just inaccessible as indicated to 561 * is just inaccessible as indicated to the _REG method
555 * the _REG method
556 * 562 *
557 * If the region is on the handler's list 563 * If the region is on the handler's list, this must be the
558 * this better be the region's handler 564 * region's handler
559 */ 565 */
560 region_obj->region.handler = NULL; 566 region_obj->region.handler = NULL;
561 acpi_ut_remove_reference(handler_obj); 567 acpi_ut_remove_reference(handler_obj);
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 4f948df17ab9..923fd2b46955 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -428,7 +428,7 @@ acpi_remove_notify_handler(acpi_handle device,
428 node = acpi_ns_map_handle_to_node(device); 428 node = acpi_ns_map_handle_to_node(device);
429 if (!node) { 429 if (!node) {
430 status = AE_BAD_PARAMETER; 430 status = AE_BAD_PARAMETER;
431 goto unlock; 431 goto unlock_and_exit;
432 } 432 }
433 433
434 /* Root Object */ 434 /* Root Object */
@@ -442,7 +442,7 @@ acpi_remove_notify_handler(acpi_handle device,
442 ((handler_type & ACPI_DEVICE_NOTIFY) && 442 ((handler_type & ACPI_DEVICE_NOTIFY) &&
443 !acpi_gbl_device_notify.handler)) { 443 !acpi_gbl_device_notify.handler)) {
444 status = AE_NOT_EXIST; 444 status = AE_NOT_EXIST;
445 goto unlock; 445 goto unlock_and_exit;
446 } 446 }
447 447
448 /* Make sure all deferred tasks are completed */ 448 /* Make sure all deferred tasks are completed */
@@ -474,7 +474,7 @@ acpi_remove_notify_handler(acpi_handle device,
474 474
475 if (!acpi_ev_is_notify_object(node)) { 475 if (!acpi_ev_is_notify_object(node)) {
476 status = AE_TYPE; 476 status = AE_TYPE;
477 goto unlock; 477 goto unlock_and_exit;
478 } 478 }
479 479
480 /* Check for an existing internal object */ 480 /* Check for an existing internal object */
@@ -482,17 +482,21 @@ acpi_remove_notify_handler(acpi_handle device,
482 obj_desc = acpi_ns_get_attached_object(node); 482 obj_desc = acpi_ns_get_attached_object(node);
483 if (!obj_desc) { 483 if (!obj_desc) {
484 status = AE_NOT_EXIST; 484 status = AE_NOT_EXIST;
485 goto unlock; 485 goto unlock_and_exit;
486 } 486 }
487 487
488 /* Object exists - make sure there's an existing handler */ 488 /* Object exists - make sure there's an existing handler */
489 489
490 if (handler_type & ACPI_SYSTEM_NOTIFY) { 490 if (handler_type & ACPI_SYSTEM_NOTIFY) {
491 notify_obj = obj_desc->common_notify.system_notify; 491 notify_obj = obj_desc->common_notify.system_notify;
492 if ((!notify_obj) || 492 if (!notify_obj) {
493 (notify_obj->notify.handler != handler)) { 493 status = AE_NOT_EXIST;
494 goto unlock_and_exit;
495 }
496
497 if (notify_obj->notify.handler != handler) {
494 status = AE_BAD_PARAMETER; 498 status = AE_BAD_PARAMETER;
495 goto unlock; 499 goto unlock_and_exit;
496 } 500 }
497 /* Make sure all deferred tasks are completed */ 501 /* Make sure all deferred tasks are completed */
498 502
@@ -510,10 +514,14 @@ acpi_remove_notify_handler(acpi_handle device,
510 514
511 if (handler_type & ACPI_DEVICE_NOTIFY) { 515 if (handler_type & ACPI_DEVICE_NOTIFY) {
512 notify_obj = obj_desc->common_notify.device_notify; 516 notify_obj = obj_desc->common_notify.device_notify;
513 if ((!notify_obj) || 517 if (!notify_obj) {
514 (notify_obj->notify.handler != handler)) { 518 status = AE_NOT_EXIST;
519 goto unlock_and_exit;
520 }
521
522 if (notify_obj->notify.handler != handler) {
515 status = AE_BAD_PARAMETER; 523 status = AE_BAD_PARAMETER;
516 goto unlock; 524 goto unlock_and_exit;
517 } 525 }
518 /* Make sure all deferred tasks are completed */ 526 /* Make sure all deferred tasks are completed */
519 527
@@ -530,9 +538,9 @@ acpi_remove_notify_handler(acpi_handle device,
530 } 538 }
531 } 539 }
532 540
533unlock: 541 unlock_and_exit:
534 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 542 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
535exit: 543 exit:
536 if (ACPI_FAILURE(status)) 544 if (ACPI_FAILURE(status))
537 ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler")); 545 ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler"));
538 return_ACPI_STATUS(status); 546 return_ACPI_STATUS(status);
@@ -586,7 +594,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
586 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 594 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
587 if (!gpe_event_info) { 595 if (!gpe_event_info) {
588 status = AE_BAD_PARAMETER; 596 status = AE_BAD_PARAMETER;
589 goto unlock; 597 goto unlock_and_exit;
590 } 598 }
591 599
592 /* Make sure that there isn't a handler there already */ 600 /* Make sure that there isn't a handler there already */
@@ -594,7 +602,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
594 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 602 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
595 ACPI_GPE_DISPATCH_HANDLER) { 603 ACPI_GPE_DISPATCH_HANDLER) {
596 status = AE_ALREADY_EXISTS; 604 status = AE_ALREADY_EXISTS;
597 goto unlock; 605 goto unlock_and_exit;
598 } 606 }
599 607
600 /* Allocate and init handler object */ 608 /* Allocate and init handler object */
@@ -602,7 +610,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
602 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); 610 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info));
603 if (!handler) { 611 if (!handler) {
604 status = AE_NO_MEMORY; 612 status = AE_NO_MEMORY;
605 goto unlock; 613 goto unlock_and_exit;
606 } 614 }
607 615
608 handler->address = address; 616 handler->address = address;
@@ -613,7 +621,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
613 621
614 status = acpi_ev_disable_gpe(gpe_event_info); 622 status = acpi_ev_disable_gpe(gpe_event_info);
615 if (ACPI_FAILURE(status)) { 623 if (ACPI_FAILURE(status)) {
616 goto unlock; 624 goto unlock_and_exit;
617 } 625 }
618 626
619 /* Install the handler */ 627 /* Install the handler */
@@ -628,9 +636,9 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
628 636
629 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 637 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
630 638
631unlock: 639 unlock_and_exit:
632 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 640 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
633exit: 641 exit:
634 if (ACPI_FAILURE(status)) 642 if (ACPI_FAILURE(status))
635 ACPI_EXCEPTION((AE_INFO, status, 643 ACPI_EXCEPTION((AE_INFO, status,
636 "Installing notify handler failed")); 644 "Installing notify handler failed"));
diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c
index e8b86a0baad0..83b12a9afa32 100644
--- a/drivers/acpi/events/evxfregn.c
+++ b/drivers/acpi/events/evxfregn.c
@@ -155,7 +155,11 @@ acpi_remove_address_space_handler(acpi_handle device,
155 /* Convert and validate the device handle */ 155 /* Convert and validate the device handle */
156 156
157 node = acpi_ns_map_handle_to_node(device); 157 node = acpi_ns_map_handle_to_node(device);
158 if (!node) { 158 if (!node ||
159 ((node->type != ACPI_TYPE_DEVICE) &&
160 (node->type != ACPI_TYPE_PROCESSOR) &&
161 (node->type != ACPI_TYPE_THERMAL) &&
162 (node != acpi_gbl_root_node))) {
159 status = AE_BAD_PARAMETER; 163 status = AE_BAD_PARAMETER;
160 goto unlock_and_exit; 164 goto unlock_and_exit;
161 } 165 }
@@ -178,6 +182,13 @@ acpi_remove_address_space_handler(acpi_handle device,
178 182
179 if (handler_obj->address_space.space_id == space_id) { 183 if (handler_obj->address_space.space_id == space_id) {
180 184
185 /* Handler must be the same as the installed handler */
186
187 if (handler_obj->address_space.handler != handler) {
188 status = AE_BAD_PARAMETER;
189 goto unlock_and_exit;
190 }
191
181 /* Matched space_id, first dereference this in the Regions */ 192 /* Matched space_id, first dereference this in the Regions */
182 193
183 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 194 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 83fed079a276..c8341fa5fe01 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -502,7 +502,6 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
502 * (Offset contains the table_id) 502 * (Offset contains the table_id)
503 */ 503 */
504 acpi_ns_delete_namespace_by_owner(table_info->owner_id); 504 acpi_ns_delete_namespace_by_owner(table_info->owner_id);
505 acpi_ut_release_owner_id(&table_info->owner_id);
506 505
507 /* Delete the table itself */ 506 /* Delete the table itself */
508 507
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index b732e399b1ef..544e81a6a438 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -170,6 +170,9 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
170 return_ACPI_STATUS(AE_NO_MEMORY); 170 return_ACPI_STATUS(AE_NO_MEMORY);
171 } 171 }
172 172
173 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
174 ACPI_FORMAT_UINT64(result)));
175
173 /* Save the Result */ 176 /* Save the Result */
174 177
175 return_desc->integer.value = result; 178 return_desc->integer.value = result;
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index d8ac2877cf05..3a39c2e8e104 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -267,9 +267,9 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
267 && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) { 267 && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) {
268 ACPI_ERROR((AE_INFO, 268 ACPI_ERROR((AE_INFO,
269 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", 269 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X",
270 walk_state->thread->thread_id, 270 (u32) walk_state->thread->thread_id,
271 acpi_ut_get_node_name(obj_desc->mutex.node), 271 acpi_ut_get_node_name(obj_desc->mutex.node),
272 obj_desc->mutex.owner_thread->thread_id)); 272 (u32) obj_desc->mutex.owner_thread->thread_id));
273 return_ACPI_STATUS(AE_AML_NOT_OWNER); 273 return_ACPI_STATUS(AE_AML_NOT_OWNER);
274 } 274 }
275 275
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index 6b5d1e6ce94b..28aef3e69ecc 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -60,7 +60,7 @@ ACPI_MODULE_NAME("exsystem")
60 * 60 *
61 * DESCRIPTION: Implements a semaphore wait with a check to see if the 61 * DESCRIPTION: Implements a semaphore wait with a check to see if the
62 * semaphore is available immediately. If it is not, the 62 * semaphore is available immediately. If it is not, the
63 * interpreter is released. 63 * interpreter is released before waiting.
64 * 64 *
65 ******************************************************************************/ 65 ******************************************************************************/
66acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) 66acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
@@ -110,9 +110,9 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
110 * 110 *
111 * RETURN: Status 111 * RETURN: Status
112 * 112 *
113 * DESCRIPTION: Implements a semaphore wait with a check to see if the 113 * DESCRIPTION: Implements a mutex wait with a check to see if the
114 * semaphore is available immediately. If it is not, the 114 * mutex is available immediately. If it is not, the
115 * interpreter is released. 115 * interpreter is released before waiting.
116 * 116 *
117 ******************************************************************************/ 117 ******************************************************************************/
118 118
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index daed2460924d..045c89477e59 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -120,7 +120,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
120 return count; 120 return count;
121} 121}
122 122
123static struct file_operations acpi_fan_state_ops = { 123static const struct file_operations acpi_fan_state_ops = {
124 .open = acpi_fan_state_open_fs, 124 .open = acpi_fan_state_open_fs,
125 .read = seq_read, 125 .read = seq_read,
126 .write = acpi_fan_write_state, 126 .write = acpi_fan_write_state,
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
index fd81a0f5222f..1ba2db671865 100644
--- a/drivers/acpi/hotkey.c
+++ b/drivers/acpi/hotkey.c
@@ -91,6 +91,14 @@ enum {
91 HK_EVENT_ENTERRING_S5, 91 HK_EVENT_ENTERRING_S5,
92}; 92};
93 93
94enum conf_entry_enum {
95 bus_handle = 0,
96 bus_method = 1,
97 action_handle = 2,
98 method = 3,
99 LAST_CONF_ENTRY
100};
101
94/* procdir we use */ 102/* procdir we use */
95static struct proc_dir_entry *hotkey_proc_dir; 103static struct proc_dir_entry *hotkey_proc_dir;
96static struct proc_dir_entry *hotkey_config; 104static struct proc_dir_entry *hotkey_config;
@@ -184,7 +192,7 @@ static union acpi_hotkey *get_hotkey_by_event(struct
184 *hotkey_list, int event); 192 *hotkey_list, int event);
185 193
186/* event based config */ 194/* event based config */
187static struct file_operations hotkey_config_fops = { 195static const struct file_operations hotkey_config_fops = {
188 .open = hotkey_open_config, 196 .open = hotkey_open_config,
189 .read = seq_read, 197 .read = seq_read,
190 .write = hotkey_write_config, 198 .write = hotkey_write_config,
@@ -193,7 +201,7 @@ static struct file_operations hotkey_config_fops = {
193}; 201};
194 202
195/* polling based config */ 203/* polling based config */
196static struct file_operations hotkey_poll_config_fops = { 204static const struct file_operations hotkey_poll_config_fops = {
197 .open = hotkey_poll_open_config, 205 .open = hotkey_poll_open_config,
198 .read = seq_read, 206 .read = seq_read,
199 .write = hotkey_write_config, 207 .write = hotkey_write_config,
@@ -202,7 +210,7 @@ static struct file_operations hotkey_poll_config_fops = {
202}; 210};
203 211
204/* hotkey driver info */ 212/* hotkey driver info */
205static struct file_operations hotkey_info_fops = { 213static const struct file_operations hotkey_info_fops = {
206 .open = hotkey_info_open_fs, 214 .open = hotkey_info_open_fs,
207 .read = seq_read, 215 .read = seq_read,
208 .llseek = seq_lseek, 216 .llseek = seq_lseek,
@@ -210,7 +218,7 @@ static struct file_operations hotkey_info_fops = {
210}; 218};
211 219
212/* action */ 220/* action */
213static struct file_operations hotkey_action_fops = { 221static const struct file_operations hotkey_action_fops = {
214 .open = hotkey_action_open_fs, 222 .open = hotkey_action_open_fs,
215 .read = seq_read, 223 .read = seq_read,
216 .write = hotkey_execute_aml_method, 224 .write = hotkey_execute_aml_method,
@@ -219,7 +227,7 @@ static struct file_operations hotkey_action_fops = {
219}; 227};
220 228
221/* polling results */ 229/* polling results */
222static struct file_operations hotkey_polling_fops = { 230static const struct file_operations hotkey_polling_fops = {
223 .open = hotkey_polling_open_fs, 231 .open = hotkey_polling_open_fs,
224 .read = seq_read, 232 .read = seq_read,
225 .llseek = seq_lseek, 233 .llseek = seq_lseek,
@@ -244,19 +252,15 @@ static int hotkey_info_open_fs(struct inode *inode, struct file *file)
244 252
245static char *format_result(union acpi_object *object) 253static char *format_result(union acpi_object *object)
246{ 254{
247 char *buf = NULL; 255 char *buf;
248
249 buf = (char *)kmalloc(RESULT_STR_LEN, GFP_KERNEL);
250 if (buf)
251 memset(buf, 0, RESULT_STR_LEN);
252 else
253 goto do_fail;
254 256
257 buf = kzalloc(RESULT_STR_LEN, GFP_KERNEL);
258 if (!buf)
259 return NULL;
255 /* Now, just support integer type */ 260 /* Now, just support integer type */
256 if (object->type == ACPI_TYPE_INTEGER) 261 if (object->type == ACPI_TYPE_INTEGER)
257 sprintf(buf, "%d\n", (u32) object->integer.value); 262 sprintf(buf, "%d\n", (u32) object->integer.value);
258 do_fail: 263 return buf;
259 return (buf);
260} 264}
261 265
262static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) 266static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
@@ -486,98 +490,102 @@ static void free_hotkey_device(union acpi_hotkey *key)
486 490
487static void free_hotkey_buffer(union acpi_hotkey *key) 491static void free_hotkey_buffer(union acpi_hotkey *key)
488{ 492{
493 /* key would never be null, action method could be */
489 kfree(key->event_hotkey.action_method); 494 kfree(key->event_hotkey.action_method);
490} 495}
491 496
492static void free_poll_hotkey_buffer(union acpi_hotkey *key) 497static void free_poll_hotkey_buffer(union acpi_hotkey *key)
493{ 498{
499 /* key would never be null, others could be*/
494 kfree(key->poll_hotkey.action_method); 500 kfree(key->poll_hotkey.action_method);
495 kfree(key->poll_hotkey.poll_method); 501 kfree(key->poll_hotkey.poll_method);
496 kfree(key->poll_hotkey.poll_result); 502 kfree(key->poll_hotkey.poll_result);
497} 503}
498static int 504static int
499init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, 505init_hotkey_device(union acpi_hotkey *key, char **config_entry,
500 char *method, int std_num, int external_num) 506 int std_num, int external_num)
501{ 507{
502 acpi_handle tmp_handle; 508 acpi_handle tmp_handle;
503 acpi_status status = AE_OK; 509 acpi_status status = AE_OK;
504 510
505
506 if (std_num < 0 || IS_POLL(std_num) || !key) 511 if (std_num < 0 || IS_POLL(std_num) || !key)
507 goto do_fail; 512 goto do_fail;
508 513
509 if (!bus_str || !action_str || !method) 514 if (!config_entry[bus_handle] || !config_entry[action_handle]
515 || !config_entry[method])
510 goto do_fail; 516 goto do_fail;
511 517
512 key->link.hotkey_type = ACPI_HOTKEY_EVENT; 518 key->link.hotkey_type = ACPI_HOTKEY_EVENT;
513 key->link.hotkey_standard_num = std_num; 519 key->link.hotkey_standard_num = std_num;
514 key->event_hotkey.flag = 0; 520 key->event_hotkey.flag = 0;
515 key->event_hotkey.action_method = method; 521 key->event_hotkey.action_method = config_entry[method];
516 522
517 status = 523 status = acpi_get_handle(NULL, config_entry[bus_handle],
518 acpi_get_handle(NULL, bus_str, &(key->event_hotkey.bus_handle)); 524 &(key->event_hotkey.bus_handle));
519 if (ACPI_FAILURE(status)) 525 if (ACPI_FAILURE(status))
520 goto do_fail; 526 goto do_fail_zero;
521 key->event_hotkey.external_hotkey_num = external_num; 527 key->event_hotkey.external_hotkey_num = external_num;
522 status = 528 status = acpi_get_handle(NULL, config_entry[action_handle],
523 acpi_get_handle(NULL, action_str,
524 &(key->event_hotkey.action_handle)); 529 &(key->event_hotkey.action_handle));
525 if (ACPI_FAILURE(status)) 530 if (ACPI_FAILURE(status))
526 goto do_fail; 531 goto do_fail_zero;
527 status = acpi_get_handle(key->event_hotkey.action_handle, 532 status = acpi_get_handle(key->event_hotkey.action_handle,
528 method, &tmp_handle); 533 config_entry[method], &tmp_handle);
529 if (ACPI_FAILURE(status)) 534 if (ACPI_FAILURE(status))
530 goto do_fail; 535 goto do_fail_zero;
531 return AE_OK; 536 return AE_OK;
532 do_fail: 537do_fail_zero:
538 key->event_hotkey.action_method = NULL;
539do_fail:
533 return -ENODEV; 540 return -ENODEV;
534} 541}
535 542
536static int 543static int
537init_poll_hotkey_device(union acpi_hotkey *key, 544init_poll_hotkey_device(union acpi_hotkey *key, char **config_entry,
538 char *poll_str, 545 int std_num)
539 char *poll_method,
540 char *action_str, char *action_method, int std_num)
541{ 546{
542 acpi_status status = AE_OK; 547 acpi_status status = AE_OK;
543 acpi_handle tmp_handle; 548 acpi_handle tmp_handle;
544 549
545
546 if (std_num < 0 || IS_EVENT(std_num) || !key) 550 if (std_num < 0 || IS_EVENT(std_num) || !key)
547 goto do_fail; 551 goto do_fail;
548 552 if (!config_entry[bus_handle] ||!config_entry[bus_method] ||
549 if (!poll_str || !poll_method || !action_str || !action_method) 553 !config_entry[action_handle] || !config_entry[method])
550 goto do_fail; 554 goto do_fail;
551 555
552 key->link.hotkey_type = ACPI_HOTKEY_POLLING; 556 key->link.hotkey_type = ACPI_HOTKEY_POLLING;
553 key->link.hotkey_standard_num = std_num; 557 key->link.hotkey_standard_num = std_num;
554 key->poll_hotkey.flag = 0; 558 key->poll_hotkey.flag = 0;
555 key->poll_hotkey.poll_method = poll_method; 559 key->poll_hotkey.poll_method = config_entry[bus_method];
556 key->poll_hotkey.action_method = action_method; 560 key->poll_hotkey.action_method = config_entry[method];
557 561
558 status = 562 status = acpi_get_handle(NULL, config_entry[bus_handle],
559 acpi_get_handle(NULL, poll_str, &(key->poll_hotkey.poll_handle)); 563 &(key->poll_hotkey.poll_handle));
560 if (ACPI_FAILURE(status)) 564 if (ACPI_FAILURE(status))
561 goto do_fail; 565 goto do_fail_zero;
562 status = acpi_get_handle(key->poll_hotkey.poll_handle, 566 status = acpi_get_handle(key->poll_hotkey.poll_handle,
563 poll_method, &tmp_handle); 567 config_entry[bus_method], &tmp_handle);
564 if (ACPI_FAILURE(status)) 568 if (ACPI_FAILURE(status))
565 goto do_fail; 569 goto do_fail_zero;
566 status = 570 status =
567 acpi_get_handle(NULL, action_str, 571 acpi_get_handle(NULL, config_entry[action_handle],
568 &(key->poll_hotkey.action_handle)); 572 &(key->poll_hotkey.action_handle));
569 if (ACPI_FAILURE(status)) 573 if (ACPI_FAILURE(status))
570 goto do_fail; 574 goto do_fail_zero;
571 status = acpi_get_handle(key->poll_hotkey.action_handle, 575 status = acpi_get_handle(key->poll_hotkey.action_handle,
572 action_method, &tmp_handle); 576 config_entry[method], &tmp_handle);
573 if (ACPI_FAILURE(status)) 577 if (ACPI_FAILURE(status))
574 goto do_fail; 578 goto do_fail_zero;
575 key->poll_hotkey.poll_result = 579 key->poll_hotkey.poll_result =
576 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 580 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
577 if (!key->poll_hotkey.poll_result) 581 if (!key->poll_hotkey.poll_result)
578 goto do_fail; 582 goto do_fail_zero;
579 return AE_OK; 583 return AE_OK;
580 do_fail: 584
585do_fail_zero:
586 key->poll_hotkey.poll_method = NULL;
587 key->poll_hotkey.action_method = NULL;
588do_fail:
581 return -ENODEV; 589 return -ENODEV;
582} 590}
583 591
@@ -652,17 +660,18 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
652} 660}
653 661
654static int 662static int
655get_parms(char *config_record, 663get_parms(char *config_record, int *cmd, char **config_entry,
656 int *cmd, 664 int *internal_event_num, int *external_event_num)
657 char **bus_handle,
658 char **bus_method,
659 char **action_handle,
660 char **method, int *internal_event_num, int *external_event_num)
661{ 665{
666/* the format of *config_record =
667 * "1:\d+:*" : "cmd:internal_event_num"
668 * "\d+:\w+:\w+:\w+:\w+:\d+:\d+" :
669 * "cmd:bus_handle:bus_method:action_handle:method:internal_event_num:external_event_num"
670 */
662 char *tmp, *tmp1, count; 671 char *tmp, *tmp1, count;
672 int i;
663 673
664 sscanf(config_record, "%d", cmd); 674 sscanf(config_record, "%d", cmd);
665
666 if (*cmd == 1) { 675 if (*cmd == 1) {
667 if (sscanf(config_record, "%d:%d", cmd, internal_event_num) != 676 if (sscanf(config_record, "%d:%d", cmd, internal_event_num) !=
668 2) 677 2)
@@ -674,59 +683,27 @@ get_parms(char *config_record,
674 if (!tmp) 683 if (!tmp)
675 goto do_fail; 684 goto do_fail;
676 tmp++; 685 tmp++;
677 tmp1 = strchr(tmp, ':'); 686 for (i = 0; i < LAST_CONF_ENTRY; i++) {
678 if (!tmp1) 687 tmp1 = strchr(tmp, ':');
679 goto do_fail; 688 if (!tmp1) {
680 689 goto do_fail;
681 count = tmp1 - tmp; 690 }
682 *bus_handle = (char *)kmalloc(count + 1, GFP_KERNEL); 691 count = tmp1 - tmp;
683 if (!*bus_handle) 692 config_entry[i] = kzalloc(count + 1, GFP_KERNEL);
684 goto do_fail; 693 if (!config_entry[i])
685 strncpy(*bus_handle, tmp, count); 694 goto handle_failure;
686 *(*bus_handle + count) = 0; 695 strncpy(config_entry[i], tmp, count);
687 696 tmp = tmp1 + 1;
688 tmp = tmp1; 697 }
689 tmp++; 698 if (sscanf(tmp, "%d:%d", internal_event_num, external_event_num) <= 0)
690 tmp1 = strchr(tmp, ':'); 699 goto handle_failure;
691 if (!tmp1) 700 if (!IS_OTHERS(*internal_event_num)) {
692 goto do_fail; 701 return 6;
693 count = tmp1 - tmp; 702 }
694 *bus_method = (char *)kmalloc(count + 1, GFP_KERNEL); 703handle_failure:
695 if (!*bus_method) 704 while (i-- > 0)
696 goto do_fail; 705 kfree(config_entry[i]);
697 strncpy(*bus_method, tmp, count); 706do_fail:
698 *(*bus_method + count) = 0;
699
700 tmp = tmp1;
701 tmp++;
702 tmp1 = strchr(tmp, ':');
703 if (!tmp1)
704 goto do_fail;
705 count = tmp1 - tmp;
706 *action_handle = (char *)kmalloc(count + 1, GFP_KERNEL);
707 if (!*action_handle)
708 goto do_fail;
709 strncpy(*action_handle, tmp, count);
710 *(*action_handle + count) = 0;
711
712 tmp = tmp1;
713 tmp++;
714 tmp1 = strchr(tmp, ':');
715 if (!tmp1)
716 goto do_fail;
717 count = tmp1 - tmp;
718 *method = (char *)kmalloc(count + 1, GFP_KERNEL);
719 if (!*method)
720 goto do_fail;
721 strncpy(*method, tmp, count);
722 *(*method + count) = 0;
723
724 if (sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num) <=
725 0)
726 goto do_fail;
727
728 return 6;
729 do_fail:
730 return -1; 707 return -1;
731} 708}
732 709
@@ -736,50 +713,34 @@ static ssize_t hotkey_write_config(struct file *file,
736 size_t count, loff_t * data) 713 size_t count, loff_t * data)
737{ 714{
738 char *config_record = NULL; 715 char *config_record = NULL;
739 char *bus_handle = NULL; 716 char *config_entry[LAST_CONF_ENTRY];
740 char *bus_method = NULL;
741 char *action_handle = NULL;
742 char *method = NULL;
743 int cmd, internal_event_num, external_event_num; 717 int cmd, internal_event_num, external_event_num;
744 int ret = 0; 718 int ret = 0;
745 union acpi_hotkey *key = NULL; 719 union acpi_hotkey *key = kzalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
746 720
721 if (!key)
722 return -ENOMEM;
747 723
748 config_record = (char *)kmalloc(count + 1, GFP_KERNEL); 724 config_record = kzalloc(count + 1, GFP_KERNEL);
749 if (!config_record) 725 if (!config_record) {
726 kfree(key);
750 return -ENOMEM; 727 return -ENOMEM;
728 }
751 729
752 if (copy_from_user(config_record, buffer, count)) { 730 if (copy_from_user(config_record, buffer, count)) {
753 kfree(config_record); 731 kfree(config_record);
732 kfree(key);
754 printk(KERN_ERR PREFIX "Invalid data\n"); 733 printk(KERN_ERR PREFIX "Invalid data\n");
755 return -EINVAL; 734 return -EINVAL;
756 } 735 }
757 config_record[count] = 0; 736 ret = get_parms(config_record, &cmd, config_entry,
758 737 &internal_event_num, &external_event_num);
759 ret = get_parms(config_record,
760 &cmd,
761 &bus_handle,
762 &bus_method,
763 &action_handle,
764 &method, &internal_event_num, &external_event_num);
765
766 kfree(config_record); 738 kfree(config_record);
767 if (IS_OTHERS(internal_event_num))
768 goto do_fail;
769 if (ret != 6) { 739 if (ret != 6) {
770 do_fail:
771 kfree(bus_handle);
772 kfree(bus_method);
773 kfree(action_handle);
774 kfree(method);
775 printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret); 740 printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret);
776 return -EINVAL; 741 return -EINVAL;
777 } 742 }
778 743
779 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
780 if (!key)
781 goto do_fail;
782 memset(key, 0, sizeof(union acpi_hotkey));
783 if (cmd == 1) { 744 if (cmd == 1) {
784 union acpi_hotkey *tmp = NULL; 745 union acpi_hotkey *tmp = NULL;
785 tmp = get_hotkey_by_event(&global_hotkey_list, 746 tmp = get_hotkey_by_event(&global_hotkey_list,
@@ -791,34 +752,19 @@ static ssize_t hotkey_write_config(struct file *file,
791 goto cont_cmd; 752 goto cont_cmd;
792 } 753 }
793 if (IS_EVENT(internal_event_num)) { 754 if (IS_EVENT(internal_event_num)) {
794 kfree(bus_method); 755 if (init_hotkey_device(key, config_entry,
795 ret = init_hotkey_device(key, bus_handle, action_handle, method, 756 internal_event_num, external_event_num))
796 internal_event_num, 757 goto init_hotkey_fail;
797 external_event_num); 758 } else {
798 } else 759 if (init_poll_hotkey_device(key, config_entry,
799 ret = init_poll_hotkey_device(key, bus_handle, bus_method, 760 internal_event_num))
800 action_handle, method, 761 goto init_poll_hotkey_fail;
801 internal_event_num);
802 if (ret) {
803 kfree(bus_handle);
804 kfree(action_handle);
805 if (IS_EVENT(internal_event_num))
806 free_hotkey_buffer(key);
807 else
808 free_poll_hotkey_buffer(key);
809 kfree(key);
810 printk(KERN_ERR PREFIX "Invalid hotkey\n");
811 return -EINVAL;
812 } 762 }
813 763cont_cmd:
814 cont_cmd:
815 kfree(bus_handle);
816 kfree(action_handle);
817
818 switch (cmd) { 764 switch (cmd) {
819 case 0: 765 case 0:
820 if (get_hotkey_by_event 766 if (get_hotkey_by_event(&global_hotkey_list,
821 (&global_hotkey_list, key->link.hotkey_standard_num)) 767 key->link.hotkey_standard_num))
822 goto fail_out; 768 goto fail_out;
823 else 769 else
824 hotkey_add(key); 770 hotkey_add(key);
@@ -827,6 +773,7 @@ static ssize_t hotkey_write_config(struct file *file,
827 hotkey_remove(key); 773 hotkey_remove(key);
828 break; 774 break;
829 case 2: 775 case 2:
776 /* key is kfree()ed if matched*/
830 if (hotkey_update(key)) 777 if (hotkey_update(key))
831 goto fail_out; 778 goto fail_out;
832 break; 779 break;
@@ -835,11 +782,22 @@ static ssize_t hotkey_write_config(struct file *file,
835 break; 782 break;
836 } 783 }
837 return count; 784 return count;
838 fail_out: 785
839 if (IS_EVENT(internal_event_num)) 786init_poll_hotkey_fail: /* failed init_poll_hotkey_device */
840 free_hotkey_buffer(key); 787 kfree(config_entry[bus_method]);
841 else 788 config_entry[bus_method] = NULL;
842 free_poll_hotkey_buffer(key); 789init_hotkey_fail: /* failed init_hotkey_device */
790 kfree(config_entry[method]);
791fail_out:
792 kfree(config_entry[bus_handle]);
793 kfree(config_entry[action_handle]);
794 /* No double free since elements =NULL for error cases */
795 if (IS_EVENT(internal_event_num)) {
796 if (config_entry[bus_method])
797 kfree(config_entry[bus_method]);
798 free_hotkey_buffer(key); /* frees [method] */
799 } else
800 free_poll_hotkey_buffer(key); /* frees [bus_method]+[method] */
843 kfree(key); 801 kfree(key);
844 printk(KERN_ERR PREFIX "invalid key\n"); 802 printk(KERN_ERR PREFIX "invalid key\n");
845 return -EINVAL; 803 return -EINVAL;
@@ -923,10 +881,9 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
923 union acpi_hotkey *key; 881 union acpi_hotkey *key;
924 882
925 883
926 arg = (char *)kmalloc(count + 1, GFP_KERNEL); 884 arg = kzalloc(count + 1, GFP_KERNEL);
927 if (!arg) 885 if (!arg)
928 return -ENOMEM; 886 return -ENOMEM;
929 arg[count] = 0;
930 887
931 if (copy_from_user(arg, buffer, count)) { 888 if (copy_from_user(arg, buffer, count)) {
932 kfree(arg); 889 kfree(arg);
diff --git a/drivers/acpi/i2c_ec.c b/drivers/acpi/i2c_ec.c
index 84239d51dc0c..6809c283ec58 100644
--- a/drivers/acpi/i2c_ec.c
+++ b/drivers/acpi/i2c_ec.c
@@ -330,7 +330,7 @@ static int acpi_ec_hc_add(struct acpi_device *device)
330 status = acpi_evaluate_integer(ec_hc->handle, "_EC", NULL, &val); 330 status = acpi_evaluate_integer(ec_hc->handle, "_EC", NULL, &val);
331 if (ACPI_FAILURE(status)) { 331 if (ACPI_FAILURE(status)) {
332 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error obtaining _EC\n")); 332 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error obtaining _EC\n"));
333 kfree(ec_hc->smbus); 333 kfree(ec_hc);
334 kfree(smbus); 334 kfree(smbus);
335 return -EIO; 335 return -EIO;
336 } 336 }
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index dc3f0739a46b..55b407aae266 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -386,14 +386,17 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
386 * specific ID. Used to delete entire ACPI tables. All 386 * specific ID. Used to delete entire ACPI tables. All
387 * reference counts are updated. 387 * reference counts are updated.
388 * 388 *
389 * MUTEX: Locks namespace during deletion walk.
390 *
389 ******************************************************************************/ 391 ******************************************************************************/
390 392
391void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id) 393void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
392{ 394{
393 struct acpi_namespace_node *child_node; 395 struct acpi_namespace_node *child_node;
394 struct acpi_namespace_node *deletion_node; 396 struct acpi_namespace_node *deletion_node;
395 u32 level;
396 struct acpi_namespace_node *parent_node; 397 struct acpi_namespace_node *parent_node;
398 u32 level;
399 acpi_status status;
397 400
398 ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id); 401 ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id);
399 402
@@ -401,6 +404,13 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
401 return_VOID; 404 return_VOID;
402 } 405 }
403 406
407 /* Lock namespace for possible update */
408
409 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
410 if (ACPI_FAILURE(status)) {
411 return_VOID;
412 }
413
404 deletion_node = NULL; 414 deletion_node = NULL;
405 parent_node = acpi_gbl_root_node; 415 parent_node = acpi_gbl_root_node;
406 child_node = NULL; 416 child_node = NULL;
@@ -469,5 +479,6 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
469 } 479 }
470 } 480 }
471 481
482 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
472 return_VOID; 483 return_VOID;
473} 484}
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index eedb05c6dc7b..507f051d1cef 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -36,7 +36,6 @@
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/workqueue.h> 37#include <linux/workqueue.h>
38#include <linux/nmi.h> 38#include <linux/nmi.h>
39#include <linux/kthread.h>
40#include <acpi/acpi.h> 39#include <acpi/acpi.h>
41#include <asm/io.h> 40#include <asm/io.h>
42#include <acpi/acpi_bus.h> 41#include <acpi/acpi_bus.h>
@@ -136,16 +135,6 @@ void acpi_os_vprintf(const char *fmt, va_list args)
136#endif 135#endif
137} 136}
138 137
139
140extern int acpi_in_resume;
141void *acpi_os_allocate(acpi_size size)
142{
143 if (acpi_in_resume)
144 return kmalloc(size, GFP_ATOMIC);
145 else
146 return kmalloc(size, GFP_KERNEL);
147}
148
149acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) 138acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
150{ 139{
151 if (efi_enabled) { 140 if (efi_enabled) {
@@ -593,16 +582,6 @@ static void acpi_os_execute_deferred(void *context)
593 return; 582 return;
594} 583}
595 584
596static int acpi_os_execute_thread(void *context)
597{
598 struct acpi_os_dpc *dpc = (struct acpi_os_dpc *)context;
599 if (dpc) {
600 dpc->function(dpc->context);
601 kfree(dpc);
602 }
603 do_exit(0);
604}
605
606/******************************************************************************* 585/*******************************************************************************
607 * 586 *
608 * FUNCTION: acpi_os_execute 587 * FUNCTION: acpi_os_execute
@@ -624,10 +603,16 @@ acpi_status acpi_os_execute(acpi_execute_type type,
624 acpi_status status = AE_OK; 603 acpi_status status = AE_OK;
625 struct acpi_os_dpc *dpc; 604 struct acpi_os_dpc *dpc;
626 struct work_struct *task; 605 struct work_struct *task;
627 struct task_struct *p; 606
607 ACPI_FUNCTION_TRACE("os_queue_for_execution");
608
609 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
610 "Scheduling function [%p(%p)] for deferred execution.\n",
611 function, context));
628 612
629 if (!function) 613 if (!function)
630 return AE_BAD_PARAMETER; 614 return_ACPI_STATUS(AE_BAD_PARAMETER);
615
631 /* 616 /*
632 * Allocate/initialize DPC structure. Note that this memory will be 617 * Allocate/initialize DPC structure. Note that this memory will be
633 * freed by the callee. The kernel handles the tq_struct list in a 618 * freed by the callee. The kernel handles the tq_struct list in a
@@ -638,34 +623,27 @@ acpi_status acpi_os_execute(acpi_execute_type type,
638 * We can save time and code by allocating the DPC and tq_structs 623 * We can save time and code by allocating the DPC and tq_structs
639 * from the same memory. 624 * from the same memory.
640 */ 625 */
641 if (type == OSL_NOTIFY_HANDLER) { 626
642 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_KERNEL); 627 dpc =
643 } else { 628 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
644 dpc = kmalloc(sizeof(struct acpi_os_dpc) + 629 GFP_ATOMIC);
645 sizeof(struct work_struct), GFP_ATOMIC);
646 }
647 if (!dpc) 630 if (!dpc)
648 return AE_NO_MEMORY; 631 return_ACPI_STATUS(AE_NO_MEMORY);
632
649 dpc->function = function; 633 dpc->function = function;
650 dpc->context = context; 634 dpc->context = context;
651 635
652 if (type == OSL_NOTIFY_HANDLER) { 636 task = (void *)(dpc + 1);
653 p = kthread_create(acpi_os_execute_thread, dpc, "kacpid_notify"); 637 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
654 if (!IS_ERR(p)) { 638
655 wake_up_process(p); 639 if (!queue_work(kacpid_wq, task)) {
656 } else { 640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
657 status = AE_NO_MEMORY; 641 "Call to queue_work() failed.\n"));
658 kfree(dpc); 642 kfree(dpc);
659 } 643 status = AE_ERROR;
660 } else {
661 task = (void *)(dpc + 1);
662 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
663 if (!queue_work(kacpid_wq, task)) {
664 status = AE_ERROR;
665 kfree(dpc);
666 }
667 } 644 }
668 return status; 645
646 return_ACPI_STATUS(status);
669} 647}
670 648
671EXPORT_SYMBOL(acpi_os_execute); 649EXPORT_SYMBOL(acpi_os_execute);
@@ -768,6 +746,16 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
768 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", 746 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
769 handle, units, timeout)); 747 handle, units, timeout));
770 748
749 /*
750 * This can be called during resume with interrupts off.
751 * Like boot-time, we should be single threaded and will
752 * always get the lock if we try -- timeout or not.
753 * If this doesn't succeed, then we will oops courtesy of
754 * might_sleep() in down().
755 */
756 if (!down_trylock(sem))
757 return AE_OK;
758
771 switch (timeout) { 759 switch (timeout) {
772 /* 760 /*
773 * No Wait: 761 * No Wait:
@@ -1115,26 +1103,6 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1115 return (AE_OK); 1103 return (AE_OK);
1116} 1104}
1117 1105
1118/*******************************************************************************
1119 *
1120 * FUNCTION: acpi_os_acquire_object
1121 *
1122 * PARAMETERS: Cache - Handle to cache object
1123 * ReturnObject - Where the object is returned
1124 *
1125 * RETURN: Status
1126 *
1127 * DESCRIPTION: Return a zero-filled object.
1128 *
1129 ******************************************************************************/
1130
1131void *acpi_os_acquire_object(acpi_cache_t * cache)
1132{
1133 void *object = kmem_cache_zalloc(cache, GFP_KERNEL);
1134 WARN_ON(!object);
1135 return object;
1136}
1137
1138/****************************************************************************** 1106/******************************************************************************
1139 * 1107 *
1140 * FUNCTION: acpi_os_validate_interface 1108 * FUNCTION: acpi_os_validate_interface
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index 182474ae8ce9..d405387b7414 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -139,12 +139,10 @@ union acpi_parse_object *acpi_ps_alloc_op(u16 opcode)
139 /* The generic op (default) is by far the most common (16 to 1) */ 139 /* The generic op (default) is by far the most common (16 to 1) */
140 140
141 op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); 141 op = acpi_os_acquire_object(acpi_gbl_ps_node_cache);
142 memset(op, 0, sizeof(struct acpi_parse_obj_common));
143 } else { 142 } else {
144 /* Extended parseop */ 143 /* Extended parseop */
145 144
146 op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); 145 op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache);
147 memset(op, 0, sizeof(struct acpi_parse_obj_named));
148 } 146 }
149 147
150 /* Initialize the Op */ 148 /* Initialize the Op */
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 8197c0e40769..7f3e7e77e794 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -780,11 +780,6 @@ static int acpi_pci_link_resume(struct acpi_pci_link *link)
780 return 0; 780 return 0;
781} 781}
782 782
783/*
784 * FIXME: this is a workaround to avoid nasty warning. It will be removed
785 * after every device calls pci_disable_device in .resume.
786 */
787int acpi_in_resume;
788static int irqrouter_resume(struct sys_device *dev) 783static int irqrouter_resume(struct sys_device *dev)
789{ 784{
790 struct list_head *node = NULL; 785 struct list_head *node = NULL;
@@ -794,7 +789,6 @@ static int irqrouter_resume(struct sys_device *dev)
794 /* Make sure SCI is enabled again (Apple firmware bug?) */ 789 /* Make sure SCI is enabled again (Apple firmware bug?) */
795 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK); 790 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK);
796 791
797 acpi_in_resume = 1;
798 list_for_each(node, &acpi_link.entries) { 792 list_for_each(node, &acpi_link.entries) {
799 link = list_entry(node, struct acpi_pci_link, node); 793 link = list_entry(node, struct acpi_pci_link, node);
800 if (!link) { 794 if (!link) {
@@ -803,7 +797,6 @@ static int irqrouter_resume(struct sys_device *dev)
803 } 797 }
804 acpi_pci_link_resume(link); 798 acpi_pci_link_resume(link);
805 } 799 }
806 acpi_in_resume = 0;
807 return 0; 800 return 0;
808} 801}
809 802
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 5d3447f4582c..fec225d1b6b7 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -80,7 +80,7 @@ struct acpi_power_resource {
80 80
81static struct list_head acpi_power_resource_list; 81static struct list_head acpi_power_resource_list;
82 82
83static struct file_operations acpi_power_fops = { 83static const struct file_operations acpi_power_fops = {
84 .open = acpi_power_open_fs, 84 .open = acpi_power_open_fs,
85 .read = seq_read, 85 .read = seq_read,
86 .llseek = seq_lseek, 86 .llseek = seq_lseek,
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 52674323b14d..b13d64415b7a 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -102,7 +102,7 @@ static struct acpi_driver acpi_processor_driver = {
102#define INSTALL_NOTIFY_HANDLER 1 102#define INSTALL_NOTIFY_HANDLER 1
103#define UNINSTALL_NOTIFY_HANDLER 2 103#define UNINSTALL_NOTIFY_HANDLER 2
104 104
105static struct file_operations acpi_processor_info_fops = { 105static const struct file_operations acpi_processor_info_fops = {
106 .open = acpi_processor_info_open_fs, 106 .open = acpi_processor_info_open_fs,
107 .read = seq_read, 107 .read = seq_read,
108 .llseek = seq_lseek, 108 .llseek = seq_lseek,
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 8e9c26aae8fe..71066066d626 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -1070,7 +1070,7 @@ static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
1070 PDE(inode)->data); 1070 PDE(inode)->data);
1071} 1071}
1072 1072
1073static struct file_operations acpi_processor_power_fops = { 1073static const struct file_operations acpi_processor_power_fops = {
1074 .open = acpi_processor_power_open_fs, 1074 .open = acpi_processor_power_open_fs,
1075 .read = seq_read, 1075 .read = seq_read,
1076 .llseek = seq_lseek, 1076 .llseek = seq_lseek,
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index db7b350a5035..62bef0b3b614 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -1714,6 +1714,9 @@ static int __init acpi_sbs_init(void)
1714{ 1714{
1715 int result = 0; 1715 int result = 0;
1716 1716
1717 if (acpi_disabled)
1718 return -ENODEV;
1719
1717 init_MUTEX(&sbs_sem); 1720 init_MUTEX(&sbs_sem);
1718 1721
1719 if (capacity_mode != DEF_CAPACITY_UNIT 1722 if (capacity_mode != DEF_CAPACITY_UNIT
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 5fcb50c7b778..698a1540e303 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/kernel.h>
7#include <linux/acpi.h> 8#include <linux/acpi.h>
8 9
9#include <acpi/acpi_drivers.h> 10#include <acpi/acpi_drivers.h>
@@ -113,6 +114,8 @@ static struct kset acpi_namespace_kset = {
113static void acpi_device_register(struct acpi_device *device, 114static void acpi_device_register(struct acpi_device *device,
114 struct acpi_device *parent) 115 struct acpi_device *parent)
115{ 116{
117 int err;
118
116 /* 119 /*
117 * Linkage 120 * Linkage
118 * ------- 121 * -------
@@ -138,7 +141,10 @@ static void acpi_device_register(struct acpi_device *device,
138 device->kobj.parent = &parent->kobj; 141 device->kobj.parent = &parent->kobj;
139 device->kobj.ktype = &ktype_acpi_ns; 142 device->kobj.ktype = &ktype_acpi_ns;
140 device->kobj.kset = &acpi_namespace_kset; 143 device->kobj.kset = &acpi_namespace_kset;
141 kobject_register(&device->kobj); 144 err = kobject_register(&device->kobj);
145 if (err < 0)
146 printk(KERN_WARNING "%s: kobject_register error: %d\n",
147 __FUNCTION__, err);
142 create_sysfs_device_files(device); 148 create_sysfs_device_files(device);
143} 149}
144 150
@@ -1450,7 +1456,9 @@ static int __init acpi_scan_init(void)
1450 if (acpi_disabled) 1456 if (acpi_disabled)
1451 return 0; 1457 return 0;
1452 1458
1453 kset_register(&acpi_namespace_kset); 1459 result = kset_register(&acpi_namespace_kset);
1460 if (result < 0)
1461 printk(KERN_ERR PREFIX "kset_register error: %d\n", result);
1454 1462
1455 result = bus_register(&acpi_bus_type); 1463 result = bus_register(&acpi_bus_type);
1456 if (result) { 1464 if (result) {
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 4696a85a98b9..34962578039d 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -434,7 +434,7 @@ acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
434 PDE(inode)->data); 434 PDE(inode)->data);
435} 435}
436 436
437static struct file_operations acpi_system_wakeup_device_fops = { 437static const struct file_operations acpi_system_wakeup_device_fops = {
438 .open = acpi_system_wakeup_device_open_fs, 438 .open = acpi_system_wakeup_device_open_fs,
439 .read = seq_read, 439 .read = seq_read,
440 .write = acpi_system_write_wakeup_device, 440 .write = acpi_system_write_wakeup_device,
@@ -443,7 +443,7 @@ static struct file_operations acpi_system_wakeup_device_fops = {
443}; 443};
444 444
445#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 445#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
446static struct file_operations acpi_system_sleep_fops = { 446static const struct file_operations acpi_system_sleep_fops = {
447 .open = acpi_system_sleep_open_fs, 447 .open = acpi_system_sleep_open_fs,
448 .read = seq_read, 448 .read = seq_read,
449 .write = acpi_system_write_sleep, 449 .write = acpi_system_write_sleep,
@@ -452,7 +452,7 @@ static struct file_operations acpi_system_sleep_fops = {
452}; 452};
453#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 453#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
454 454
455static struct file_operations acpi_system_alarm_fops = { 455static const struct file_operations acpi_system_alarm_fops = {
456 .open = acpi_system_alarm_open_fs, 456 .open = acpi_system_alarm_open_fs,
457 .read = seq_read, 457 .read = seq_read,
458 .write = acpi_system_write_alarm, 458 .write = acpi_system_write_alarm,
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index c3bb7faad75e..d86dcb3c2366 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -57,7 +57,7 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
57 return single_open(file, acpi_system_read_info, PDE(inode)->data); 57 return single_open(file, acpi_system_read_info, PDE(inode)->data);
58} 58}
59 59
60static struct file_operations acpi_system_info_ops = { 60static const struct file_operations acpi_system_info_ops = {
61 .open = acpi_system_info_open_fs, 61 .open = acpi_system_info_open_fs,
62 .read = seq_read, 62 .read = seq_read,
63 .llseek = seq_lseek, 63 .llseek = seq_lseek,
@@ -67,7 +67,7 @@ static struct file_operations acpi_system_info_ops = {
67static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, 67static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
68 loff_t *); 68 loff_t *);
69 69
70static struct file_operations acpi_system_dsdt_ops = { 70static const struct file_operations acpi_system_dsdt_ops = {
71 .read = acpi_system_read_dsdt, 71 .read = acpi_system_read_dsdt,
72}; 72};
73 73
@@ -94,7 +94,7 @@ acpi_system_read_dsdt(struct file *file,
94static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, 94static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
95 loff_t *); 95 loff_t *);
96 96
97static struct file_operations acpi_system_fadt_ops = { 97static const struct file_operations acpi_system_fadt_ops = {
98 .read = acpi_system_read_fadt, 98 .read = acpi_system_read_fadt,
99}; 99};
100 100
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 99eacceff563..7856db759af0 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -320,6 +320,16 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
320 320
321 ACPI_FUNCTION_TRACE(tb_get_this_table); 321 ACPI_FUNCTION_TRACE(tb_get_this_table);
322 322
323 /* Validate minimum length */
324
325 if (header->length < sizeof(struct acpi_table_header)) {
326 ACPI_ERROR((AE_INFO,
327 "Table length (%X) is smaller than minimum (%X)",
328 header->length, sizeof(struct acpi_table_header)));
329
330 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
331 }
332
323 /* 333 /*
324 * Flags contains the current processor mode (Virtual or Physical 334 * Flags contains the current processor mode (Virtual or Physical
325 * addressing) The pointer_type is either Logical or Physical 335 * addressing) The pointer_type is either Logical or Physical
@@ -356,7 +366,7 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
356 */ 366 */
357 status = acpi_os_map_memory(address->pointer.physical, 367 status = acpi_os_map_memory(address->pointer.physical,
358 (acpi_size) header->length, 368 (acpi_size) header->length,
359 (void *)&full_table); 369 ACPI_CAST_PTR(void, &full_table));
360 if (ACPI_FAILURE(status)) { 370 if (ACPI_FAILURE(status)) {
361 ACPI_ERROR((AE_INFO, 371 ACPI_ERROR((AE_INFO,
362 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X", 372 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X",
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 7ca2df75bb11..1668a232fb67 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -256,7 +256,7 @@ acpi_tb_init_table_descriptor(acpi_table_type table_type,
256 256
257 status = acpi_ut_allocate_owner_id(&table_desc->owner_id); 257 status = acpi_ut_allocate_owner_id(&table_desc->owner_id);
258 if (ACPI_FAILURE(status)) { 258 if (ACPI_FAILURE(status)) {
259 return_ACPI_STATUS(status); 259 goto error_exit1;
260 } 260 }
261 261
262 /* Install the table into the global data structure */ 262 /* Install the table into the global data structure */
@@ -274,8 +274,8 @@ acpi_tb_init_table_descriptor(acpi_table_type table_type,
274 * at this location, so return an error. 274 * at this location, so return an error.
275 */ 275 */
276 if (list_head->next) { 276 if (list_head->next) {
277 ACPI_FREE(table_desc); 277 status = AE_ALREADY_EXISTS;
278 return_ACPI_STATUS(AE_ALREADY_EXISTS); 278 goto error_exit2;
279 } 279 }
280 280
281 table_desc->next = list_head->next; 281 table_desc->next = list_head->next;
@@ -335,6 +335,17 @@ acpi_tb_init_table_descriptor(acpi_table_type table_type,
335 table_info->owner_id = table_desc->owner_id; 335 table_info->owner_id = table_desc->owner_id;
336 table_info->installed_desc = table_desc; 336 table_info->installed_desc = table_desc;
337 return_ACPI_STATUS(AE_OK); 337 return_ACPI_STATUS(AE_OK);
338
339 /* Error exit with cleanup */
340
341 error_exit2:
342
343 acpi_ut_release_owner_id(&table_desc->owner_id);
344
345 error_exit1:
346
347 ACPI_FREE(table_desc);
348 return_ACPI_STATUS(status);
338} 349}
339 350
340/******************************************************************************* 351/*******************************************************************************
@@ -525,6 +536,10 @@ struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc
525 536
526 acpi_tb_delete_single_table(table_desc); 537 acpi_tb_delete_single_table(table_desc);
527 538
539 /* Free the owner ID associated with this table */
540
541 acpi_ut_release_owner_id(&table_desc->owner_id);
542
528 /* Free the table descriptor */ 543 /* Free the table descriptor */
529 544
530 next_desc = table_desc->next; 545 next_desc = table_desc->next;
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index abcb08c2592a..0ad3dbb9ebca 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -183,6 +183,17 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
183 183
184 ACPI_FUNCTION_ENTRY(); 184 ACPI_FUNCTION_ENTRY();
185 185
186 /* Validate minimum length */
187
188 if (table_ptr->length < sizeof(struct acpi_table_header)) {
189 ACPI_ERROR((AE_INFO,
190 "RSDT/XSDT length (%X) is smaller than minimum (%X)",
191 table_ptr->length,
192 sizeof(struct acpi_table_header)));
193
194 return (AE_INVALID_TABLE_LENGTH);
195 }
196
186 /* Search for appropriate signature, RSDT or XSDT */ 197 /* Search for appropriate signature, RSDT or XSDT */
187 198
188 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 199 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
@@ -210,7 +221,7 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
210 ACPI_ERROR((AE_INFO, "Looking for XSDT")); 221 ACPI_ERROR((AE_INFO, "Looking for XSDT"));
211 } 222 }
212 223
213 ACPI_DUMP_BUFFER((char *)table_ptr, 48); 224 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(char, table_ptr), 48);
214 return (AE_BAD_SIGNATURE); 225 return (AE_BAD_SIGNATURE);
215 } 226 }
216 227
@@ -258,7 +269,7 @@ acpi_status acpi_tb_get_table_rsdt(void)
258 269
259 status = acpi_tb_validate_rsdt(table_info.pointer); 270 status = acpi_tb_validate_rsdt(table_info.pointer);
260 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
261 return_ACPI_STATUS(status); 272 goto error_cleanup;
262 } 273 }
263 274
264 /* Get the number of tables defined in the RSDT or XSDT */ 275 /* Get the number of tables defined in the RSDT or XSDT */
@@ -270,14 +281,14 @@ acpi_status acpi_tb_get_table_rsdt(void)
270 281
271 status = acpi_tb_convert_to_xsdt(&table_info); 282 status = acpi_tb_convert_to_xsdt(&table_info);
272 if (ACPI_FAILURE(status)) { 283 if (ACPI_FAILURE(status)) {
273 return_ACPI_STATUS(status); 284 goto error_cleanup;
274 } 285 }
275 286
276 /* Save the table pointers and allocation info */ 287 /* Save the table pointers and allocation info */
277 288
278 status = acpi_tb_init_table_descriptor(ACPI_TABLE_ID_XSDT, &table_info); 289 status = acpi_tb_init_table_descriptor(ACPI_TABLE_ID_XSDT, &table_info);
279 if (ACPI_FAILURE(status)) { 290 if (ACPI_FAILURE(status)) {
280 return_ACPI_STATUS(status); 291 goto error_cleanup;
281 } 292 }
282 293
283 acpi_gbl_XSDT = 294 acpi_gbl_XSDT =
@@ -285,4 +296,12 @@ acpi_status acpi_tb_get_table_rsdt(void)
285 296
286 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); 297 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
287 return_ACPI_STATUS(status); 298 return_ACPI_STATUS(status);
299
300 error_cleanup:
301
302 /* Free table allocated by acpi_tb_get_table */
303
304 acpi_tb_delete_single_table(&table_info);
305
306 return_ACPI_STATUS(status);
288} 307}
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 4e91f2984815..7767987be15a 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -134,8 +134,8 @@ ACPI_EXPORT_SYMBOL(acpi_load_tables)
134 * RETURN: Status 134 * RETURN: Status
135 * 135 *
136 * DESCRIPTION: This function is called to load a table from the caller's 136 * DESCRIPTION: This function is called to load a table from the caller's
137 * buffer. The buffer must contain an entire ACPI Table including 137 * buffer. The buffer must contain an entire ACPI Table including
138 * a valid header. The header fields will be verified, and if it 138 * a valid header. The header fields will be verified, and if it
139 * is determined that the table is invalid, the call will fail. 139 * is determined that the table is invalid, the call will fail.
140 * 140 *
141 ******************************************************************************/ 141 ******************************************************************************/
@@ -245,15 +245,18 @@ acpi_status acpi_unload_table(acpi_table_type table_type)
245 /* Find all tables of the requested type */ 245 /* Find all tables of the requested type */
246 246
247 table_desc = acpi_gbl_table_lists[table_type].next; 247 table_desc = acpi_gbl_table_lists[table_type].next;
248 if (!table_desc) {
249 return_ACPI_STATUS(AE_NOT_EXIST);
250 }
251
248 while (table_desc) { 252 while (table_desc) {
249 /* 253 /*
250 * Delete all namespace entries owned by this table. Note that these 254 * Delete all namespace objects owned by this table. Note that these
251 * entries can appear anywhere in the namespace by virtue of the AML 255 * objects can appear anywhere in the namespace by virtue of the AML
252 * "Scope" operator. Thus, we need to track ownership by an ID, not 256 * "Scope" operator. Thus, we need to track ownership by an ID, not
253 * simply a position within the hierarchy 257 * simply a position within the hierarchy
254 */ 258 */
255 acpi_ns_delete_namespace_by_owner(table_desc->owner_id); 259 acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
256 acpi_ut_release_owner_id(&table_desc->owner_id);
257 table_desc = table_desc->next; 260 table_desc = table_desc->next;
258 } 261 }
259 262
@@ -275,12 +278,12 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table)
275 * see acpi_gbl_acpi_table_flag 278 * see acpi_gbl_acpi_table_flag
276 * out_table_header - pointer to the struct acpi_table_header if successful 279 * out_table_header - pointer to the struct acpi_table_header if successful
277 * 280 *
278 * DESCRIPTION: This function is called to get an ACPI table header. The caller 281 * DESCRIPTION: This function is called to get an ACPI table header. The caller
279 * supplies an pointer to a data area sufficient to contain an ACPI 282 * supplies an pointer to a data area sufficient to contain an ACPI
280 * struct acpi_table_header structure. 283 * struct acpi_table_header structure.
281 * 284 *
282 * The header contains a length field that can be used to determine 285 * The header contains a length field that can be used to determine
283 * the size of the buffer needed to contain the entire table. This 286 * the size of the buffer needed to contain the entire table. This
284 * function is not valid for the RSD PTR table since it does not 287 * function is not valid for the RSD PTR table since it does not
285 * have a standard header and is fixed length. 288 * have a standard header and is fixed length.
286 * 289 *
@@ -322,7 +325,8 @@ acpi_get_table_header(acpi_table_type table_type,
322 325
323 /* Copy the header to the caller's buffer */ 326 /* Copy the header to the caller's buffer */
324 327
325 ACPI_MEMCPY((void *)out_table_header, (void *)tbl_ptr, 328 ACPI_MEMCPY(ACPI_CAST_PTR(void, out_table_header),
329 ACPI_CAST_PTR(void, tbl_ptr),
326 sizeof(struct acpi_table_header)); 330 sizeof(struct acpi_table_header));
327 331
328 return_ACPI_STATUS(status); 332 return_ACPI_STATUS(status);
@@ -344,10 +348,10 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_header)
344 * 348 *
345 * RETURN: Status 349 * RETURN: Status
346 * 350 *
347 * DESCRIPTION: This function is called to get an ACPI table. The caller 351 * DESCRIPTION: This function is called to get an ACPI table. The caller
348 * supplies an out_buffer large enough to contain the entire ACPI 352 * supplies an out_buffer large enough to contain the entire ACPI
349 * table. The caller should call the acpi_get_table_header function 353 * table. The caller should call the acpi_get_table_header function
350 * first to determine the buffer size needed. Upon completion 354 * first to determine the buffer size needed. Upon completion
351 * the out_buffer->Length field will indicate the number of bytes 355 * the out_buffer->Length field will indicate the number of bytes
352 * copied into the out_buffer->buf_ptr buffer. This table will be 356 * copied into the out_buffer->buf_ptr buffer. This table will be
353 * a complete table including the header. 357 * a complete table including the header.
@@ -417,7 +421,9 @@ acpi_get_table(acpi_table_type table_type,
417 421
418 /* Copy the table to the buffer */ 422 /* Copy the table to the buffer */
419 423
420 ACPI_MEMCPY((void *)ret_buffer->pointer, (void *)tbl_ptr, table_length); 424 ACPI_MEMCPY(ACPI_CAST_PTR(void, ret_buffer->pointer),
425 ACPI_CAST_PTR(void, tbl_ptr), table_length);
426
421 return_ACPI_STATUS(AE_OK); 427 return_ACPI_STATUS(AE_OK);
422} 428}
423 429
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 503c0b99db12..5753d06b7860 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -176,21 +176,21 @@ struct acpi_thermal {
176 struct timer_list timer; 176 struct timer_list timer;
177}; 177};
178 178
179static struct file_operations acpi_thermal_state_fops = { 179static 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
186static struct file_operations acpi_thermal_temp_fops = { 186static 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
193static struct file_operations acpi_thermal_trip_fops = { 193static 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
201static struct file_operations acpi_thermal_cooling_fops = { 201static 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
209static struct file_operations acpi_thermal_polling_fops = { 209static 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,
@@ -1359,13 +1359,28 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1359static int acpi_thermal_resume(struct acpi_device *device, int state) 1359static int acpi_thermal_resume(struct acpi_device *device, int state)
1360{ 1360{
1361 struct acpi_thermal *tz = NULL; 1361 struct acpi_thermal *tz = NULL;
1362 int i;
1362 1363
1363 if (!device || !acpi_driver_data(device)) 1364 if (!device || !acpi_driver_data(device))
1364 return -EINVAL; 1365 return -EINVAL;
1365 1366
1366 tz = (struct acpi_thermal *)acpi_driver_data(device); 1367 tz = (struct acpi_thermal *)acpi_driver_data(device);
1367 1368
1368 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);
1369 1384
1370 return AE_OK; 1385 return AE_OK;
1371} 1386}
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 5cff17dc78b3..f6cbc0b1bfd0 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -285,6 +285,7 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
285 return (status); 285 return (status);
286} 286}
287 287
288#ifdef NOT_USED_BY_LINUX
288/******************************************************************************* 289/*******************************************************************************
289 * 290 *
290 * FUNCTION: acpi_ut_allocate 291 * FUNCTION: acpi_ut_allocate
@@ -360,3 +361,4 @@ void *acpi_ut_allocate_zeroed(acpi_size size,
360 361
361 return (allocation); 362 return (allocation);
362} 363}
364#endif
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index 5ec1cfcc611d..bb1eaf9aa653 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -47,7 +47,7 @@
47ACPI_MODULE_NAME("utdebug") 47ACPI_MODULE_NAME("utdebug")
48 48
49#ifdef ACPI_DEBUG_OUTPUT 49#ifdef ACPI_DEBUG_OUTPUT
50static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; 50static acpi_thread_id acpi_gbl_prev_thread_id;
51static char *acpi_gbl_fn_entry_str = "----Entry"; 51static char *acpi_gbl_fn_entry_str = "----Entry";
52static char *acpi_gbl_fn_exit_str = "----Exit-"; 52static char *acpi_gbl_fn_exit_str = "----Exit-";
53 53
@@ -181,7 +181,7 @@ acpi_ut_debug_print(u32 requested_debug_level,
181 if (ACPI_LV_THREADS & acpi_dbg_level) { 181 if (ACPI_LV_THREADS & acpi_dbg_level) {
182 acpi_os_printf 182 acpi_os_printf
183 ("\n**** Context Switch from TID %X to TID %X ****\n\n", 183 ("\n**** Context Switch from TID %X to TID %X ****\n\n",
184 acpi_gbl_prev_thread_id, thread_id); 184 (u32) acpi_gbl_prev_thread_id, (u32) thread_id);
185 } 185 }
186 186
187 acpi_gbl_prev_thread_id = thread_id; 187 acpi_gbl_prev_thread_id = thread_id;
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 38ebe1c54330..9d3f1149ba21 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -447,11 +447,16 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
447 */ 447 */
448 switch (ACPI_GET_OBJECT_TYPE(object)) { 448 switch (ACPI_GET_OBJECT_TYPE(object)) {
449 case ACPI_TYPE_DEVICE: 449 case ACPI_TYPE_DEVICE:
450 case ACPI_TYPE_PROCESSOR:
451 case ACPI_TYPE_POWER:
452 case ACPI_TYPE_THERMAL:
450 453
451 acpi_ut_update_ref_count(object->device.system_notify, 454 /* Update the notify objects for these types (if present) */
452 action); 455
453 acpi_ut_update_ref_count(object->device.device_notify, 456 acpi_ut_update_ref_count(object->common_notify.
454 action); 457 system_notify, action);
458 acpi_ut_update_ref_count(object->common_notify.
459 device_notify, action);
455 break; 460 break;
456 461
457 case ACPI_TYPE_PACKAGE: 462 case ACPI_TYPE_PACKAGE:
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 33268310c738..6d8a8211be90 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -65,7 +65,7 @@ ACPI_MODULE_NAME("utmisc")
65u8 acpi_ut_is_aml_table(struct acpi_table_header *table) 65u8 acpi_ut_is_aml_table(struct acpi_table_header *table)
66{ 66{
67 67
68 /* Ignore tables that contain AML */ 68 /* These are the only tables that contain executable AML */
69 69
70 if (ACPI_COMPARE_NAME(table->signature, DSDT_SIG) || 70 if (ACPI_COMPARE_NAME(table->signature, DSDT_SIG) ||
71 ACPI_COMPARE_NAME(table->signature, PSDT_SIG) || 71 ACPI_COMPARE_NAME(table->signature, PSDT_SIG) ||
@@ -419,10 +419,15 @@ void acpi_ut_set_integer_width(u8 revision)
419{ 419{
420 420
421 if (revision <= 1) { 421 if (revision <= 1) {
422
423 /* 32-bit case */
424
422 acpi_gbl_integer_bit_width = 32; 425 acpi_gbl_integer_bit_width = 32;
423 acpi_gbl_integer_nybble_width = 8; 426 acpi_gbl_integer_nybble_width = 8;
424 acpi_gbl_integer_byte_width = 4; 427 acpi_gbl_integer_byte_width = 4;
425 } else { 428 } else {
429 /* 64-bit case (ACPI 2.0+) */
430
426 acpi_gbl_integer_bit_width = 64; 431 acpi_gbl_integer_bit_width = 64;
427 acpi_gbl_integer_nybble_width = 16; 432 acpi_gbl_integer_nybble_width = 16;
428 acpi_gbl_integer_byte_width = 8; 433 acpi_gbl_integer_byte_width = 8;
@@ -502,6 +507,7 @@ acpi_ut_display_init_pathname(u8 type,
502 * FUNCTION: acpi_ut_valid_acpi_char 507 * FUNCTION: acpi_ut_valid_acpi_char
503 * 508 *
504 * PARAMETERS: Char - The character to be examined 509 * PARAMETERS: Char - The character to be examined
510 * Position - Byte position (0-3)
505 * 511 *
506 * RETURN: TRUE if the character is valid, FALSE otherwise 512 * RETURN: TRUE if the character is valid, FALSE otherwise
507 * 513 *
@@ -609,7 +615,9 @@ acpi_name acpi_ut_repair_name(acpi_name name)
609 * 615 *
610 * RETURN: Status and Converted value 616 * RETURN: Status and Converted value
611 * 617 *
612 * DESCRIPTION: Convert a string into an unsigned value. 618 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
619 * 32-bit or 64-bit conversion, depending on the current mode
620 * of the interpreter.
613 * NOTE: Does not support Octal strings, not needed. 621 * NOTE: Does not support Octal strings, not needed.
614 * 622 *
615 ******************************************************************************/ 623 ******************************************************************************/
@@ -627,7 +635,7 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
627 u8 sign_of0x = 0; 635 u8 sign_of0x = 0;
628 u8 term = 0; 636 u8 term = 0;
629 637
630 ACPI_FUNCTION_TRACE(ut_stroul64); 638 ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
631 639
632 switch (base) { 640 switch (base) {
633 case ACPI_ANY_BASE: 641 case ACPI_ANY_BASE:
@@ -675,11 +683,13 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
675 } 683 }
676 } 684 }
677 685
686 /*
687 * Perform a 32-bit or 64-bit conversion, depending upon the current
688 * execution mode of the interpreter
689 */
678 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; 690 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
679 691
680 /* At least one character in the string here */ 692 /* Main loop: convert the string to a 32- or 64-bit integer */
681
682 /* Main loop: convert the string to a 64-bit integer */
683 693
684 while (*string) { 694 while (*string) {
685 if (ACPI_IS_DIGIT(*string)) { 695 if (ACPI_IS_DIGIT(*string)) {
@@ -754,6 +764,9 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
754 764
755 all_done: 765 all_done:
756 766
767 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
768 ACPI_FORMAT_UINT64(return_value)));
769
757 *ret_integer = return_value; 770 *ret_integer = return_value;
758 return_ACPI_STATUS(AE_OK); 771 return_ACPI_STATUS(AE_OK);
759 772
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index dfc8f30ca892..c39062a047cd 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -244,14 +244,14 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
244 244
245 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 245 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
246 "Thread %X attempting to acquire Mutex [%s]\n", 246 "Thread %X attempting to acquire Mutex [%s]\n",
247 this_thread_id, acpi_ut_get_mutex_name(mutex_id))); 247 (u32) this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
248 248
249 status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, 249 status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
250 ACPI_WAIT_FOREVER); 250 ACPI_WAIT_FOREVER);
251 if (ACPI_SUCCESS(status)) { 251 if (ACPI_SUCCESS(status)) {
252 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 252 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
253 "Thread %X acquired Mutex [%s]\n", 253 "Thread %X acquired Mutex [%s]\n",
254 this_thread_id, 254 (u32) this_thread_id,
255 acpi_ut_get_mutex_name(mutex_id))); 255 acpi_ut_get_mutex_name(mutex_id)));
256 256
257 acpi_gbl_mutex_info[mutex_id].use_count++; 257 acpi_gbl_mutex_info[mutex_id].use_count++;
@@ -259,7 +259,7 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
259 } else { 259 } else {
260 ACPI_EXCEPTION((AE_INFO, status, 260 ACPI_EXCEPTION((AE_INFO, status,
261 "Thread %X could not acquire Mutex [%X]", 261 "Thread %X could not acquire Mutex [%X]",
262 this_thread_id, mutex_id)); 262 (u32) this_thread_id, mutex_id));
263 } 263 }
264 264
265 return (status); 265 return (status);
@@ -285,7 +285,7 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
285 285
286 this_thread_id = acpi_os_get_thread_id(); 286 this_thread_id = acpi_os_get_thread_id();
287 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 287 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
288 "Thread %X releasing Mutex [%s]\n", this_thread_id, 288 "Thread %X releasing Mutex [%s]\n", (u32) this_thread_id,
289 acpi_ut_get_mutex_name(mutex_id))); 289 acpi_ut_get_mutex_name(mutex_id)));
290 290
291 if (mutex_id > ACPI_MAX_MUTEX) { 291 if (mutex_id > ACPI_MAX_MUTEX) {
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index 0f5c5bb5deff..eaa13d05c859 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -199,6 +199,13 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
199 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_THREAD; 199 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_THREAD;
200 state->thread.thread_id = acpi_os_get_thread_id(); 200 state->thread.thread_id = acpi_os_get_thread_id();
201 201
202 /* Check for invalid thread ID - zero is very bad, it will break things */
203
204 if (!state->thread.thread_id) {
205 ACPI_ERROR((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId"));
206 state->thread.thread_id = (acpi_thread_id) 1;
207 }
208
202 return_PTR((struct acpi_thread_state *)state); 209 return_PTR((struct acpi_thread_state *)state);
203} 210}
204 211
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index f48227f4c8c9..d0d84c43a9d4 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -262,7 +262,7 @@ acpi_evaluate_integer(acpi_handle handle,
262 if (!data) 262 if (!data)
263 return AE_BAD_PARAMETER; 263 return AE_BAD_PARAMETER;
264 264
265 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 265 element = kmalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
266 if (!element) 266 if (!element)
267 return AE_NO_MEMORY; 267 return AE_NO_MEMORY;
268 268