diff options
Diffstat (limited to 'drivers/acpi')
43 files changed, 1019 insertions, 215 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 89eacd1bfeeb..56c5ba874623 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -132,6 +132,12 @@ config ACPI_FAN | |||
132 | This driver adds support for ACPI fan devices, allowing user-mode | 132 | This driver adds support for ACPI fan devices, allowing user-mode |
133 | applications to perform basic fan control (on, off, status). | 133 | applications to perform basic fan control (on, off, status). |
134 | 134 | ||
135 | config ACPI_DOCK | ||
136 | tristate "Dock" | ||
137 | depends on EXPERIMENTAL | ||
138 | help | ||
139 | This driver adds support for ACPI controlled docking stations | ||
140 | |||
135 | config ACPI_PROCESSOR | 141 | config ACPI_PROCESSOR |
136 | tristate "Processor" | 142 | tristate "Processor" |
137 | default y | 143 | default y |
@@ -206,6 +212,7 @@ config ACPI_IBM | |||
206 | config ACPI_IBM_DOCK | 212 | config ACPI_IBM_DOCK |
207 | bool "Legacy Docking Station Support" | 213 | bool "Legacy Docking Station Support" |
208 | depends on ACPI_IBM | 214 | depends on ACPI_IBM |
215 | depends on ACPI_DOCK=n | ||
209 | default n | 216 | default n |
210 | ---help--- | 217 | ---help--- |
211 | Allows the ibm_acpi driver to handle docking station events. | 218 | Allows the ibm_acpi driver to handle docking station events. |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index bb5b80a80b18..bce7ca27b429 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -42,6 +42,7 @@ obj-$(CONFIG_ACPI_BATTERY) += battery.o | |||
42 | obj-$(CONFIG_ACPI_BUTTON) += button.o | 42 | obj-$(CONFIG_ACPI_BUTTON) += button.o |
43 | obj-$(CONFIG_ACPI_EC) += ec.o | 43 | obj-$(CONFIG_ACPI_EC) += ec.o |
44 | obj-$(CONFIG_ACPI_FAN) += fan.o | 44 | obj-$(CONFIG_ACPI_FAN) += fan.o |
45 | obj-$(CONFIG_ACPI_DOCK) += dock.o | ||
45 | obj-$(CONFIG_ACPI_VIDEO) += video.o | 46 | obj-$(CONFIG_ACPI_VIDEO) += video.o |
46 | obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o | 47 | obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o |
47 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 48 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 24ccf81d135f..96309b9660da 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 | ||
75 | static struct file_operations acpi_ac_fops = { | 75 | static 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, |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 24bf4dca88cc..6e5221707d97 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 | ||
560 | static struct file_operations acpi_battery_info_ops = { | 560 | static 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 | ||
568 | static struct file_operations acpi_battery_state_ops = { | 568 | static 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 | ||
576 | static struct file_operations acpi_battery_alarm_ops = { | 576 | static 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, |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index ea5a0496a4fd..b2977695e120 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -192,8 +192,8 @@ int acpi_bus_set_power(acpi_handle handle, int state) | |||
192 | /* Make sure this is a valid target state */ | 192 | /* Make sure this is a valid target state */ |
193 | 193 | ||
194 | if (!device->flags.power_manageable) { | 194 | if (!device->flags.power_manageable) { |
195 | printk(KERN_DEBUG "Device `[%s]' is not power manageable", | 195 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable", |
196 | device->kobj.name); | 196 | device->kobj.name)); |
197 | return -ENODEV; | 197 | return -ENODEV; |
198 | } | 198 | } |
199 | /* | 199 | /* |
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 | ||
90 | static struct file_operations acpi_button_info_fops = { | 90 | static 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 | ||
97 | static struct file_operations acpi_button_state_fops = { | 97 | static 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") | |||
39 | static struct proc_dir_entry *acpi_ac_dir; | 39 | static struct proc_dir_entry *acpi_ac_dir; |
40 | static struct proc_dir_entry *acpi_battery_dir; | 40 | static struct proc_dir_entry *acpi_battery_dir; |
41 | 41 | ||
42 | static struct semaphore cm_sbs_sem; | 42 | static DEFINE_MUTEX(cm_sbs_mutex); |
43 | 43 | ||
44 | static int lock_ac_dir_cnt = 0; | 44 | static int lock_ac_dir_cnt; |
45 | static int lock_battery_dir_cnt = 0; | 45 | static int lock_battery_dir_cnt; |
46 | 46 | ||
47 | struct proc_dir_entry *acpi_lock_ac_dir(void) | 47 | struct 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 | |||
64 | EXPORT_SYMBOL(acpi_lock_ac_dir); | 61 | EXPORT_SYMBOL(acpi_lock_ac_dir); |
65 | 62 | ||
66 | void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param) | 63 | void 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 | |||
80 | EXPORT_SYMBOL(acpi_unlock_ac_dir); | 74 | EXPORT_SYMBOL(acpi_unlock_ac_dir); |
81 | 75 | ||
82 | struct proc_dir_entry *acpi_lock_battery_dir(void) | 76 | struct 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 | |||
100 | EXPORT_SYMBOL(acpi_lock_battery_dir); | 92 | EXPORT_SYMBOL(acpi_lock_battery_dir); |
101 | 93 | ||
102 | void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param) | 94 | void 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 | |||
118 | EXPORT_SYMBOL(acpi_unlock_battery_dir); | 107 | EXPORT_SYMBOL(acpi_unlock_battery_dir); |
119 | 108 | ||
120 | static int __init acpi_cm_sbs_init(void) | 109 | static 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 | |||
131 | subsys_initcall(acpi_cm_sbs_init); | 113 | subsys_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 new file mode 100644 index 000000000000..1c0a39d8b04e --- /dev/null +++ b/drivers/acpi/dock.c | |||
@@ -0,0 +1,740 @@ | |||
1 | /* | ||
2 | * dock.c - ACPI dock station driver | ||
3 | * | ||
4 | * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com> | ||
5 | * | ||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
11 | * your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License along | ||
19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
21 | * | ||
22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
23 | */ | ||
24 | |||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/types.h> | ||
29 | #include <linux/notifier.h> | ||
30 | #include <acpi/acpi_bus.h> | ||
31 | #include <acpi/acpi_drivers.h> | ||
32 | |||
33 | #define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver" | ||
34 | |||
35 | ACPI_MODULE_NAME("dock") | ||
36 | MODULE_AUTHOR("Kristen Carlson Accardi"); | ||
37 | MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME); | ||
38 | MODULE_LICENSE("GPL"); | ||
39 | |||
40 | static struct atomic_notifier_head dock_notifier_list; | ||
41 | |||
42 | struct dock_station { | ||
43 | acpi_handle handle; | ||
44 | unsigned long last_dock_time; | ||
45 | u32 flags; | ||
46 | spinlock_t dd_lock; | ||
47 | spinlock_t hp_lock; | ||
48 | struct list_head dependent_devices; | ||
49 | struct list_head hotplug_devices; | ||
50 | }; | ||
51 | |||
52 | struct dock_dependent_device { | ||
53 | struct list_head list; | ||
54 | struct list_head hotplug_list; | ||
55 | acpi_handle handle; | ||
56 | acpi_notify_handler handler; | ||
57 | void *context; | ||
58 | }; | ||
59 | |||
60 | #define DOCK_DOCKING 0x00000001 | ||
61 | #define DOCK_EVENT KOBJ_DOCK | ||
62 | #define UNDOCK_EVENT KOBJ_UNDOCK | ||
63 | |||
64 | static struct dock_station *dock_station; | ||
65 | |||
66 | /***************************************************************************** | ||
67 | * Dock Dependent device functions * | ||
68 | *****************************************************************************/ | ||
69 | /** | ||
70 | * alloc_dock_dependent_device - allocate and init a dependent device | ||
71 | * @handle: the acpi_handle of the dependent device | ||
72 | * | ||
73 | * Allocate memory for a dependent device structure for a device referenced | ||
74 | * by the acpi handle | ||
75 | */ | ||
76 | static struct dock_dependent_device * | ||
77 | alloc_dock_dependent_device(acpi_handle handle) | ||
78 | { | ||
79 | struct dock_dependent_device *dd; | ||
80 | |||
81 | dd = kzalloc(sizeof(*dd), GFP_KERNEL); | ||
82 | if (dd) { | ||
83 | dd->handle = handle; | ||
84 | INIT_LIST_HEAD(&dd->list); | ||
85 | INIT_LIST_HEAD(&dd->hotplug_list); | ||
86 | } | ||
87 | return dd; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * add_dock_dependent_device - associate a device with the dock station | ||
92 | * @ds: The dock station | ||
93 | * @dd: The dependent device | ||
94 | * | ||
95 | * Add the dependent device to the dock's dependent device list. | ||
96 | */ | ||
97 | static void | ||
98 | add_dock_dependent_device(struct dock_station *ds, | ||
99 | struct dock_dependent_device *dd) | ||
100 | { | ||
101 | spin_lock(&ds->dd_lock); | ||
102 | list_add_tail(&dd->list, &ds->dependent_devices); | ||
103 | spin_unlock(&ds->dd_lock); | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * dock_add_hotplug_device - associate a hotplug handler with the dock station | ||
108 | * @ds: The dock station | ||
109 | * @dd: The dependent device struct | ||
110 | * | ||
111 | * Add the dependent device to the dock's hotplug device list | ||
112 | */ | ||
113 | static void | ||
114 | dock_add_hotplug_device(struct dock_station *ds, | ||
115 | struct dock_dependent_device *dd) | ||
116 | { | ||
117 | spin_lock(&ds->hp_lock); | ||
118 | list_add_tail(&dd->hotplug_list, &ds->hotplug_devices); | ||
119 | spin_unlock(&ds->hp_lock); | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * dock_del_hotplug_device - remove a hotplug handler from the dock station | ||
124 | * @ds: The dock station | ||
125 | * @dd: the dependent device struct | ||
126 | * | ||
127 | * Delete the dependent device from the dock's hotplug device list | ||
128 | */ | ||
129 | static void | ||
130 | dock_del_hotplug_device(struct dock_station *ds, | ||
131 | struct dock_dependent_device *dd) | ||
132 | { | ||
133 | spin_lock(&ds->hp_lock); | ||
134 | list_del(&dd->hotplug_list); | ||
135 | spin_unlock(&ds->hp_lock); | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * find_dock_dependent_device - get a device dependent on this dock | ||
140 | * @ds: the dock station | ||
141 | * @handle: the acpi_handle of the device we want | ||
142 | * | ||
143 | * iterate over the dependent device list for this dock. If the | ||
144 | * dependent device matches the handle, return. | ||
145 | */ | ||
146 | static struct dock_dependent_device * | ||
147 | find_dock_dependent_device(struct dock_station *ds, acpi_handle handle) | ||
148 | { | ||
149 | struct dock_dependent_device *dd; | ||
150 | |||
151 | spin_lock(&ds->dd_lock); | ||
152 | list_for_each_entry(dd, &ds->dependent_devices, list) { | ||
153 | if (handle == dd->handle) { | ||
154 | spin_unlock(&ds->dd_lock); | ||
155 | return dd; | ||
156 | } | ||
157 | } | ||
158 | spin_unlock(&ds->dd_lock); | ||
159 | return NULL; | ||
160 | } | ||
161 | |||
162 | /***************************************************************************** | ||
163 | * Dock functions * | ||
164 | *****************************************************************************/ | ||
165 | /** | ||
166 | * is_dock - see if a device is a dock station | ||
167 | * @handle: acpi handle of the device | ||
168 | * | ||
169 | * If an acpi object has a _DCK method, then it is by definition a dock | ||
170 | * station, so return true. | ||
171 | */ | ||
172 | static int is_dock(acpi_handle handle) | ||
173 | { | ||
174 | acpi_status status; | ||
175 | acpi_handle tmp; | ||
176 | |||
177 | status = acpi_get_handle(handle, "_DCK", &tmp); | ||
178 | if (ACPI_FAILURE(status)) | ||
179 | return 0; | ||
180 | return 1; | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * is_dock_device - see if a device is on a dock station | ||
185 | * @handle: acpi handle of the device | ||
186 | * | ||
187 | * If this device is either the dock station itself, | ||
188 | * or is a device dependent on the dock station, then it | ||
189 | * is a dock device | ||
190 | */ | ||
191 | int is_dock_device(acpi_handle handle) | ||
192 | { | ||
193 | if (!dock_station) | ||
194 | return 0; | ||
195 | |||
196 | if (is_dock(handle) || find_dock_dependent_device(dock_station, handle)) | ||
197 | return 1; | ||
198 | |||
199 | return 0; | ||
200 | } | ||
201 | |||
202 | EXPORT_SYMBOL_GPL(is_dock_device); | ||
203 | |||
204 | /** | ||
205 | * dock_present - see if the dock station is present. | ||
206 | * @ds: the dock station | ||
207 | * | ||
208 | * execute the _STA method. note that present does not | ||
209 | * imply that we are docked. | ||
210 | */ | ||
211 | static int dock_present(struct dock_station *ds) | ||
212 | { | ||
213 | unsigned long sta; | ||
214 | acpi_status status; | ||
215 | |||
216 | if (ds) { | ||
217 | status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta); | ||
218 | if (ACPI_SUCCESS(status) && sta) | ||
219 | return 1; | ||
220 | } | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | |||
225 | |||
226 | /** | ||
227 | * dock_create_acpi_device - add new devices to acpi | ||
228 | * @handle - handle of the device to add | ||
229 | * | ||
230 | * This function will create a new acpi_device for the given | ||
231 | * handle if one does not exist already. This should cause | ||
232 | * acpi to scan for drivers for the given devices, and call | ||
233 | * matching driver's add routine. | ||
234 | * | ||
235 | * Returns a pointer to the acpi_device corresponding to the handle. | ||
236 | */ | ||
237 | static struct acpi_device * dock_create_acpi_device(acpi_handle handle) | ||
238 | { | ||
239 | struct acpi_device *device = NULL; | ||
240 | struct acpi_device *parent_device; | ||
241 | acpi_handle parent; | ||
242 | int ret; | ||
243 | |||
244 | if (acpi_bus_get_device(handle, &device)) { | ||
245 | /* | ||
246 | * no device created for this object, | ||
247 | * so we should create one. | ||
248 | */ | ||
249 | acpi_get_parent(handle, &parent); | ||
250 | if (acpi_bus_get_device(parent, &parent_device)) | ||
251 | parent_device = NULL; | ||
252 | |||
253 | ret = acpi_bus_add(&device, parent_device, handle, | ||
254 | ACPI_BUS_TYPE_DEVICE); | ||
255 | if (ret) { | ||
256 | pr_debug("error adding bus, %x\n", | ||
257 | -ret); | ||
258 | return NULL; | ||
259 | } | ||
260 | } | ||
261 | return device; | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * dock_remove_acpi_device - remove the acpi_device struct from acpi | ||
266 | * @handle - the handle of the device to remove | ||
267 | * | ||
268 | * Tell acpi to remove the acpi_device. This should cause any loaded | ||
269 | * driver to have it's remove routine called. | ||
270 | */ | ||
271 | static void dock_remove_acpi_device(acpi_handle handle) | ||
272 | { | ||
273 | struct acpi_device *device; | ||
274 | int ret; | ||
275 | |||
276 | if (!acpi_bus_get_device(handle, &device)) { | ||
277 | ret = acpi_bus_trim(device, 1); | ||
278 | if (ret) | ||
279 | pr_debug("error removing bus, %x\n", -ret); | ||
280 | } | ||
281 | } | ||
282 | |||
283 | |||
284 | /** | ||
285 | * hotplug_dock_devices - insert or remove devices on the dock station | ||
286 | * @ds: the dock station | ||
287 | * @event: either bus check or eject request | ||
288 | * | ||
289 | * Some devices on the dock station need to have drivers called | ||
290 | * to perform hotplug operations after a dock event has occurred. | ||
291 | * Traverse the list of dock devices that have registered a | ||
292 | * hotplug handler, and call the handler. | ||
293 | */ | ||
294 | static void hotplug_dock_devices(struct dock_station *ds, u32 event) | ||
295 | { | ||
296 | struct dock_dependent_device *dd; | ||
297 | |||
298 | spin_lock(&ds->hp_lock); | ||
299 | |||
300 | /* | ||
301 | * First call driver specific hotplug functions | ||
302 | */ | ||
303 | list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) { | ||
304 | if (dd->handler) | ||
305 | dd->handler(dd->handle, event, dd->context); | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | * Now make sure that an acpi_device is created for each | ||
310 | * dependent device, or removed if this is an eject request. | ||
311 | * This will cause acpi_drivers to be stopped/started if they | ||
312 | * exist | ||
313 | */ | ||
314 | list_for_each_entry(dd, &ds->dependent_devices, list) { | ||
315 | if (event == ACPI_NOTIFY_EJECT_REQUEST) | ||
316 | dock_remove_acpi_device(dd->handle); | ||
317 | else | ||
318 | dock_create_acpi_device(dd->handle); | ||
319 | } | ||
320 | spin_unlock(&ds->hp_lock); | ||
321 | } | ||
322 | |||
323 | static void dock_event(struct dock_station *ds, u32 event, int num) | ||
324 | { | ||
325 | struct acpi_device *device; | ||
326 | |||
327 | device = dock_create_acpi_device(ds->handle); | ||
328 | if (device) | ||
329 | kobject_uevent(&device->kobj, num); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * eject_dock - respond to a dock eject request | ||
334 | * @ds: the dock station | ||
335 | * | ||
336 | * This is called after _DCK is called, to execute the dock station's | ||
337 | * _EJ0 method. | ||
338 | */ | ||
339 | static void eject_dock(struct dock_station *ds) | ||
340 | { | ||
341 | struct acpi_object_list arg_list; | ||
342 | union acpi_object arg; | ||
343 | acpi_status status; | ||
344 | acpi_handle tmp; | ||
345 | |||
346 | /* all dock devices should have _EJ0, but check anyway */ | ||
347 | status = acpi_get_handle(ds->handle, "_EJ0", &tmp); | ||
348 | if (ACPI_FAILURE(status)) { | ||
349 | pr_debug("No _EJ0 support for dock device\n"); | ||
350 | return; | ||
351 | } | ||
352 | |||
353 | arg_list.count = 1; | ||
354 | arg_list.pointer = &arg; | ||
355 | arg.type = ACPI_TYPE_INTEGER; | ||
356 | arg.integer.value = 1; | ||
357 | |||
358 | if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", | ||
359 | &arg_list, NULL))) | ||
360 | pr_debug("Failed to evaluate _EJ0!\n"); | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * handle_dock - handle a dock event | ||
365 | * @ds: the dock station | ||
366 | * @dock: to dock, or undock - that is the question | ||
367 | * | ||
368 | * Execute the _DCK method in response to an acpi event | ||
369 | */ | ||
370 | static void handle_dock(struct dock_station *ds, int dock) | ||
371 | { | ||
372 | acpi_status status; | ||
373 | struct acpi_object_list arg_list; | ||
374 | union acpi_object arg; | ||
375 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
376 | struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
377 | union acpi_object *obj; | ||
378 | |||
379 | acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer); | ||
380 | obj = name_buffer.pointer; | ||
381 | |||
382 | printk(KERN_INFO PREFIX "%s\n", dock ? "docking" : "undocking"); | ||
383 | |||
384 | /* _DCK method has one argument */ | ||
385 | arg_list.count = 1; | ||
386 | arg_list.pointer = &arg; | ||
387 | arg.type = ACPI_TYPE_INTEGER; | ||
388 | arg.integer.value = dock; | ||
389 | status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); | ||
390 | if (ACPI_FAILURE(status)) | ||
391 | pr_debug("%s: failed to execute _DCK\n", obj->string.pointer); | ||
392 | kfree(buffer.pointer); | ||
393 | kfree(name_buffer.pointer); | ||
394 | } | ||
395 | |||
396 | static inline void dock(struct dock_station *ds) | ||
397 | { | ||
398 | handle_dock(ds, 1); | ||
399 | } | ||
400 | |||
401 | static inline void undock(struct dock_station *ds) | ||
402 | { | ||
403 | handle_dock(ds, 0); | ||
404 | } | ||
405 | |||
406 | static inline void begin_dock(struct dock_station *ds) | ||
407 | { | ||
408 | ds->flags |= DOCK_DOCKING; | ||
409 | } | ||
410 | |||
411 | static inline void complete_dock(struct dock_station *ds) | ||
412 | { | ||
413 | ds->flags &= ~(DOCK_DOCKING); | ||
414 | ds->last_dock_time = jiffies; | ||
415 | } | ||
416 | |||
417 | /** | ||
418 | * dock_in_progress - see if we are in the middle of handling a dock event | ||
419 | * @ds: the dock station | ||
420 | * | ||
421 | * Sometimes while docking, false dock events can be sent to the driver | ||
422 | * because good connections aren't made or some other reason. Ignore these | ||
423 | * if we are in the middle of doing something. | ||
424 | */ | ||
425 | static int dock_in_progress(struct dock_station *ds) | ||
426 | { | ||
427 | if ((ds->flags & DOCK_DOCKING) || | ||
428 | time_before(jiffies, (ds->last_dock_time + HZ))) | ||
429 | return 1; | ||
430 | return 0; | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * register_dock_notifier - add yourself to the dock notifier list | ||
435 | * @nb: the callers notifier block | ||
436 | * | ||
437 | * If a driver wishes to be notified about dock events, they can | ||
438 | * use this function to put a notifier block on the dock notifier list. | ||
439 | * this notifier call chain will be called after a dock event, but | ||
440 | * before hotplugging any new devices. | ||
441 | */ | ||
442 | int register_dock_notifier(struct notifier_block *nb) | ||
443 | { | ||
444 | return atomic_notifier_chain_register(&dock_notifier_list, nb); | ||
445 | } | ||
446 | |||
447 | EXPORT_SYMBOL_GPL(register_dock_notifier); | ||
448 | |||
449 | /** | ||
450 | * unregister_dock_notifier - remove yourself from the dock notifier list | ||
451 | * @nb: the callers notifier block | ||
452 | */ | ||
453 | void unregister_dock_notifier(struct notifier_block *nb) | ||
454 | { | ||
455 | atomic_notifier_chain_unregister(&dock_notifier_list, nb); | ||
456 | } | ||
457 | |||
458 | EXPORT_SYMBOL_GPL(unregister_dock_notifier); | ||
459 | |||
460 | /** | ||
461 | * register_hotplug_dock_device - register a hotplug function | ||
462 | * @handle: the handle of the device | ||
463 | * @handler: the acpi_notifier_handler to call after docking | ||
464 | * @context: device specific data | ||
465 | * | ||
466 | * If a driver would like to perform a hotplug operation after a dock | ||
467 | * event, they can register an acpi_notifiy_handler to be called by | ||
468 | * the dock driver after _DCK is executed. | ||
469 | */ | ||
470 | int | ||
471 | register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler, | ||
472 | void *context) | ||
473 | { | ||
474 | struct dock_dependent_device *dd; | ||
475 | |||
476 | if (!dock_station) | ||
477 | return -ENODEV; | ||
478 | |||
479 | /* | ||
480 | * make sure this handle is for a device dependent on the dock, | ||
481 | * this would include the dock station itself | ||
482 | */ | ||
483 | dd = find_dock_dependent_device(dock_station, handle); | ||
484 | if (dd) { | ||
485 | dd->handler = handler; | ||
486 | dd->context = context; | ||
487 | dock_add_hotplug_device(dock_station, dd); | ||
488 | return 0; | ||
489 | } | ||
490 | |||
491 | return -EINVAL; | ||
492 | } | ||
493 | |||
494 | EXPORT_SYMBOL_GPL(register_hotplug_dock_device); | ||
495 | |||
496 | /** | ||
497 | * unregister_hotplug_dock_device - remove yourself from the hotplug list | ||
498 | * @handle: the acpi handle of the device | ||
499 | */ | ||
500 | void unregister_hotplug_dock_device(acpi_handle handle) | ||
501 | { | ||
502 | struct dock_dependent_device *dd; | ||
503 | |||
504 | if (!dock_station) | ||
505 | return; | ||
506 | |||
507 | dd = find_dock_dependent_device(dock_station, handle); | ||
508 | if (dd) | ||
509 | dock_del_hotplug_device(dock_station, dd); | ||
510 | } | ||
511 | |||
512 | EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); | ||
513 | |||
514 | /** | ||
515 | * dock_notify - act upon an acpi dock notification | ||
516 | * @handle: the dock station handle | ||
517 | * @event: the acpi event | ||
518 | * @data: our driver data struct | ||
519 | * | ||
520 | * If we are notified to dock, then check to see if the dock is | ||
521 | * present and then dock. Notify all drivers of the dock event, | ||
522 | * and then hotplug and devices that may need hotplugging. For undock | ||
523 | * check to make sure the dock device is still present, then undock | ||
524 | * and hotremove all the devices that may need removing. | ||
525 | */ | ||
526 | static void dock_notify(acpi_handle handle, u32 event, void *data) | ||
527 | { | ||
528 | struct dock_station *ds = (struct dock_station *)data; | ||
529 | |||
530 | switch (event) { | ||
531 | case ACPI_NOTIFY_BUS_CHECK: | ||
532 | if (!dock_in_progress(ds) && dock_present(ds)) { | ||
533 | begin_dock(ds); | ||
534 | dock(ds); | ||
535 | if (!dock_present(ds)) { | ||
536 | printk(KERN_ERR PREFIX "Unable to dock!\n"); | ||
537 | break; | ||
538 | } | ||
539 | atomic_notifier_call_chain(&dock_notifier_list, | ||
540 | event, NULL); | ||
541 | hotplug_dock_devices(ds, event); | ||
542 | complete_dock(ds); | ||
543 | dock_event(ds, event, DOCK_EVENT); | ||
544 | } | ||
545 | break; | ||
546 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
547 | /* | ||
548 | * According to acpi spec 3.0a, if a DEVICE_CHECK notification | ||
549 | * is sent and _DCK is present, it is assumed to mean an | ||
550 | * undock request. This notify routine will only be called | ||
551 | * for objects defining _DCK, so we will fall through to eject | ||
552 | * request here. However, we will pass an eject request through | ||
553 | * to the driver who wish to hotplug. | ||
554 | */ | ||
555 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
556 | if (!dock_in_progress(ds) && dock_present(ds)) { | ||
557 | /* | ||
558 | * here we need to generate the undock | ||
559 | * event prior to actually doing the undock | ||
560 | * so that the device struct still exists. | ||
561 | */ | ||
562 | dock_event(ds, event, UNDOCK_EVENT); | ||
563 | hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); | ||
564 | undock(ds); | ||
565 | eject_dock(ds); | ||
566 | if (dock_present(ds)) | ||
567 | printk(KERN_ERR PREFIX "Unable to undock!\n"); | ||
568 | } | ||
569 | break; | ||
570 | default: | ||
571 | printk(KERN_ERR PREFIX "Unknown dock event %d\n", event); | ||
572 | } | ||
573 | } | ||
574 | |||
575 | /** | ||
576 | * find_dock_devices - find devices on the dock station | ||
577 | * @handle: the handle of the device we are examining | ||
578 | * @lvl: unused | ||
579 | * @context: the dock station private data | ||
580 | * @rv: unused | ||
581 | * | ||
582 | * This function is called by acpi_walk_namespace. It will | ||
583 | * check to see if an object has an _EJD method. If it does, then it | ||
584 | * will see if it is dependent on the dock station. | ||
585 | */ | ||
586 | static acpi_status | ||
587 | find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
588 | { | ||
589 | acpi_status status; | ||
590 | acpi_handle tmp; | ||
591 | struct dock_station *ds = (struct dock_station *)context; | ||
592 | struct dock_dependent_device *dd; | ||
593 | |||
594 | status = acpi_bus_get_ejd(handle, &tmp); | ||
595 | if (ACPI_FAILURE(status)) | ||
596 | return AE_OK; | ||
597 | |||
598 | if (tmp == ds->handle) { | ||
599 | dd = alloc_dock_dependent_device(handle); | ||
600 | if (dd) | ||
601 | add_dock_dependent_device(ds, dd); | ||
602 | } | ||
603 | |||
604 | return AE_OK; | ||
605 | } | ||
606 | |||
607 | /** | ||
608 | * dock_add - add a new dock station | ||
609 | * @handle: the dock station handle | ||
610 | * | ||
611 | * allocated and initialize a new dock station device. Find all devices | ||
612 | * that are on the dock station, and register for dock event notifications. | ||
613 | */ | ||
614 | static int dock_add(acpi_handle handle) | ||
615 | { | ||
616 | int ret; | ||
617 | acpi_status status; | ||
618 | struct dock_dependent_device *dd; | ||
619 | |||
620 | /* allocate & initialize the dock_station private data */ | ||
621 | dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL); | ||
622 | if (!dock_station) | ||
623 | return -ENOMEM; | ||
624 | dock_station->handle = handle; | ||
625 | dock_station->last_dock_time = jiffies - HZ; | ||
626 | INIT_LIST_HEAD(&dock_station->dependent_devices); | ||
627 | INIT_LIST_HEAD(&dock_station->hotplug_devices); | ||
628 | spin_lock_init(&dock_station->dd_lock); | ||
629 | spin_lock_init(&dock_station->hp_lock); | ||
630 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); | ||
631 | |||
632 | /* Find dependent devices */ | ||
633 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
634 | ACPI_UINT32_MAX, find_dock_devices, dock_station, | ||
635 | NULL); | ||
636 | |||
637 | /* add the dock station as a device dependent on itself */ | ||
638 | dd = alloc_dock_dependent_device(handle); | ||
639 | if (!dd) { | ||
640 | kfree(dock_station); | ||
641 | return -ENOMEM; | ||
642 | } | ||
643 | add_dock_dependent_device(dock_station, dd); | ||
644 | |||
645 | /* register for dock events */ | ||
646 | status = acpi_install_notify_handler(dock_station->handle, | ||
647 | ACPI_SYSTEM_NOTIFY, | ||
648 | dock_notify, dock_station); | ||
649 | |||
650 | if (ACPI_FAILURE(status)) { | ||
651 | printk(KERN_ERR PREFIX "Error installing notify handler\n"); | ||
652 | ret = -ENODEV; | ||
653 | goto dock_add_err; | ||
654 | } | ||
655 | |||
656 | printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME); | ||
657 | |||
658 | return 0; | ||
659 | |||
660 | dock_add_err: | ||
661 | kfree(dock_station); | ||
662 | kfree(dd); | ||
663 | return ret; | ||
664 | } | ||
665 | |||
666 | /** | ||
667 | * dock_remove - free up resources related to the dock station | ||
668 | */ | ||
669 | static int dock_remove(void) | ||
670 | { | ||
671 | struct dock_dependent_device *dd, *tmp; | ||
672 | acpi_status status; | ||
673 | |||
674 | if (!dock_station) | ||
675 | return 0; | ||
676 | |||
677 | /* remove dependent devices */ | ||
678 | list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices, | ||
679 | list) | ||
680 | kfree(dd); | ||
681 | |||
682 | /* remove dock notify handler */ | ||
683 | status = acpi_remove_notify_handler(dock_station->handle, | ||
684 | ACPI_SYSTEM_NOTIFY, | ||
685 | dock_notify); | ||
686 | if (ACPI_FAILURE(status)) | ||
687 | printk(KERN_ERR "Error removing notify handler\n"); | ||
688 | |||
689 | /* free dock station memory */ | ||
690 | kfree(dock_station); | ||
691 | return 0; | ||
692 | } | ||
693 | |||
694 | /** | ||
695 | * find_dock - look for a dock station | ||
696 | * @handle: acpi handle of a device | ||
697 | * @lvl: unused | ||
698 | * @context: counter of dock stations found | ||
699 | * @rv: unused | ||
700 | * | ||
701 | * This is called by acpi_walk_namespace to look for dock stations. | ||
702 | */ | ||
703 | static acpi_status | ||
704 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
705 | { | ||
706 | int *count = (int *)context; | ||
707 | acpi_status status = AE_OK; | ||
708 | |||
709 | if (is_dock(handle)) { | ||
710 | if (dock_add(handle) >= 0) { | ||
711 | (*count)++; | ||
712 | status = AE_CTRL_TERMINATE; | ||
713 | } | ||
714 | } | ||
715 | return status; | ||
716 | } | ||
717 | |||
718 | static int __init dock_init(void) | ||
719 | { | ||
720 | int num = 0; | ||
721 | |||
722 | dock_station = NULL; | ||
723 | |||
724 | /* look for a dock station */ | ||
725 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
726 | ACPI_UINT32_MAX, find_dock, &num, NULL); | ||
727 | |||
728 | if (!num) | ||
729 | return -ENODEV; | ||
730 | |||
731 | return 0; | ||
732 | } | ||
733 | |||
734 | static void __exit dock_exit(void) | ||
735 | { | ||
736 | dock_remove(); | ||
737 | } | ||
738 | |||
739 | postcore_initcall(dock_init); | ||
740 | module_exit(dock_exit); | ||
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 | ||
932 | static struct file_operations acpi_ec_info_ops = { | 932 | static 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 | ||
102 | static struct file_operations acpi_system_event_ops = { | 102 | static 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 | ||
533 | unlock: | 541 | unlock_and_exit: |
534 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 542 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
535 | exit: | 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 | ||
631 | unlock: | 639 | unlock_and_exit: |
632 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 640 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
633 | exit: | 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 | ******************************************************************************/ |
66 | acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) | 66 | acpi_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 | ||
123 | static struct file_operations acpi_fan_state_ops = { | 123 | static 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..32c9d88fd196 100644 --- a/drivers/acpi/hotkey.c +++ b/drivers/acpi/hotkey.c | |||
@@ -184,7 +184,7 @@ static union acpi_hotkey *get_hotkey_by_event(struct | |||
184 | *hotkey_list, int event); | 184 | *hotkey_list, int event); |
185 | 185 | ||
186 | /* event based config */ | 186 | /* event based config */ |
187 | static struct file_operations hotkey_config_fops = { | 187 | static const struct file_operations hotkey_config_fops = { |
188 | .open = hotkey_open_config, | 188 | .open = hotkey_open_config, |
189 | .read = seq_read, | 189 | .read = seq_read, |
190 | .write = hotkey_write_config, | 190 | .write = hotkey_write_config, |
@@ -193,7 +193,7 @@ static struct file_operations hotkey_config_fops = { | |||
193 | }; | 193 | }; |
194 | 194 | ||
195 | /* polling based config */ | 195 | /* polling based config */ |
196 | static struct file_operations hotkey_poll_config_fops = { | 196 | static const struct file_operations hotkey_poll_config_fops = { |
197 | .open = hotkey_poll_open_config, | 197 | .open = hotkey_poll_open_config, |
198 | .read = seq_read, | 198 | .read = seq_read, |
199 | .write = hotkey_write_config, | 199 | .write = hotkey_write_config, |
@@ -202,7 +202,7 @@ static struct file_operations hotkey_poll_config_fops = { | |||
202 | }; | 202 | }; |
203 | 203 | ||
204 | /* hotkey driver info */ | 204 | /* hotkey driver info */ |
205 | static struct file_operations hotkey_info_fops = { | 205 | static const struct file_operations hotkey_info_fops = { |
206 | .open = hotkey_info_open_fs, | 206 | .open = hotkey_info_open_fs, |
207 | .read = seq_read, | 207 | .read = seq_read, |
208 | .llseek = seq_lseek, | 208 | .llseek = seq_lseek, |
@@ -210,7 +210,7 @@ static struct file_operations hotkey_info_fops = { | |||
210 | }; | 210 | }; |
211 | 211 | ||
212 | /* action */ | 212 | /* action */ |
213 | static struct file_operations hotkey_action_fops = { | 213 | static const struct file_operations hotkey_action_fops = { |
214 | .open = hotkey_action_open_fs, | 214 | .open = hotkey_action_open_fs, |
215 | .read = seq_read, | 215 | .read = seq_read, |
216 | .write = hotkey_execute_aml_method, | 216 | .write = hotkey_execute_aml_method, |
@@ -219,7 +219,7 @@ static struct file_operations hotkey_action_fops = { | |||
219 | }; | 219 | }; |
220 | 220 | ||
221 | /* polling results */ | 221 | /* polling results */ |
222 | static struct file_operations hotkey_polling_fops = { | 222 | static const struct file_operations hotkey_polling_fops = { |
223 | .open = hotkey_polling_open_fs, | 223 | .open = hotkey_polling_open_fs, |
224 | .read = seq_read, | 224 | .read = seq_read, |
225 | .llseek = seq_lseek, | 225 | .llseek = seq_lseek, |
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 | ||
391 | void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id) | 393 | void 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..47dfde95b8f8 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -136,16 +136,6 @@ void acpi_os_vprintf(const char *fmt, va_list args) | |||
136 | #endif | 136 | #endif |
137 | } | 137 | } |
138 | 138 | ||
139 | |||
140 | extern int acpi_in_resume; | ||
141 | void *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 | |||
149 | acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) | 139 | acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) |
150 | { | 140 | { |
151 | if (efi_enabled) { | 141 | if (efi_enabled) { |
@@ -1115,26 +1105,6 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) | |||
1115 | return (AE_OK); | 1105 | return (AE_OK); |
1116 | } | 1106 | } |
1117 | 1107 | ||
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 | |||
1131 | void *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 | /****************************************************************************** | 1108 | /****************************************************************************** |
1139 | * | 1109 | * |
1140 | * FUNCTION: acpi_os_validate_interface | 1110 | * 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 | */ | ||
787 | int acpi_in_resume; | ||
788 | static int irqrouter_resume(struct sys_device *dev) | 783 | static 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 | ||
81 | static struct list_head acpi_power_resource_list; | 81 | static struct list_head acpi_power_resource_list; |
82 | 82 | ||
83 | static struct file_operations acpi_power_fops = { | 83 | static 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 | ||
105 | static struct file_operations acpi_processor_info_fops = { | 105 | static 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 | ||
1073 | static struct file_operations acpi_processor_power_fops = { | 1073 | static 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/scan.c b/drivers/acpi/scan.c index cac4fcdcfc8d..5fcb50c7b778 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -663,6 +663,29 @@ static int acpi_bus_find_driver(struct acpi_device *device) | |||
663 | Device Enumeration | 663 | Device Enumeration |
664 | -------------------------------------------------------------------------- */ | 664 | -------------------------------------------------------------------------- */ |
665 | 665 | ||
666 | acpi_status | ||
667 | acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd) | ||
668 | { | ||
669 | acpi_status status; | ||
670 | acpi_handle tmp; | ||
671 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
672 | union acpi_object *obj; | ||
673 | |||
674 | status = acpi_get_handle(handle, "_EJD", &tmp); | ||
675 | if (ACPI_FAILURE(status)) | ||
676 | return status; | ||
677 | |||
678 | status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer); | ||
679 | if (ACPI_SUCCESS(status)) { | ||
680 | obj = buffer.pointer; | ||
681 | status = acpi_get_handle(NULL, obj->string.pointer, ejd); | ||
682 | kfree(buffer.pointer); | ||
683 | } | ||
684 | return status; | ||
685 | } | ||
686 | EXPORT_SYMBOL_GPL(acpi_bus_get_ejd); | ||
687 | |||
688 | |||
666 | static int acpi_bus_get_flags(struct acpi_device *device) | 689 | static int acpi_bus_get_flags(struct acpi_device *device) |
667 | { | 690 | { |
668 | acpi_status status = AE_OK; | 691 | acpi_status status = AE_OK; |
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 | ||
437 | static struct file_operations acpi_system_wakeup_device_fops = { | 437 | static 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 |
446 | static struct file_operations acpi_system_sleep_fops = { | 446 | static 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 | ||
455 | static struct file_operations acpi_system_alarm_fops = { | 455 | static 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 | ||
60 | static struct file_operations acpi_system_info_ops = { | 60 | static 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 = { | |||
67 | static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, | 67 | static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, |
68 | loff_t *); | 68 | loff_t *); |
69 | 69 | ||
70 | static struct file_operations acpi_system_dsdt_ops = { | 70 | static 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, | |||
94 | static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, | 94 | static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, |
95 | loff_t *); | 95 | loff_t *); |
96 | 96 | ||
97 | static struct file_operations acpi_system_fadt_ops = { | 97 | static 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 fdba4879603f..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 | ||
179 | static struct file_operations acpi_thermal_state_fops = { | 179 | static const struct file_operations acpi_thermal_state_fops = { |
180 | .open = acpi_thermal_state_open_fs, | 180 | .open = acpi_thermal_state_open_fs, |
181 | .read = seq_read, | 181 | .read = seq_read, |
182 | .llseek = seq_lseek, | 182 | .llseek = seq_lseek, |
183 | .release = single_release, | 183 | .release = single_release, |
184 | }; | 184 | }; |
185 | 185 | ||
186 | static struct file_operations acpi_thermal_temp_fops = { | 186 | static const struct file_operations acpi_thermal_temp_fops = { |
187 | .open = acpi_thermal_temp_open_fs, | 187 | .open = acpi_thermal_temp_open_fs, |
188 | .read = seq_read, | 188 | .read = seq_read, |
189 | .llseek = seq_lseek, | 189 | .llseek = seq_lseek, |
190 | .release = single_release, | 190 | .release = single_release, |
191 | }; | 191 | }; |
192 | 192 | ||
193 | static struct file_operations acpi_thermal_trip_fops = { | 193 | static const struct file_operations acpi_thermal_trip_fops = { |
194 | .open = acpi_thermal_trip_open_fs, | 194 | .open = acpi_thermal_trip_open_fs, |
195 | .read = seq_read, | 195 | .read = seq_read, |
196 | .write = acpi_thermal_write_trip_points, | 196 | .write = acpi_thermal_write_trip_points, |
@@ -198,7 +198,7 @@ static struct file_operations acpi_thermal_trip_fops = { | |||
198 | .release = single_release, | 198 | .release = single_release, |
199 | }; | 199 | }; |
200 | 200 | ||
201 | static struct file_operations acpi_thermal_cooling_fops = { | 201 | static const struct file_operations acpi_thermal_cooling_fops = { |
202 | .open = acpi_thermal_cooling_open_fs, | 202 | .open = acpi_thermal_cooling_open_fs, |
203 | .read = seq_read, | 203 | .read = seq_read, |
204 | .write = acpi_thermal_write_cooling_mode, | 204 | .write = acpi_thermal_write_cooling_mode, |
@@ -206,7 +206,7 @@ static struct file_operations acpi_thermal_cooling_fops = { | |||
206 | .release = single_release, | 206 | .release = single_release, |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static struct file_operations acpi_thermal_polling_fops = { | 209 | static const struct file_operations acpi_thermal_polling_fops = { |
210 | .open = acpi_thermal_polling_open_fs, | 210 | .open = acpi_thermal_polling_open_fs, |
211 | .read = seq_read, | 211 | .read = seq_read, |
212 | .write = acpi_thermal_write_polling, | 212 | .write = acpi_thermal_write_polling, |
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 @@ | |||
47 | ACPI_MODULE_NAME("utdebug") | 47 | ACPI_MODULE_NAME("utdebug") |
48 | 48 | ||
49 | #ifdef ACPI_DEBUG_OUTPUT | 49 | #ifdef ACPI_DEBUG_OUTPUT |
50 | static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; | 50 | static acpi_thread_id acpi_gbl_prev_thread_id; |
51 | static char *acpi_gbl_fn_entry_str = "----Entry"; | 51 | static char *acpi_gbl_fn_entry_str = "----Entry"; |
52 | static char *acpi_gbl_fn_exit_str = "----Exit-"; | 52 | static 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") | |||
65 | u8 acpi_ut_is_aml_table(struct acpi_table_header *table) | 65 | u8 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 | ||