aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c8
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c8
-rw-r--r--drivers/acpi/Kconfig7
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/ac.c63
-rw-r--r--drivers/acpi/acpi_memhotplug.c135
-rw-r--r--drivers/acpi/asus_acpi.c2
-rw-r--r--drivers/acpi/battery.c122
-rw-r--r--drivers/acpi/bus.c128
-rw-r--r--drivers/acpi/button.c72
-rw-r--r--drivers/acpi/container.c36
-rw-r--r--drivers/acpi/debug.c19
-rw-r--r--drivers/acpi/dispatcher/dsinit.c30
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c330
-rw-r--r--drivers/acpi/dispatcher/dswexec.c4
-rw-r--r--drivers/acpi/dispatcher/dswload.c49
-rw-r--r--drivers/acpi/dock.c739
-rw-r--r--drivers/acpi/ec.c168
-rw-r--r--drivers/acpi/event.c19
-rw-r--r--drivers/acpi/events/evgpe.c14
-rw-r--r--drivers/acpi/events/evxface.c47
-rw-r--r--drivers/acpi/executer/exconfig.c8
-rw-r--r--drivers/acpi/executer/excreate.c27
-rw-r--r--drivers/acpi/executer/exdump.c8
-rw-r--r--drivers/acpi/executer/exfldio.c71
-rw-r--r--drivers/acpi/executer/exmutex.c12
-rw-r--r--drivers/acpi/executer/exsystem.c82
-rw-r--r--drivers/acpi/fan.c51
-rw-r--r--drivers/acpi/hardware/hwregs.c77
-rw-r--r--drivers/acpi/hotkey.c132
-rw-r--r--drivers/acpi/motherboard.c5
-rw-r--r--drivers/acpi/namespace/nsaccess.c27
-rw-r--r--drivers/acpi/osl.c72
-rw-r--r--drivers/acpi/parser/psparse.c18
-rw-r--r--drivers/acpi/pci_bind.c87
-rw-r--r--drivers/acpi/pci_irq.c91
-rw-r--r--drivers/acpi/pci_link.c189
-rw-r--r--drivers/acpi/pci_root.c39
-rw-r--r--drivers/acpi/power.c145
-rw-r--r--drivers/acpi/processor_core.c161
-rw-r--r--drivers/acpi/processor_idle.c129
-rw-r--r--drivers/acpi/processor_perflib.c132
-rw-r--r--drivers/acpi/processor_thermal.c48
-rw-r--r--drivers/acpi/processor_throttling.c45
-rw-r--r--drivers/acpi/scan.c107
-rw-r--r--drivers/acpi/system.c21
-rw-r--r--drivers/acpi/thermal.c218
-rw-r--r--drivers/acpi/utilities/utdelete.c36
-rw-r--r--drivers/acpi/utilities/utglobal.c1
-rw-r--r--drivers/acpi/utilities/utmisc.c3
-rw-r--r--drivers/acpi/utilities/utmutex.c39
-rw-r--r--drivers/acpi/utils.c104
-rw-r--r--drivers/acpi/video.c270
-rw-r--r--drivers/pci/hotplug/Makefile3
-rw-r--r--drivers/pci/hotplug/acpiphp.h36
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c19
-rw-r--r--drivers/pci/hotplug/acpiphp_dock.c438
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c123
-rw-r--r--include/acpi/acconfig.h2
-rw-r--r--include/acpi/acdispat.h2
-rw-r--r--include/acpi/acglobal.h26
-rw-r--r--include/acpi/acinterp.h5
-rw-r--r--include/acpi/aclocal.h36
-rw-r--r--include/acpi/acmacros.h2
-rw-r--r--include/acpi/acobject.h8
-rw-r--r--include/acpi/acpi_bus.h2
-rw-r--r--include/acpi/acpi_drivers.h17
-rw-r--r--include/acpi/acpiosxf.h40
-rw-r--r--include/acpi/actypes.h49
-rw-r--r--include/acpi/platform/aclinux.h2
-rw-r--r--include/acpi/processor.h1
-rw-r--r--include/linux/cpufreq.h6
-rw-r--r--include/linux/kobject.h2
-rw-r--r--lib/kobject_uevent.c4
74 files changed, 2637 insertions, 2642 deletions
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 5fd65325b81a..cf0ddc9ee0cd 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -418,8 +418,14 @@ acpi_cpufreq_cpu_init (
418 goto err_free; 418 goto err_free;
419 419
420 perf = data->acpi_data; 420 perf = data->acpi_data;
421 policy->cpus = perf->shared_cpu_map;
422 policy->shared_type = perf->shared_type; 421 policy->shared_type = perf->shared_type;
422 /*
423 * Will let policy->cpus know about dependency only when software
424 * coordination is required.
425 */
426 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
427 policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
428 policy->cpus = perf->shared_cpu_map;
423 429
424 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { 430 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
425 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS; 431 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index f7e4356f6820..8d765509ef59 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -399,8 +399,14 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
399 dprintk(PFX "obtaining ACPI data failed\n"); 399 dprintk(PFX "obtaining ACPI data failed\n");
400 return -EIO; 400 return -EIO;
401 } 401 }
402 policy->cpus = p->shared_cpu_map;
403 policy->shared_type = p->shared_type; 402 policy->shared_type = p->shared_type;
403 /*
404 * Will let policy->cpus know about dependency only when software
405 * coordination is required.
406 */
407 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
408 policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
409 policy->cpus = p->shared_cpu_map;
404 410
405 /* verify the acpi_data */ 411 /* verify the acpi_data */
406 if (p->state_count <= 1) { 412 if (p->state_count <= 1) {
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 610d2cc02cf8..bc2652d72fdc 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -133,6 +133,13 @@ config ACPI_FAN
133 This driver adds support for ACPI fan devices, allowing user-mode 133 This driver adds support for ACPI fan devices, allowing user-mode
134 applications to perform basic fan control (on, off, status). 134 applications to perform basic fan control (on, off, status).
135 135
136config ACPI_DOCK
137 tristate "Dock"
138 depends on !ACPI_IBM_DOCK
139 default y
140 help
141 This driver adds support for ACPI controlled docking stations
142
136config ACPI_PROCESSOR 143config ACPI_PROCESSOR
137 tristate "Processor" 144 tristate "Processor"
138 default y 145 default y
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 5984b4f6715a..f0a68ecf1e57 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_ACPI_BATTERY) += battery.o
42obj-$(CONFIG_ACPI_BUTTON) += button.o 42obj-$(CONFIG_ACPI_BUTTON) += button.o
43obj-$(CONFIG_ACPI_EC) += ec.o 43obj-$(CONFIG_ACPI_EC) += ec.o
44obj-$(CONFIG_ACPI_FAN) += fan.o 44obj-$(CONFIG_ACPI_FAN) += fan.o
45obj-$(CONFIG_ACPI_DOCK) += dock.o
45obj-$(CONFIG_ACPI_VIDEO) += video.o 46obj-$(CONFIG_ACPI_VIDEO) += video.o
46obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o 47obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o
47obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 48obj-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 7839b831df94..36ca365bcead 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -84,20 +84,18 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
84{ 84{
85 acpi_status status = AE_OK; 85 acpi_status status = AE_OK;
86 86
87 ACPI_FUNCTION_TRACE("acpi_ac_get_state");
88 87
89 if (!ac) 88 if (!ac)
90 return_VALUE(-EINVAL); 89 return -EINVAL;
91 90
92 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); 91 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
93 if (ACPI_FAILURE(status)) { 92 if (ACPI_FAILURE(status)) {
94 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 93 ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state"));
95 "Error reading AC Adapter state\n"));
96 ac->state = ACPI_AC_STATUS_UNKNOWN; 94 ac->state = ACPI_AC_STATUS_UNKNOWN;
97 return_VALUE(-ENODEV); 95 return -ENODEV;
98 } 96 }
99 97
100 return_VALUE(0); 98 return 0;
101} 99}
102 100
103/* -------------------------------------------------------------------------- 101/* --------------------------------------------------------------------------
@@ -110,14 +108,13 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
110{ 108{
111 struct acpi_ac *ac = (struct acpi_ac *)seq->private; 109 struct acpi_ac *ac = (struct acpi_ac *)seq->private;
112 110
113 ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
114 111
115 if (!ac) 112 if (!ac)
116 return_VALUE(0); 113 return 0;
117 114
118 if (acpi_ac_get_state(ac)) { 115 if (acpi_ac_get_state(ac)) {
119 seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); 116 seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
120 return_VALUE(0); 117 return 0;
121 } 118 }
122 119
123 seq_puts(seq, "state: "); 120 seq_puts(seq, "state: ");
@@ -133,7 +130,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
133 break; 130 break;
134 } 131 }
135 132
136 return_VALUE(0); 133 return 0;
137} 134}
138 135
139static int acpi_ac_open_fs(struct inode *inode, struct file *file) 136static int acpi_ac_open_fs(struct inode *inode, struct file *file)
@@ -145,13 +142,12 @@ static int acpi_ac_add_fs(struct acpi_device *device)
145{ 142{
146 struct proc_dir_entry *entry = NULL; 143 struct proc_dir_entry *entry = NULL;
147 144
148 ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
149 145
150 if (!acpi_device_dir(device)) { 146 if (!acpi_device_dir(device)) {
151 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 147 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
152 acpi_ac_dir); 148 acpi_ac_dir);
153 if (!acpi_device_dir(device)) 149 if (!acpi_device_dir(device))
154 return_VALUE(-ENODEV); 150 return -ENODEV;
155 acpi_device_dir(device)->owner = THIS_MODULE; 151 acpi_device_dir(device)->owner = THIS_MODULE;
156 } 152 }
157 153
@@ -159,21 +155,18 @@ static int acpi_ac_add_fs(struct acpi_device *device)
159 entry = create_proc_entry(ACPI_AC_FILE_STATE, 155 entry = create_proc_entry(ACPI_AC_FILE_STATE,
160 S_IRUGO, acpi_device_dir(device)); 156 S_IRUGO, acpi_device_dir(device));
161 if (!entry) 157 if (!entry)
162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 158 return -ENODEV;
163 "Unable to create '%s' fs entry\n",
164 ACPI_AC_FILE_STATE));
165 else { 159 else {
166 entry->proc_fops = &acpi_ac_fops; 160 entry->proc_fops = &acpi_ac_fops;
167 entry->data = acpi_driver_data(device); 161 entry->data = acpi_driver_data(device);
168 entry->owner = THIS_MODULE; 162 entry->owner = THIS_MODULE;
169 } 163 }
170 164
171 return_VALUE(0); 165 return 0;
172} 166}
173 167
174static int acpi_ac_remove_fs(struct acpi_device *device) 168static int acpi_ac_remove_fs(struct acpi_device *device)
175{ 169{
176 ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
177 170
178 if (acpi_device_dir(device)) { 171 if (acpi_device_dir(device)) {
179 remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device)); 172 remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device));
@@ -182,7 +175,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
182 acpi_device_dir(device) = NULL; 175 acpi_device_dir(device) = NULL;
183 } 176 }
184 177
185 return_VALUE(0); 178 return 0;
186} 179}
187 180
188/* -------------------------------------------------------------------------- 181/* --------------------------------------------------------------------------
@@ -194,13 +187,12 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
194 struct acpi_ac *ac = (struct acpi_ac *)data; 187 struct acpi_ac *ac = (struct acpi_ac *)data;
195 struct acpi_device *device = NULL; 188 struct acpi_device *device = NULL;
196 189
197 ACPI_FUNCTION_TRACE("acpi_ac_notify");
198 190
199 if (!ac) 191 if (!ac)
200 return_VOID; 192 return;
201 193
202 if (acpi_bus_get_device(ac->handle, &device)) 194 if (acpi_bus_get_device(ac->handle, &device))
203 return_VOID; 195 return;
204 196
205 switch (event) { 197 switch (event) {
206 case ACPI_AC_NOTIFY_STATUS: 198 case ACPI_AC_NOTIFY_STATUS:
@@ -213,7 +205,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
213 break; 205 break;
214 } 206 }
215 207
216 return_VOID; 208 return;
217} 209}
218 210
219static int acpi_ac_add(struct acpi_device *device) 211static int acpi_ac_add(struct acpi_device *device)
@@ -222,14 +214,13 @@ static int acpi_ac_add(struct acpi_device *device)
222 acpi_status status = AE_OK; 214 acpi_status status = AE_OK;
223 struct acpi_ac *ac = NULL; 215 struct acpi_ac *ac = NULL;
224 216
225 ACPI_FUNCTION_TRACE("acpi_ac_add");
226 217
227 if (!device) 218 if (!device)
228 return_VALUE(-EINVAL); 219 return -EINVAL;
229 220
230 ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); 221 ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL);
231 if (!ac) 222 if (!ac)
232 return_VALUE(-ENOMEM); 223 return -ENOMEM;
233 memset(ac, 0, sizeof(struct acpi_ac)); 224 memset(ac, 0, sizeof(struct acpi_ac));
234 225
235 ac->handle = device->handle; 226 ac->handle = device->handle;
@@ -249,8 +240,6 @@ static int acpi_ac_add(struct acpi_device *device)
249 ACPI_DEVICE_NOTIFY, acpi_ac_notify, 240 ACPI_DEVICE_NOTIFY, acpi_ac_notify,
250 ac); 241 ac);
251 if (ACPI_FAILURE(status)) { 242 if (ACPI_FAILURE(status)) {
252 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
253 "Error installing notify handler\n"));
254 result = -ENODEV; 243 result = -ENODEV;
255 goto end; 244 goto end;
256 } 245 }
@@ -265,7 +254,7 @@ static int acpi_ac_add(struct acpi_device *device)
265 kfree(ac); 254 kfree(ac);
266 } 255 }
267 256
268 return_VALUE(result); 257 return result;
269} 258}
270 259
271static int acpi_ac_remove(struct acpi_device *device, int type) 260static int acpi_ac_remove(struct acpi_device *device, int type)
@@ -273,55 +262,49 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
273 acpi_status status = AE_OK; 262 acpi_status status = AE_OK;
274 struct acpi_ac *ac = NULL; 263 struct acpi_ac *ac = NULL;
275 264
276 ACPI_FUNCTION_TRACE("acpi_ac_remove");
277 265
278 if (!device || !acpi_driver_data(device)) 266 if (!device || !acpi_driver_data(device))
279 return_VALUE(-EINVAL); 267 return -EINVAL;
280 268
281 ac = (struct acpi_ac *)acpi_driver_data(device); 269 ac = (struct acpi_ac *)acpi_driver_data(device);
282 270
283 status = acpi_remove_notify_handler(ac->handle, 271 status = acpi_remove_notify_handler(ac->handle,
284 ACPI_DEVICE_NOTIFY, acpi_ac_notify); 272 ACPI_DEVICE_NOTIFY, acpi_ac_notify);
285 if (ACPI_FAILURE(status))
286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
287 "Error removing notify handler\n"));
288 273
289 acpi_ac_remove_fs(device); 274 acpi_ac_remove_fs(device);
290 275
291 kfree(ac); 276 kfree(ac);
292 277
293 return_VALUE(0); 278 return 0;
294} 279}
295 280
296static int __init acpi_ac_init(void) 281static int __init acpi_ac_init(void)
297{ 282{
298 int result = 0; 283 int result = 0;
299 284
300 ACPI_FUNCTION_TRACE("acpi_ac_init");
301 285
302 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); 286 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
303 if (!acpi_ac_dir) 287 if (!acpi_ac_dir)
304 return_VALUE(-ENODEV); 288 return -ENODEV;
305 acpi_ac_dir->owner = THIS_MODULE; 289 acpi_ac_dir->owner = THIS_MODULE;
306 290
307 result = acpi_bus_register_driver(&acpi_ac_driver); 291 result = acpi_bus_register_driver(&acpi_ac_driver);
308 if (result < 0) { 292 if (result < 0) {
309 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 293 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
310 return_VALUE(-ENODEV); 294 return -ENODEV;
311 } 295 }
312 296
313 return_VALUE(0); 297 return 0;
314} 298}
315 299
316static void __exit acpi_ac_exit(void) 300static void __exit acpi_ac_exit(void)
317{ 301{
318 ACPI_FUNCTION_TRACE("acpi_ac_exit");
319 302
320 acpi_bus_unregister_driver(&acpi_ac_driver); 303 acpi_bus_unregister_driver(&acpi_ac_driver);
321 304
322 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 305 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
323 306
324 return_VOID; 307 return;
325} 308}
326 309
327module_init(acpi_ac_init); 310module_init(acpi_ac_init);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 1012284ff4f7..6f5e395c78af 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -128,7 +128,6 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
128 acpi_status status; 128 acpi_status status;
129 struct acpi_memory_info *info, *n; 129 struct acpi_memory_info *info, *n;
130 130
131 ACPI_FUNCTION_TRACE("acpi_memory_get_device_resources");
132 131
133 status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS, 132 status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS,
134 acpi_memory_get_resource, mem_device); 133 acpi_memory_get_resource, mem_device);
@@ -150,23 +149,21 @@ acpi_memory_get_device(acpi_handle handle,
150 struct acpi_device *device = NULL; 149 struct acpi_device *device = NULL;
151 struct acpi_device *pdevice = NULL; 150 struct acpi_device *pdevice = NULL;
152 151
153 ACPI_FUNCTION_TRACE("acpi_memory_get_device");
154 152
155 if (!acpi_bus_get_device(handle, &device) && device) 153 if (!acpi_bus_get_device(handle, &device) && device)
156 goto end; 154 goto end;
157 155
158 status = acpi_get_parent(handle, &phandle); 156 status = acpi_get_parent(handle, &phandle);
159 if (ACPI_FAILURE(status)) { 157 if (ACPI_FAILURE(status)) {
160 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n")); 158 ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent"));
161 return_VALUE(-EINVAL); 159 return -EINVAL;
162 } 160 }
163 161
164 /* Get the parent device */ 162 /* Get the parent device */
165 status = acpi_bus_get_device(phandle, &pdevice); 163 status = acpi_bus_get_device(phandle, &pdevice);
166 if (ACPI_FAILURE(status)) { 164 if (ACPI_FAILURE(status)) {
167 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 165 ACPI_EXCEPTION((AE_INFO, status, "Cannot get acpi bus device"));
168 "Error in acpi_bus_get_device\n")); 166 return -EINVAL;
169 return_VALUE(-EINVAL);
170 } 167 }
171 168
172 /* 169 /*
@@ -175,30 +172,29 @@ acpi_memory_get_device(acpi_handle handle,
175 */ 172 */
176 status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 173 status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
177 if (ACPI_FAILURE(status)) { 174 if (ACPI_FAILURE(status)) {
178 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n")); 175 ACPI_EXCEPTION((AE_INFO, status, "Cannot add acpi bus"));
179 return_VALUE(-EINVAL); 176 return -EINVAL;
180 } 177 }
181 178
182 end: 179 end:
183 *mem_device = acpi_driver_data(device); 180 *mem_device = acpi_driver_data(device);
184 if (!(*mem_device)) { 181 if (!(*mem_device)) {
185 printk(KERN_ERR "\n driver data not found"); 182 printk(KERN_ERR "\n driver data not found");
186 return_VALUE(-ENODEV); 183 return -ENODEV;
187 } 184 }
188 185
189 return_VALUE(0); 186 return 0;
190} 187}
191 188
192static int acpi_memory_check_device(struct acpi_memory_device *mem_device) 189static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
193{ 190{
194 unsigned long current_status; 191 unsigned long current_status;
195 192
196 ACPI_FUNCTION_TRACE("acpi_memory_check_device");
197 193
198 /* Get device present/absent information from the _STA */ 194 /* Get device present/absent information from the _STA */
199 if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA", 195 if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA",
200 NULL, &current_status))) 196 NULL, &current_status)))
201 return_VALUE(-ENODEV); 197 return -ENODEV;
202 /* 198 /*
203 * Check for device status. Device should be 199 * Check for device status. Device should be
204 * present/enabled/functioning. 200 * present/enabled/functioning.
@@ -206,9 +202,9 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
206 if (!((current_status & ACPI_MEMORY_STA_PRESENT) 202 if (!((current_status & ACPI_MEMORY_STA_PRESENT)
207 && (current_status & ACPI_MEMORY_STA_ENABLED) 203 && (current_status & ACPI_MEMORY_STA_ENABLED)
208 && (current_status & ACPI_MEMORY_STA_FUNCTIONAL))) 204 && (current_status & ACPI_MEMORY_STA_FUNCTIONAL)))
209 return_VALUE(-ENODEV); 205 return -ENODEV;
210 206
211 return_VALUE(0); 207 return 0;
212} 208}
213 209
214static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) 210static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
@@ -217,13 +213,11 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
217 struct acpi_memory_info *info; 213 struct acpi_memory_info *info;
218 int node; 214 int node;
219 215
220 ACPI_FUNCTION_TRACE("acpi_memory_enable_device");
221 216
222 /* Get the range from the _CRS */ 217 /* Get the range from the _CRS */
223 result = acpi_memory_get_device_resources(mem_device); 218 result = acpi_memory_get_device_resources(mem_device);
224 if (result) { 219 if (result) {
225 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 220 printk(KERN_ERR PREFIX "get_device_resources failed\n");
226 "\nget_device_resources failed\n"));
227 mem_device->state = MEMORY_INVALID_STATE; 221 mem_device->state = MEMORY_INVALID_STATE;
228 return result; 222 return result;
229 } 223 }
@@ -269,7 +263,6 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
269 union acpi_object arg; 263 union acpi_object arg;
270 unsigned long current_status; 264 unsigned long current_status;
271 265
272 ACPI_FUNCTION_TRACE("acpi_memory_powerdown_device");
273 266
274 /* Issue the _EJ0 command */ 267 /* Issue the _EJ0 command */
275 arg_list.count = 1; 268 arg_list.count = 1;
@@ -280,21 +273,21 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
280 "_EJ0", &arg_list, NULL); 273 "_EJ0", &arg_list, NULL);
281 /* Return on _EJ0 failure */ 274 /* Return on _EJ0 failure */
282 if (ACPI_FAILURE(status)) { 275 if (ACPI_FAILURE(status)) {
283 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n")); 276 ACPI_EXCEPTION((AE_INFO, status, "_EJ0 failed"));
284 return_VALUE(-ENODEV); 277 return -ENODEV;
285 } 278 }
286 279
287 /* Evalute _STA to check if the device is disabled */ 280 /* Evalute _STA to check if the device is disabled */
288 status = acpi_evaluate_integer(mem_device->handle, "_STA", 281 status = acpi_evaluate_integer(mem_device->handle, "_STA",
289 NULL, &current_status); 282 NULL, &current_status);
290 if (ACPI_FAILURE(status)) 283 if (ACPI_FAILURE(status))
291 return_VALUE(-ENODEV); 284 return -ENODEV;
292 285
293 /* Check for device status. Device should be disabled */ 286 /* Check for device status. Device should be disabled */
294 if (current_status & ACPI_MEMORY_STA_ENABLED) 287 if (current_status & ACPI_MEMORY_STA_ENABLED)
295 return_VALUE(-EINVAL); 288 return -EINVAL;
296 289
297 return_VALUE(0); 290 return 0;
298} 291}
299 292
300static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) 293static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
@@ -302,7 +295,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
302 int result; 295 int result;
303 struct acpi_memory_info *info, *n; 296 struct acpi_memory_info *info, *n;
304 297
305 ACPI_FUNCTION_TRACE("acpi_memory_disable_device");
306 298
307 /* 299 /*
308 * Ask the VM to offline this memory range. 300 * Ask the VM to offline this memory range.
@@ -320,8 +312,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
320 /* Power-off and eject the device */ 312 /* Power-off and eject the device */
321 result = acpi_memory_powerdown_device(mem_device); 313 result = acpi_memory_powerdown_device(mem_device);
322 if (result) { 314 if (result) {
323 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
324 "Device Power Down failed.\n"));
325 /* Set the status of the device to invalid */ 315 /* Set the status of the device to invalid */
326 mem_device->state = MEMORY_INVALID_STATE; 316 mem_device->state = MEMORY_INVALID_STATE;
327 return result; 317 return result;
@@ -336,7 +326,6 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
336 struct acpi_memory_device *mem_device; 326 struct acpi_memory_device *mem_device;
337 struct acpi_device *device; 327 struct acpi_device *device;
338 328
339 ACPI_FUNCTION_TRACE("acpi_memory_device_notify");
340 329
341 switch (event) { 330 switch (event) {
342 case ACPI_NOTIFY_BUS_CHECK: 331 case ACPI_NOTIFY_BUS_CHECK:
@@ -348,15 +337,14 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
348 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 337 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
349 "\nReceived DEVICE CHECK notification for device\n")); 338 "\nReceived DEVICE CHECK notification for device\n"));
350 if (acpi_memory_get_device(handle, &mem_device)) { 339 if (acpi_memory_get_device(handle, &mem_device)) {
351 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 340 printk(KERN_ERR PREFIX "Cannot find driver data\n");
352 "Error in finding driver data\n")); 341 return;
353 return_VOID;
354 } 342 }
355 343
356 if (!acpi_memory_check_device(mem_device)) { 344 if (!acpi_memory_check_device(mem_device)) {
357 if (acpi_memory_enable_device(mem_device)) 345 if (acpi_memory_enable_device(mem_device))
358 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 346 printk(KERN_ERR PREFIX
359 "Error in acpi_memory_enable_device\n")); 347 "Cannot enable memory device\n");
360 } 348 }
361 break; 349 break;
362 case ACPI_NOTIFY_EJECT_REQUEST: 350 case ACPI_NOTIFY_EJECT_REQUEST:
@@ -364,14 +352,12 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
364 "\nReceived EJECT REQUEST notification for device\n")); 352 "\nReceived EJECT REQUEST notification for device\n"));
365 353
366 if (acpi_bus_get_device(handle, &device)) { 354 if (acpi_bus_get_device(handle, &device)) {
367 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 355 printk(KERN_ERR PREFIX "Device doesn't exist\n");
368 "Device doesn't exist\n"));
369 break; 356 break;
370 } 357 }
371 mem_device = acpi_driver_data(device); 358 mem_device = acpi_driver_data(device);
372 if (!mem_device) { 359 if (!mem_device) {
373 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 360 printk(KERN_ERR PREFIX "Driver Data is NULL\n");
374 "Driver Data is NULL\n"));
375 break; 361 break;
376 } 362 }
377 363
@@ -382,8 +368,8 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
382 * with generic sysfs driver 368 * with generic sysfs driver
383 */ 369 */
384 if (acpi_memory_disable_device(mem_device)) 370 if (acpi_memory_disable_device(mem_device))
385 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 371 printk(KERN_ERR PREFIX
386 "Error in acpi_memory_disable_device\n")); 372 "Disable memory device\n");
387 /* 373 /*
388 * TBD: Invoke acpi_bus_remove to cleanup data structures 374 * TBD: Invoke acpi_bus_remove to cleanup data structures
389 */ 375 */
@@ -394,7 +380,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
394 break; 380 break;
395 } 381 }
396 382
397 return_VOID; 383 return;
398} 384}
399 385
400static int acpi_memory_device_add(struct acpi_device *device) 386static int acpi_memory_device_add(struct acpi_device *device)
@@ -402,14 +388,13 @@ static int acpi_memory_device_add(struct acpi_device *device)
402 int result; 388 int result;
403 struct acpi_memory_device *mem_device = NULL; 389 struct acpi_memory_device *mem_device = NULL;
404 390
405 ACPI_FUNCTION_TRACE("acpi_memory_device_add");
406 391
407 if (!device) 392 if (!device)
408 return_VALUE(-EINVAL); 393 return -EINVAL;
409 394
410 mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); 395 mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
411 if (!mem_device) 396 if (!mem_device)
412 return_VALUE(-ENOMEM); 397 return -ENOMEM;
413 memset(mem_device, 0, sizeof(struct acpi_memory_device)); 398 memset(mem_device, 0, sizeof(struct acpi_memory_device));
414 399
415 INIT_LIST_HEAD(&mem_device->res_list); 400 INIT_LIST_HEAD(&mem_device->res_list);
@@ -422,7 +407,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
422 result = acpi_memory_get_device_resources(mem_device); 407 result = acpi_memory_get_device_resources(mem_device);
423 if (result) { 408 if (result) {
424 kfree(mem_device); 409 kfree(mem_device);
425 return_VALUE(result); 410 return result;
426 } 411 }
427 412
428 /* Set the device state */ 413 /* Set the device state */
@@ -430,22 +415,21 @@ static int acpi_memory_device_add(struct acpi_device *device)
430 415
431 printk(KERN_INFO "%s \n", acpi_device_name(device)); 416 printk(KERN_INFO "%s \n", acpi_device_name(device));
432 417
433 return_VALUE(result); 418 return result;
434} 419}
435 420
436static int acpi_memory_device_remove(struct acpi_device *device, int type) 421static int acpi_memory_device_remove(struct acpi_device *device, int type)
437{ 422{
438 struct acpi_memory_device *mem_device = NULL; 423 struct acpi_memory_device *mem_device = NULL;
439 424
440 ACPI_FUNCTION_TRACE("acpi_memory_device_remove");
441 425
442 if (!device || !acpi_driver_data(device)) 426 if (!device || !acpi_driver_data(device))
443 return_VALUE(-EINVAL); 427 return -EINVAL;
444 428
445 mem_device = (struct acpi_memory_device *)acpi_driver_data(device); 429 mem_device = (struct acpi_memory_device *)acpi_driver_data(device);
446 kfree(mem_device); 430 kfree(mem_device);
447 431
448 return_VALUE(0); 432 return 0;
449} 433}
450 434
451static int acpi_memory_device_start (struct acpi_device *device) 435static int acpi_memory_device_start (struct acpi_device *device)
@@ -453,8 +437,6 @@ static int acpi_memory_device_start (struct acpi_device *device)
453 struct acpi_memory_device *mem_device; 437 struct acpi_memory_device *mem_device;
454 int result = 0; 438 int result = 0;
455 439
456 ACPI_FUNCTION_TRACE("acpi_memory_device_start");
457
458 mem_device = acpi_driver_data(device); 440 mem_device = acpi_driver_data(device);
459 441
460 if (!acpi_memory_check_device(mem_device)) { 442 if (!acpi_memory_check_device(mem_device)) {
@@ -464,7 +446,7 @@ static int acpi_memory_device_start (struct acpi_device *device)
464 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 446 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
465 "Error in acpi_memory_enable_device\n")); 447 "Error in acpi_memory_enable_device\n"));
466 } 448 }
467 return_VALUE(result); 449 return result;
468} 450}
469 451
470/* 452/*
@@ -477,16 +459,15 @@ static acpi_status is_memory_device(acpi_handle handle)
477 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 459 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
478 struct acpi_device_info *info; 460 struct acpi_device_info *info;
479 461
480 ACPI_FUNCTION_TRACE("is_memory_device");
481 462
482 status = acpi_get_object_info(handle, &buffer); 463 status = acpi_get_object_info(handle, &buffer);
483 if (ACPI_FAILURE(status)) 464 if (ACPI_FAILURE(status))
484 return_ACPI_STATUS(AE_ERROR); 465 return status;
485 466
486 info = buffer.pointer; 467 info = buffer.pointer;
487 if (!(info->valid & ACPI_VALID_HID)) { 468 if (!(info->valid & ACPI_VALID_HID)) {
488 acpi_os_free(buffer.pointer); 469 acpi_os_free(buffer.pointer);
489 return_ACPI_STATUS(AE_ERROR); 470 return AE_ERROR;
490 } 471 }
491 472
492 hardware_id = info->hardware_id.value; 473 hardware_id = info->hardware_id.value;
@@ -495,7 +476,7 @@ static acpi_status is_memory_device(acpi_handle handle)
495 status = AE_ERROR; 476 status = AE_ERROR;
496 477
497 acpi_os_free(buffer.pointer); 478 acpi_os_free(buffer.pointer);
498 return_ACPI_STATUS(status); 479 return status;
499} 480}
500 481
501static acpi_status 482static acpi_status
@@ -504,21 +485,17 @@ acpi_memory_register_notify_handler(acpi_handle handle,
504{ 485{
505 acpi_status status; 486 acpi_status status;
506 487
507 ACPI_FUNCTION_TRACE("acpi_memory_register_notify_handler");
508 488
509 status = is_memory_device(handle); 489 status = is_memory_device(handle);
510 if (ACPI_FAILURE(status)) 490 if (ACPI_FAILURE(status)){
511 return_ACPI_STATUS(AE_OK); /* continue */ 491 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
492 return AE_OK; /* continue */
493 }
512 494
513 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 495 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
514 acpi_memory_device_notify, NULL); 496 acpi_memory_device_notify, NULL);
515 if (ACPI_FAILURE(status)) { 497 /* continue */
516 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 498 return AE_OK;
517 "Error installing notify handler\n"));
518 return_ACPI_STATUS(AE_OK); /* continue */
519 }
520
521 return_ACPI_STATUS(status);
522} 499}
523 500
524static acpi_status 501static acpi_status
@@ -527,22 +504,18 @@ acpi_memory_deregister_notify_handler(acpi_handle handle,
527{ 504{
528 acpi_status status; 505 acpi_status status;
529 506
530 ACPI_FUNCTION_TRACE("acpi_memory_deregister_notify_handler");
531 507
532 status = is_memory_device(handle); 508 status = is_memory_device(handle);
533 if (ACPI_FAILURE(status)) 509 if (ACPI_FAILURE(status)){
534 return_ACPI_STATUS(AE_OK); /* continue */ 510 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
511 return AE_OK; /* continue */
512 }
535 513
536 status = acpi_remove_notify_handler(handle, 514 status = acpi_remove_notify_handler(handle,
537 ACPI_SYSTEM_NOTIFY, 515 ACPI_SYSTEM_NOTIFY,
538 acpi_memory_device_notify); 516 acpi_memory_device_notify);
539 if (ACPI_FAILURE(status)) {
540 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
541 "Error removing notify handler\n"));
542 return_ACPI_STATUS(AE_OK); /* continue */
543 }
544 517
545 return_ACPI_STATUS(status); 518 return AE_OK; /* continue */
546} 519}
547 520
548static int __init acpi_memory_device_init(void) 521static int __init acpi_memory_device_init(void)
@@ -550,12 +523,11 @@ static int __init acpi_memory_device_init(void)
550 int result; 523 int result;
551 acpi_status status; 524 acpi_status status;
552 525
553 ACPI_FUNCTION_TRACE("acpi_memory_device_init");
554 526
555 result = acpi_bus_register_driver(&acpi_memory_device_driver); 527 result = acpi_bus_register_driver(&acpi_memory_device_driver);
556 528
557 if (result < 0) 529 if (result < 0)
558 return_VALUE(-ENODEV); 530 return -ENODEV;
559 531
560 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 532 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
561 ACPI_UINT32_MAX, 533 ACPI_UINT32_MAX,
@@ -563,19 +535,18 @@ static int __init acpi_memory_device_init(void)
563 NULL, NULL); 535 NULL, NULL);
564 536
565 if (ACPI_FAILURE(status)) { 537 if (ACPI_FAILURE(status)) {
566 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); 538 ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed"));
567 acpi_bus_unregister_driver(&acpi_memory_device_driver); 539 acpi_bus_unregister_driver(&acpi_memory_device_driver);
568 return_VALUE(-ENODEV); 540 return -ENODEV;
569 } 541 }
570 542
571 return_VALUE(0); 543 return 0;
572} 544}
573 545
574static void __exit acpi_memory_device_exit(void) 546static void __exit acpi_memory_device_exit(void)
575{ 547{
576 acpi_status status; 548 acpi_status status;
577 549
578 ACPI_FUNCTION_TRACE("acpi_memory_device_exit");
579 550
580 /* 551 /*
581 * Adding this to un-install notification handlers for all the device 552 * Adding this to un-install notification handlers for all the device
@@ -587,11 +558,11 @@ static void __exit acpi_memory_device_exit(void)
587 NULL, NULL); 558 NULL, NULL);
588 559
589 if (ACPI_FAILURE(status)) 560 if (ACPI_FAILURE(status))
590 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); 561 ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed"));
591 562
592 acpi_bus_unregister_driver(&acpi_memory_device_driver); 563 acpi_bus_unregister_driver(&acpi_memory_device_driver);
593 564
594 return_VOID; 565 return;
595} 566}
596 567
597module_init(acpi_memory_device_init); 568module_init(acpi_memory_device_init);
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index 839f423d738d..055cfd5c8766 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -1232,7 +1232,7 @@ static int __init asus_acpi_init(void)
1232 result = acpi_bus_register_driver(&asus_hotk_driver); 1232 result = acpi_bus_register_driver(&asus_hotk_driver);
1233 if (result < 0) { 1233 if (result < 0) {
1234 remove_proc_entry(PROC_ASUS, acpi_root_dir); 1234 remove_proc_entry(PROC_ASUS, acpi_root_dir);
1235 return -ENODEV; 1235 return result;
1236 } 1236 }
1237 1237
1238 /* 1238 /*
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 702e857e98c5..00b0728efe82 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -132,17 +132,16 @@ acpi_battery_get_info(struct acpi_battery *battery,
132 struct acpi_buffer data = { 0, NULL }; 132 struct acpi_buffer data = { 0, NULL };
133 union acpi_object *package = NULL; 133 union acpi_object *package = NULL;
134 134
135 ACPI_FUNCTION_TRACE("acpi_battery_get_info");
136 135
137 if (!battery || !bif) 136 if (!battery || !bif)
138 return_VALUE(-EINVAL); 137 return -EINVAL;
139 138
140 /* Evalute _BIF */ 139 /* Evalute _BIF */
141 140
142 status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); 141 status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer);
143 if (ACPI_FAILURE(status)) { 142 if (ACPI_FAILURE(status)) {
144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n")); 143 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
145 return_VALUE(-ENODEV); 144 return -ENODEV;
146 } 145 }
147 146
148 package = (union acpi_object *)buffer.pointer; 147 package = (union acpi_object *)buffer.pointer;
@@ -151,7 +150,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
151 150
152 status = acpi_extract_package(package, &format, &data); 151 status = acpi_extract_package(package, &format, &data);
153 if (status != AE_BUFFER_OVERFLOW) { 152 if (status != AE_BUFFER_OVERFLOW) {
154 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); 153 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
155 result = -ENODEV; 154 result = -ENODEV;
156 goto end; 155 goto end;
157 } 156 }
@@ -165,7 +164,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
165 164
166 status = acpi_extract_package(package, &format, &data); 165 status = acpi_extract_package(package, &format, &data);
167 if (ACPI_FAILURE(status)) { 166 if (ACPI_FAILURE(status)) {
168 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); 167 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
169 kfree(data.pointer); 168 kfree(data.pointer);
170 result = -ENODEV; 169 result = -ENODEV;
171 goto end; 170 goto end;
@@ -177,7 +176,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
177 if (!result) 176 if (!result)
178 (*bif) = (struct acpi_battery_info *)data.pointer; 177 (*bif) = (struct acpi_battery_info *)data.pointer;
179 178
180 return_VALUE(result); 179 return result;
181} 180}
182 181
183static int 182static int
@@ -193,17 +192,16 @@ acpi_battery_get_status(struct acpi_battery *battery,
193 struct acpi_buffer data = { 0, NULL }; 192 struct acpi_buffer data = { 0, NULL };
194 union acpi_object *package = NULL; 193 union acpi_object *package = NULL;
195 194
196 ACPI_FUNCTION_TRACE("acpi_battery_get_status");
197 195
198 if (!battery || !bst) 196 if (!battery || !bst)
199 return_VALUE(-EINVAL); 197 return -EINVAL;
200 198
201 /* Evalute _BST */ 199 /* Evalute _BST */
202 200
203 status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); 201 status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer);
204 if (ACPI_FAILURE(status)) { 202 if (ACPI_FAILURE(status)) {
205 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n")); 203 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
206 return_VALUE(-ENODEV); 204 return -ENODEV;
207 } 205 }
208 206
209 package = (union acpi_object *)buffer.pointer; 207 package = (union acpi_object *)buffer.pointer;
@@ -212,7 +210,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
212 210
213 status = acpi_extract_package(package, &format, &data); 211 status = acpi_extract_package(package, &format, &data);
214 if (status != AE_BUFFER_OVERFLOW) { 212 if (status != AE_BUFFER_OVERFLOW) {
215 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); 213 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
216 result = -ENODEV; 214 result = -ENODEV;
217 goto end; 215 goto end;
218 } 216 }
@@ -226,7 +224,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
226 224
227 status = acpi_extract_package(package, &format, &data); 225 status = acpi_extract_package(package, &format, &data);
228 if (ACPI_FAILURE(status)) { 226 if (ACPI_FAILURE(status)) {
229 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); 227 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
230 kfree(data.pointer); 228 kfree(data.pointer);
231 result = -ENODEV; 229 result = -ENODEV;
232 goto end; 230 goto end;
@@ -238,7 +236,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
238 if (!result) 236 if (!result)
239 (*bst) = (struct acpi_battery_status *)data.pointer; 237 (*bst) = (struct acpi_battery_status *)data.pointer;
240 238
241 return_VALUE(result); 239 return result;
242} 240}
243 241
244static int 242static int
@@ -248,25 +246,24 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
248 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 246 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
249 struct acpi_object_list arg_list = { 1, &arg0 }; 247 struct acpi_object_list arg_list = { 1, &arg0 };
250 248
251 ACPI_FUNCTION_TRACE("acpi_battery_set_alarm");
252 249
253 if (!battery) 250 if (!battery)
254 return_VALUE(-EINVAL); 251 return -EINVAL;
255 252
256 if (!battery->flags.alarm) 253 if (!battery->flags.alarm)
257 return_VALUE(-ENODEV); 254 return -ENODEV;
258 255
259 arg0.integer.value = alarm; 256 arg0.integer.value = alarm;
260 257
261 status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); 258 status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL);
262 if (ACPI_FAILURE(status)) 259 if (ACPI_FAILURE(status))
263 return_VALUE(-ENODEV); 260 return -ENODEV;
264 261
265 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm)); 262 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm));
266 263
267 battery->alarm = alarm; 264 battery->alarm = alarm;
268 265
269 return_VALUE(0); 266 return 0;
270} 267}
271 268
272static int acpi_battery_check(struct acpi_battery *battery) 269static int acpi_battery_check(struct acpi_battery *battery)
@@ -277,18 +274,17 @@ static int acpi_battery_check(struct acpi_battery *battery)
277 struct acpi_device *device = NULL; 274 struct acpi_device *device = NULL;
278 struct acpi_battery_info *bif = NULL; 275 struct acpi_battery_info *bif = NULL;
279 276
280 ACPI_FUNCTION_TRACE("acpi_battery_check");
281 277
282 if (!battery) 278 if (!battery)
283 return_VALUE(-EINVAL); 279 return -EINVAL;
284 280
285 result = acpi_bus_get_device(battery->handle, &device); 281 result = acpi_bus_get_device(battery->handle, &device);
286 if (result) 282 if (result)
287 return_VALUE(result); 283 return result;
288 284
289 result = acpi_bus_get_status(device); 285 result = acpi_bus_get_status(device);
290 if (result) 286 if (result)
291 return_VALUE(result); 287 return result;
292 288
293 /* Insertion? */ 289 /* Insertion? */
294 290
@@ -300,7 +296,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
300 296
301 result = acpi_battery_get_info(battery, &bif); 297 result = acpi_battery_get_info(battery, &bif);
302 if (result) 298 if (result)
303 return_VALUE(result); 299 return result;
304 300
305 battery->flags.power_unit = bif->power_unit; 301 battery->flags.power_unit = bif->power_unit;
306 battery->trips.warning = bif->design_capacity_warning; 302 battery->trips.warning = bif->design_capacity_warning;
@@ -324,7 +320,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
324 320
325 battery->flags.present = device->status.battery_present; 321 battery->flags.present = device->status.battery_present;
326 322
327 return_VALUE(result); 323 return result;
328} 324}
329 325
330/* -------------------------------------------------------------------------- 326/* --------------------------------------------------------------------------
@@ -339,7 +335,6 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
339 struct acpi_battery_info *bif = NULL; 335 struct acpi_battery_info *bif = NULL;
340 char *units = "?"; 336 char *units = "?";
341 337
342 ACPI_FUNCTION_TRACE("acpi_battery_read_info");
343 338
344 if (!battery) 339 if (!battery)
345 goto end; 340 goto end;
@@ -409,7 +404,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
409 end: 404 end:
410 kfree(bif); 405 kfree(bif);
411 406
412 return_VALUE(0); 407 return 0;
413} 408}
414 409
415static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) 410static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
@@ -424,7 +419,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
424 struct acpi_battery_status *bst = NULL; 419 struct acpi_battery_status *bst = NULL;
425 char *units = "?"; 420 char *units = "?";
426 421
427 ACPI_FUNCTION_TRACE("acpi_battery_read_state");
428 422
429 if (!battery) 423 if (!battery)
430 goto end; 424 goto end;
@@ -458,8 +452,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
458 if ((bst->state & 0x01) && (bst->state & 0x02)) { 452 if ((bst->state & 0x01) && (bst->state & 0x02)) {
459 seq_printf(seq, 453 seq_printf(seq,
460 "charging state: charging/discharging\n"); 454 "charging state: charging/discharging\n");
461 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
462 "Battery Charging and Discharging?\n"));
463 } else if (bst->state & 0x01) 455 } else if (bst->state & 0x01)
464 seq_printf(seq, "charging state: discharging\n"); 456 seq_printf(seq, "charging state: discharging\n");
465 else if (bst->state & 0x02) 457 else if (bst->state & 0x02)
@@ -489,7 +481,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
489 end: 481 end:
490 kfree(bst); 482 kfree(bst);
491 483
492 return_VALUE(0); 484 return 0;
493} 485}
494 486
495static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) 487static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
@@ -502,7 +494,6 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
502 struct acpi_battery *battery = (struct acpi_battery *)seq->private; 494 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
503 char *units = "?"; 495 char *units = "?";
504 496
505 ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
506 497
507 if (!battery) 498 if (!battery)
508 goto end; 499 goto end;
@@ -527,7 +518,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
527 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); 518 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
528 519
529 end: 520 end:
530 return_VALUE(0); 521 return 0;
531} 522}
532 523
533static ssize_t 524static ssize_t
@@ -540,25 +531,24 @@ acpi_battery_write_alarm(struct file *file,
540 struct seq_file *m = (struct seq_file *)file->private_data; 531 struct seq_file *m = (struct seq_file *)file->private_data;
541 struct acpi_battery *battery = (struct acpi_battery *)m->private; 532 struct acpi_battery *battery = (struct acpi_battery *)m->private;
542 533
543 ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
544 534
545 if (!battery || (count > sizeof(alarm_string) - 1)) 535 if (!battery || (count > sizeof(alarm_string) - 1))
546 return_VALUE(-EINVAL); 536 return -EINVAL;
547 537
548 if (!battery->flags.present) 538 if (!battery->flags.present)
549 return_VALUE(-ENODEV); 539 return -ENODEV;
550 540
551 if (copy_from_user(alarm_string, buffer, count)) 541 if (copy_from_user(alarm_string, buffer, count))
552 return_VALUE(-EFAULT); 542 return -EFAULT;
553 543
554 alarm_string[count] = '\0'; 544 alarm_string[count] = '\0';
555 545
556 result = acpi_battery_set_alarm(battery, 546 result = acpi_battery_set_alarm(battery,
557 simple_strtoul(alarm_string, NULL, 0)); 547 simple_strtoul(alarm_string, NULL, 0));
558 if (result) 548 if (result)
559 return_VALUE(result); 549 return result;
560 550
561 return_VALUE(count); 551 return count;
562} 552}
563 553
564static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) 554static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
@@ -595,13 +585,12 @@ static int acpi_battery_add_fs(struct acpi_device *device)
595{ 585{
596 struct proc_dir_entry *entry = NULL; 586 struct proc_dir_entry *entry = NULL;
597 587
598 ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
599 588
600 if (!acpi_device_dir(device)) { 589 if (!acpi_device_dir(device)) {
601 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 590 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
602 acpi_battery_dir); 591 acpi_battery_dir);
603 if (!acpi_device_dir(device)) 592 if (!acpi_device_dir(device))
604 return_VALUE(-ENODEV); 593 return -ENODEV;
605 acpi_device_dir(device)->owner = THIS_MODULE; 594 acpi_device_dir(device)->owner = THIS_MODULE;
606 } 595 }
607 596
@@ -609,9 +598,7 @@ static int acpi_battery_add_fs(struct acpi_device *device)
609 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, 598 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
610 S_IRUGO, acpi_device_dir(device)); 599 S_IRUGO, acpi_device_dir(device));
611 if (!entry) 600 if (!entry)
612 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 601 return -ENODEV;
613 "Unable to create '%s' fs entry\n",
614 ACPI_BATTERY_FILE_INFO));
615 else { 602 else {
616 entry->proc_fops = &acpi_battery_info_ops; 603 entry->proc_fops = &acpi_battery_info_ops;
617 entry->data = acpi_driver_data(device); 604 entry->data = acpi_driver_data(device);
@@ -622,9 +609,7 @@ static int acpi_battery_add_fs(struct acpi_device *device)
622 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, 609 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
623 S_IRUGO, acpi_device_dir(device)); 610 S_IRUGO, acpi_device_dir(device));
624 if (!entry) 611 if (!entry)
625 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 612 return -ENODEV;
626 "Unable to create '%s' fs entry\n",
627 ACPI_BATTERY_FILE_STATUS));
628 else { 613 else {
629 entry->proc_fops = &acpi_battery_state_ops; 614 entry->proc_fops = &acpi_battery_state_ops;
630 entry->data = acpi_driver_data(device); 615 entry->data = acpi_driver_data(device);
@@ -636,21 +621,18 @@ static int acpi_battery_add_fs(struct acpi_device *device)
636 S_IFREG | S_IRUGO | S_IWUSR, 621 S_IFREG | S_IRUGO | S_IWUSR,
637 acpi_device_dir(device)); 622 acpi_device_dir(device));
638 if (!entry) 623 if (!entry)
639 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 624 return -ENODEV;
640 "Unable to create '%s' fs entry\n",
641 ACPI_BATTERY_FILE_ALARM));
642 else { 625 else {
643 entry->proc_fops = &acpi_battery_alarm_ops; 626 entry->proc_fops = &acpi_battery_alarm_ops;
644 entry->data = acpi_driver_data(device); 627 entry->data = acpi_driver_data(device);
645 entry->owner = THIS_MODULE; 628 entry->owner = THIS_MODULE;
646 } 629 }
647 630
648 return_VALUE(0); 631 return 0;
649} 632}
650 633
651static int acpi_battery_remove_fs(struct acpi_device *device) 634static int acpi_battery_remove_fs(struct acpi_device *device)
652{ 635{
653 ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
654 636
655 if (acpi_device_dir(device)) { 637 if (acpi_device_dir(device)) {
656 remove_proc_entry(ACPI_BATTERY_FILE_ALARM, 638 remove_proc_entry(ACPI_BATTERY_FILE_ALARM,
@@ -664,7 +646,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device)
664 acpi_device_dir(device) = NULL; 646 acpi_device_dir(device) = NULL;
665 } 647 }
666 648
667 return_VALUE(0); 649 return 0;
668} 650}
669 651
670/* -------------------------------------------------------------------------- 652/* --------------------------------------------------------------------------
@@ -676,13 +658,12 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
676 struct acpi_battery *battery = (struct acpi_battery *)data; 658 struct acpi_battery *battery = (struct acpi_battery *)data;
677 struct acpi_device *device = NULL; 659 struct acpi_device *device = NULL;
678 660
679 ACPI_FUNCTION_TRACE("acpi_battery_notify");
680 661
681 if (!battery) 662 if (!battery)
682 return_VOID; 663 return;
683 664
684 if (acpi_bus_get_device(handle, &device)) 665 if (acpi_bus_get_device(handle, &device))
685 return_VOID; 666 return;
686 667
687 switch (event) { 668 switch (event) {
688 case ACPI_BATTERY_NOTIFY_STATUS: 669 case ACPI_BATTERY_NOTIFY_STATUS:
@@ -696,7 +677,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
696 break; 677 break;
697 } 678 }
698 679
699 return_VOID; 680 return;
700} 681}
701 682
702static int acpi_battery_add(struct acpi_device *device) 683static int acpi_battery_add(struct acpi_device *device)
@@ -705,14 +686,13 @@ static int acpi_battery_add(struct acpi_device *device)
705 acpi_status status = 0; 686 acpi_status status = 0;
706 struct acpi_battery *battery = NULL; 687 struct acpi_battery *battery = NULL;
707 688
708 ACPI_FUNCTION_TRACE("acpi_battery_add");
709 689
710 if (!device) 690 if (!device)
711 return_VALUE(-EINVAL); 691 return -EINVAL;
712 692
713 battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); 693 battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL);
714 if (!battery) 694 if (!battery)
715 return_VALUE(-ENOMEM); 695 return -ENOMEM;
716 memset(battery, 0, sizeof(struct acpi_battery)); 696 memset(battery, 0, sizeof(struct acpi_battery));
717 697
718 battery->handle = device->handle; 698 battery->handle = device->handle;
@@ -732,8 +712,6 @@ static int acpi_battery_add(struct acpi_device *device)
732 ACPI_DEVICE_NOTIFY, 712 ACPI_DEVICE_NOTIFY,
733 acpi_battery_notify, battery); 713 acpi_battery_notify, battery);
734 if (ACPI_FAILURE(status)) { 714 if (ACPI_FAILURE(status)) {
735 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
736 "Error installing notify handler\n"));
737 result = -ENODEV; 715 result = -ENODEV;
738 goto end; 716 goto end;
739 } 717 }
@@ -748,7 +726,7 @@ static int acpi_battery_add(struct acpi_device *device)
748 kfree(battery); 726 kfree(battery);
749 } 727 }
750 728
751 return_VALUE(result); 729 return result;
752} 730}
753 731
754static int acpi_battery_remove(struct acpi_device *device, int type) 732static int acpi_battery_remove(struct acpi_device *device, int type)
@@ -756,56 +734,50 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
756 acpi_status status = 0; 734 acpi_status status = 0;
757 struct acpi_battery *battery = NULL; 735 struct acpi_battery *battery = NULL;
758 736
759 ACPI_FUNCTION_TRACE("acpi_battery_remove");
760 737
761 if (!device || !acpi_driver_data(device)) 738 if (!device || !acpi_driver_data(device))
762 return_VALUE(-EINVAL); 739 return -EINVAL;
763 740
764 battery = (struct acpi_battery *)acpi_driver_data(device); 741 battery = (struct acpi_battery *)acpi_driver_data(device);
765 742
766 status = acpi_remove_notify_handler(battery->handle, 743 status = acpi_remove_notify_handler(battery->handle,
767 ACPI_DEVICE_NOTIFY, 744 ACPI_DEVICE_NOTIFY,
768 acpi_battery_notify); 745 acpi_battery_notify);
769 if (ACPI_FAILURE(status))
770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
771 "Error removing notify handler\n"));
772 746
773 acpi_battery_remove_fs(device); 747 acpi_battery_remove_fs(device);
774 748
775 kfree(battery); 749 kfree(battery);
776 750
777 return_VALUE(0); 751 return 0;
778} 752}
779 753
780static int __init acpi_battery_init(void) 754static int __init acpi_battery_init(void)
781{ 755{
782 int result = 0; 756 int result = 0;
783 757
784 ACPI_FUNCTION_TRACE("acpi_battery_init");
785 758
786 acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); 759 acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
787 if (!acpi_battery_dir) 760 if (!acpi_battery_dir)
788 return_VALUE(-ENODEV); 761 return -ENODEV;
789 acpi_battery_dir->owner = THIS_MODULE; 762 acpi_battery_dir->owner = THIS_MODULE;
790 763
791 result = acpi_bus_register_driver(&acpi_battery_driver); 764 result = acpi_bus_register_driver(&acpi_battery_driver);
792 if (result < 0) { 765 if (result < 0) {
793 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 766 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
794 return_VALUE(-ENODEV); 767 return -ENODEV;
795 } 768 }
796 769
797 return_VALUE(0); 770 return 0;
798} 771}
799 772
800static void __exit acpi_battery_exit(void) 773static void __exit acpi_battery_exit(void)
801{ 774{
802 ACPI_FUNCTION_TRACE("acpi_battery_exit");
803 775
804 acpi_bus_unregister_driver(&acpi_battery_driver); 776 acpi_bus_unregister_driver(&acpi_battery_driver);
805 777
806 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 778 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
807 779
808 return_VOID; 780 return;
809} 781}
810 782
811module_init(acpi_battery_init); 783module_init(acpi_battery_init);
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index dd3983cece92..dec044c04273 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -60,21 +60,19 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
60{ 60{
61 acpi_status status = AE_OK; 61 acpi_status status = AE_OK;
62 62
63 ACPI_FUNCTION_TRACE("acpi_bus_get_device");
64 63
65 if (!device) 64 if (!device)
66 return_VALUE(-EINVAL); 65 return -EINVAL;
67 66
68 /* TBD: Support fixed-feature devices */ 67 /* TBD: Support fixed-feature devices */
69 68
70 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); 69 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
71 if (ACPI_FAILURE(status) || !*device) { 70 if (ACPI_FAILURE(status) || !*device) {
72 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n", 71 ACPI_EXCEPTION((AE_INFO, status, "No context for object [%p]", handle));
73 handle)); 72 return -ENODEV;
74 return_VALUE(-ENODEV);
75 } 73 }
76 74
77 return_VALUE(0); 75 return 0;
78} 76}
79 77
80EXPORT_SYMBOL(acpi_bus_get_device); 78EXPORT_SYMBOL(acpi_bus_get_device);
@@ -84,10 +82,9 @@ int acpi_bus_get_status(struct acpi_device *device)
84 acpi_status status = AE_OK; 82 acpi_status status = AE_OK;
85 unsigned long sta = 0; 83 unsigned long sta = 0;
86 84
87 ACPI_FUNCTION_TRACE("acpi_bus_get_status");
88 85
89 if (!device) 86 if (!device)
90 return_VALUE(-EINVAL); 87 return -EINVAL;
91 88
92 /* 89 /*
93 * Evaluate _STA if present. 90 * Evaluate _STA if present.
@@ -96,7 +93,7 @@ int acpi_bus_get_status(struct acpi_device *device)
96 status = 93 status =
97 acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); 94 acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
98 if (ACPI_FAILURE(status)) 95 if (ACPI_FAILURE(status))
99 return_VALUE(-ENODEV); 96 return -ENODEV;
100 STRUCT_TO_INT(device->status) = (int)sta; 97 STRUCT_TO_INT(device->status) = (int)sta;
101 } 98 }
102 99
@@ -120,7 +117,7 @@ int acpi_bus_get_status(struct acpi_device *device)
120 device->pnp.bus_id, 117 device->pnp.bus_id,
121 (u32) STRUCT_TO_INT(device->status))); 118 (u32) STRUCT_TO_INT(device->status)));
122 119
123 return_VALUE(0); 120 return 0;
124} 121}
125 122
126EXPORT_SYMBOL(acpi_bus_get_status); 123EXPORT_SYMBOL(acpi_bus_get_status);
@@ -136,11 +133,10 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
136 struct acpi_device *device = NULL; 133 struct acpi_device *device = NULL;
137 unsigned long psc = 0; 134 unsigned long psc = 0;
138 135
139 ACPI_FUNCTION_TRACE("acpi_bus_get_power");
140 136
141 result = acpi_bus_get_device(handle, &device); 137 result = acpi_bus_get_device(handle, &device);
142 if (result) 138 if (result)
143 return_VALUE(result); 139 return result;
144 140
145 *state = ACPI_STATE_UNKNOWN; 141 *state = ACPI_STATE_UNKNOWN;
146 142
@@ -159,12 +155,12 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
159 status = acpi_evaluate_integer(device->handle, "_PSC", 155 status = acpi_evaluate_integer(device->handle, "_PSC",
160 NULL, &psc); 156 NULL, &psc);
161 if (ACPI_FAILURE(status)) 157 if (ACPI_FAILURE(status))
162 return_VALUE(-ENODEV); 158 return -ENODEV;
163 device->power.state = (int)psc; 159 device->power.state = (int)psc;
164 } else if (device->power.flags.power_resources) { 160 } else if (device->power.flags.power_resources) {
165 result = acpi_power_get_inferred_state(device); 161 result = acpi_power_get_inferred_state(device);
166 if (result) 162 if (result)
167 return_VALUE(result); 163 return result;
168 } 164 }
169 165
170 *state = device->power.state; 166 *state = device->power.state;
@@ -173,7 +169,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
173 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
174 device->pnp.bus_id, device->power.state)); 170 device->pnp.bus_id, device->power.state));
175 171
176 return_VALUE(0); 172 return 0;
177} 173}
178 174
179EXPORT_SYMBOL(acpi_bus_get_power); 175EXPORT_SYMBOL(acpi_bus_get_power);
@@ -185,21 +181,20 @@ int acpi_bus_set_power(acpi_handle handle, int state)
185 struct acpi_device *device = NULL; 181 struct acpi_device *device = NULL;
186 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; 182 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
187 183
188 ACPI_FUNCTION_TRACE("acpi_bus_set_power");
189 184
190 result = acpi_bus_get_device(handle, &device); 185 result = acpi_bus_get_device(handle, &device);
191 if (result) 186 if (result)
192 return_VALUE(result); 187 return result;
193 188
194 if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 189 if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
195 return_VALUE(-EINVAL); 190 return -EINVAL;
196 191
197 /* Make sure this is a valid target state */ 192 /* Make sure this is a valid target state */
198 193
199 if (!device->flags.power_manageable) { 194 if (!device->flags.power_manageable) {
200 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 195 printk(KERN_DEBUG "Device `[%s]is not power manageable",
201 "Device is not power manageable\n")); 196 device->kobj.name);
202 return_VALUE(-ENODEV); 197 return -ENODEV;
203 } 198 }
204 /* 199 /*
205 * Get device's current power state if it's unknown 200 * Get device's current power state if it's unknown
@@ -211,18 +206,18 @@ int acpi_bus_set_power(acpi_handle handle, int state)
211 if (state == device->power.state) { 206 if (state == device->power.state) {
212 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", 207 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
213 state)); 208 state));
214 return_VALUE(0); 209 return 0;
215 } 210 }
216 } 211 }
217 if (!device->power.states[state].flags.valid) { 212 if (!device->power.states[state].flags.valid) {
218 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", 213 printk(KERN_WARNING PREFIX "Device does not support D%d\n", state);
219 state)); 214 return -ENODEV;
220 return_VALUE(-ENODEV);
221 } 215 }
222 if (device->parent && (state < device->parent->power.state)) { 216 if (device->parent && (state < device->parent->power.state)) {
223 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 217 printk(KERN_WARNING PREFIX
224 "Cannot set device to a higher-powered state than parent\n")); 218 "Cannot set device to a higher-powered"
225 return_VALUE(-ENODEV); 219 " state than parent\n");
220 return -ENODEV;
226 } 221 }
227 222
228 /* 223 /*
@@ -264,15 +259,15 @@ int acpi_bus_set_power(acpi_handle handle, int state)
264 259
265 end: 260 end:
266 if (result) 261 if (result)
267 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 262 printk(KERN_WARNING PREFIX
268 "Error transitioning device [%s] to D%d\n", 263 "Transitioning device [%s] to D%d\n",
269 device->pnp.bus_id, state)); 264 device->pnp.bus_id, state);
270 else 265 else
271 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 266 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
272 "Device [%s] transitioned to D%d\n", 267 "Device [%s] transitioned to D%d\n",
273 device->pnp.bus_id, state)); 268 device->pnp.bus_id, state));
274 269
275 return_VALUE(result); 270 return result;
276} 271}
277 272
278EXPORT_SYMBOL(acpi_bus_set_power); 273EXPORT_SYMBOL(acpi_bus_set_power);
@@ -293,18 +288,17 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
293 struct acpi_bus_event *event = NULL; 288 struct acpi_bus_event *event = NULL;
294 unsigned long flags = 0; 289 unsigned long flags = 0;
295 290
296 ACPI_FUNCTION_TRACE("acpi_bus_generate_event");
297 291
298 if (!device) 292 if (!device)
299 return_VALUE(-EINVAL); 293 return -EINVAL;
300 294
301 /* drop event on the floor if no one's listening */ 295 /* drop event on the floor if no one's listening */
302 if (!event_is_open) 296 if (!event_is_open)
303 return_VALUE(0); 297 return 0;
304 298
305 event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC); 299 event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
306 if (!event) 300 if (!event)
307 return_VALUE(-ENOMEM); 301 return -ENOMEM;
308 302
309 strcpy(event->device_class, device->pnp.device_class); 303 strcpy(event->device_class, device->pnp.device_class);
310 strcpy(event->bus_id, device->pnp.bus_id); 304 strcpy(event->bus_id, device->pnp.bus_id);
@@ -317,7 +311,7 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
317 311
318 wake_up_interruptible(&acpi_bus_event_queue); 312 wake_up_interruptible(&acpi_bus_event_queue);
319 313
320 return_VALUE(0); 314 return 0;
321} 315}
322 316
323EXPORT_SYMBOL(acpi_bus_generate_event); 317EXPORT_SYMBOL(acpi_bus_generate_event);
@@ -329,10 +323,9 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
329 323
330 DECLARE_WAITQUEUE(wait, current); 324 DECLARE_WAITQUEUE(wait, current);
331 325
332 ACPI_FUNCTION_TRACE("acpi_bus_receive_event");
333 326
334 if (!event) 327 if (!event)
335 return_VALUE(-EINVAL); 328 return -EINVAL;
336 329
337 if (list_empty(&acpi_bus_event_list)) { 330 if (list_empty(&acpi_bus_event_list)) {
338 331
@@ -346,7 +339,7 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
346 set_current_state(TASK_RUNNING); 339 set_current_state(TASK_RUNNING);
347 340
348 if (signal_pending(current)) 341 if (signal_pending(current))
349 return_VALUE(-ERESTARTSYS); 342 return -ERESTARTSYS;
350 } 343 }
351 344
352 spin_lock_irqsave(&acpi_bus_event_lock, flags); 345 spin_lock_irqsave(&acpi_bus_event_lock, flags);
@@ -357,13 +350,13 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
357 spin_unlock_irqrestore(&acpi_bus_event_lock, flags); 350 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
358 351
359 if (!entry) 352 if (!entry)
360 return_VALUE(-ENODEV); 353 return -ENODEV;
361 354
362 memcpy(event, entry, sizeof(struct acpi_bus_event)); 355 memcpy(event, entry, sizeof(struct acpi_bus_event));
363 356
364 kfree(entry); 357 kfree(entry);
365 358
366 return_VALUE(0); 359 return 0;
367} 360}
368 361
369EXPORT_SYMBOL(acpi_bus_receive_event); 362EXPORT_SYMBOL(acpi_bus_receive_event);
@@ -378,10 +371,9 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
378 acpi_status status = 0; 371 acpi_status status = 0;
379 struct acpi_device_status old_status; 372 struct acpi_device_status old_status;
380 373
381 ACPI_FUNCTION_TRACE("acpi_bus_check_device");
382 374
383 if (!device) 375 if (!device)
384 return_VALUE(-EINVAL); 376 return -EINVAL;
385 377
386 if (status_changed) 378 if (status_changed)
387 *status_changed = 0; 379 *status_changed = 0;
@@ -398,15 +390,15 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
398 if (status_changed) 390 if (status_changed)
399 *status_changed = 1; 391 *status_changed = 1;
400 } 392 }
401 return_VALUE(0); 393 return 0;
402 } 394 }
403 395
404 status = acpi_bus_get_status(device); 396 status = acpi_bus_get_status(device);
405 if (ACPI_FAILURE(status)) 397 if (ACPI_FAILURE(status))
406 return_VALUE(-ENODEV); 398 return -ENODEV;
407 399
408 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) 400 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
409 return_VALUE(0); 401 return 0;
410 402
411 if (status_changed) 403 if (status_changed)
412 *status_changed = 1; 404 *status_changed = 1;
@@ -422,7 +414,7 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
422 /* TBD: Handle device removal */ 414 /* TBD: Handle device removal */
423 } 415 }
424 416
425 return_VALUE(0); 417 return 0;
426} 418}
427 419
428static int acpi_bus_check_scope(struct acpi_device *device) 420static int acpi_bus_check_scope(struct acpi_device *device)
@@ -430,25 +422,24 @@ static int acpi_bus_check_scope(struct acpi_device *device)
430 int result = 0; 422 int result = 0;
431 int status_changed = 0; 423 int status_changed = 0;
432 424
433 ACPI_FUNCTION_TRACE("acpi_bus_check_scope");
434 425
435 if (!device) 426 if (!device)
436 return_VALUE(-EINVAL); 427 return -EINVAL;
437 428
438 /* Status Change? */ 429 /* Status Change? */
439 result = acpi_bus_check_device(device, &status_changed); 430 result = acpi_bus_check_device(device, &status_changed);
440 if (result) 431 if (result)
441 return_VALUE(result); 432 return result;
442 433
443 if (!status_changed) 434 if (!status_changed)
444 return_VALUE(0); 435 return 0;
445 436
446 /* 437 /*
447 * TBD: Enumerate child devices within this device's scope and 438 * TBD: Enumerate child devices within this device's scope and
448 * run acpi_bus_check_device()'s on them. 439 * run acpi_bus_check_device()'s on them.
449 */ 440 */
450 441
451 return_VALUE(0); 442 return 0;
452} 443}
453 444
454/** 445/**
@@ -461,10 +452,9 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
461 int result = 0; 452 int result = 0;
462 struct acpi_device *device = NULL; 453 struct acpi_device *device = NULL;
463 454
464 ACPI_FUNCTION_TRACE("acpi_bus_notify");
465 455
466 if (acpi_bus_get_device(handle, &device)) 456 if (acpi_bus_get_device(handle, &device))
467 return_VOID; 457 return;
468 458
469 switch (type) { 459 switch (type) {
470 460
@@ -539,7 +529,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
539 break; 529 break;
540 } 530 }
541 531
542 return_VOID; 532 return;
543} 533}
544 534
545/* -------------------------------------------------------------------------- 535/* --------------------------------------------------------------------------
@@ -553,7 +543,6 @@ static int __init acpi_bus_init_irq(void)
553 struct acpi_object_list arg_list = { 1, &arg }; 543 struct acpi_object_list arg_list = { 1, &arg };
554 char *message = NULL; 544 char *message = NULL;
555 545
556 ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
557 546
558 /* 547 /*
559 * Let the system know what interrupt model we are using by 548 * Let the system know what interrupt model we are using by
@@ -572,7 +561,7 @@ static int __init acpi_bus_init_irq(void)
572 break; 561 break;
573 default: 562 default:
574 printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n"); 563 printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
575 return_VALUE(-ENODEV); 564 return -ENODEV;
576 } 565 }
577 566
578 printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message); 567 printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
@@ -581,11 +570,11 @@ static int __init acpi_bus_init_irq(void)
581 570
582 status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL); 571 status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
583 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 572 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
584 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n")); 573 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
585 return_VALUE(-ENODEV); 574 return -ENODEV;
586 } 575 }
587 576
588 return_VALUE(0); 577 return 0;
589} 578}
590 579
591void __init acpi_early_init(void) 580void __init acpi_early_init(void)
@@ -593,10 +582,9 @@ void __init acpi_early_init(void)
593 acpi_status status = AE_OK; 582 acpi_status status = AE_OK;
594 struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt }; 583 struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt };
595 584
596 ACPI_FUNCTION_TRACE("acpi_early_init");
597 585
598 if (acpi_disabled) 586 if (acpi_disabled)
599 return_VOID; 587 return;
600 588
601 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); 589 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
602 590
@@ -656,11 +644,11 @@ void __init acpi_early_init(void)
656 goto error0; 644 goto error0;
657 } 645 }
658 646
659 return_VOID; 647 return;
660 648
661 error0: 649 error0:
662 disable_acpi(); 650 disable_acpi();
663 return_VOID; 651 return;
664} 652}
665 653
666static int __init acpi_bus_init(void) 654static int __init acpi_bus_init(void)
@@ -669,7 +657,6 @@ static int __init acpi_bus_init(void)
669 acpi_status status = AE_OK; 657 acpi_status status = AE_OK;
670 extern acpi_status acpi_os_initialize1(void); 658 extern acpi_status acpi_os_initialize1(void);
671 659
672 ACPI_FUNCTION_TRACE("acpi_bus_init");
673 660
674 status = acpi_os_initialize1(); 661 status = acpi_os_initialize1();
675 662
@@ -731,12 +718,12 @@ static int __init acpi_bus_init(void)
731 */ 718 */
732 acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL); 719 acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
733 720
734 return_VALUE(0); 721 return 0;
735 722
736 /* Mimic structured exception handling */ 723 /* Mimic structured exception handling */
737 error1: 724 error1:
738 acpi_terminate(); 725 acpi_terminate();
739 return_VALUE(-ENODEV); 726 return -ENODEV;
740} 727}
741 728
742decl_subsys(acpi, NULL, NULL); 729decl_subsys(acpi, NULL, NULL);
@@ -745,11 +732,10 @@ static int __init acpi_init(void)
745{ 732{
746 int result = 0; 733 int result = 0;
747 734
748 ACPI_FUNCTION_TRACE("acpi_init");
749 735
750 if (acpi_disabled) { 736 if (acpi_disabled) {
751 printk(KERN_INFO PREFIX "Interpreter disabled.\n"); 737 printk(KERN_INFO PREFIX "Interpreter disabled.\n");
752 return_VALUE(-ENODEV); 738 return -ENODEV;
753 } 739 }
754 740
755 firmware_register(&acpi_subsys); 741 firmware_register(&acpi_subsys);
@@ -770,7 +756,7 @@ static int __init acpi_init(void)
770 } else 756 } else
771 disable_acpi(); 757 disable_acpi();
772 758
773 return_VALUE(result); 759 return result;
774} 760}
775 761
776subsys_initcall(acpi_init); 762subsys_initcall(acpi_init);
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 4b6d9f0096a1..02594639c4d9 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -112,15 +112,14 @@ static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
112{ 112{
113 struct acpi_button *button = (struct acpi_button *)seq->private; 113 struct acpi_button *button = (struct acpi_button *)seq->private;
114 114
115 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
116 115
117 if (!button || !button->device) 116 if (!button || !button->device)
118 return_VALUE(0); 117 return 0;
119 118
120 seq_printf(seq, "type: %s\n", 119 seq_printf(seq, "type: %s\n",
121 acpi_device_name(button->device)); 120 acpi_device_name(button->device));
122 121
123 return_VALUE(0); 122 return 0;
124} 123}
125 124
126static int acpi_button_info_open_fs(struct inode *inode, struct file *file) 125static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
@@ -134,10 +133,9 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
134 acpi_status status; 133 acpi_status status;
135 unsigned long state; 134 unsigned long state;
136 135
137 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
138 136
139 if (!button || !button->device) 137 if (!button || !button->device)
140 return_VALUE(0); 138 return 0;
141 139
142 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); 140 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
143 if (ACPI_FAILURE(status)) { 141 if (ACPI_FAILURE(status)) {
@@ -147,7 +145,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
147 (state ? "open" : "closed")); 145 (state ? "open" : "closed"));
148 } 146 }
149 147
150 return_VALUE(0); 148 return 0;
151} 149}
152 150
153static int acpi_button_state_open_fs(struct inode *inode, struct file *file) 151static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
@@ -164,10 +162,9 @@ static int acpi_button_add_fs(struct acpi_device *device)
164 struct proc_dir_entry *entry = NULL; 162 struct proc_dir_entry *entry = NULL;
165 struct acpi_button *button = NULL; 163 struct acpi_button *button = NULL;
166 164
167 ACPI_FUNCTION_TRACE("acpi_button_add_fs");
168 165
169 if (!device || !acpi_driver_data(device)) 166 if (!device || !acpi_driver_data(device))
170 return_VALUE(-EINVAL); 167 return -EINVAL;
171 168
172 button = acpi_driver_data(device); 169 button = acpi_driver_data(device);
173 170
@@ -195,21 +192,19 @@ static int acpi_button_add_fs(struct acpi_device *device)
195 } 192 }
196 193
197 if (!entry) 194 if (!entry)
198 return_VALUE(-ENODEV); 195 return -ENODEV;
199 entry->owner = THIS_MODULE; 196 entry->owner = THIS_MODULE;
200 197
201 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 198 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
202 if (!acpi_device_dir(device)) 199 if (!acpi_device_dir(device))
203 return_VALUE(-ENODEV); 200 return -ENODEV;
204 acpi_device_dir(device)->owner = THIS_MODULE; 201 acpi_device_dir(device)->owner = THIS_MODULE;
205 202
206 /* 'info' [R] */ 203 /* 'info' [R] */
207 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, 204 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
208 S_IRUGO, acpi_device_dir(device)); 205 S_IRUGO, acpi_device_dir(device));
209 if (!entry) 206 if (!entry)
210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 207 return -ENODEV;
211 "Unable to create '%s' fs entry\n",
212 ACPI_BUTTON_FILE_INFO));
213 else { 208 else {
214 entry->proc_fops = &acpi_button_info_fops; 209 entry->proc_fops = &acpi_button_info_fops;
215 entry->data = acpi_driver_data(device); 210 entry->data = acpi_driver_data(device);
@@ -221,9 +216,7 @@ static int acpi_button_add_fs(struct acpi_device *device)
221 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, 216 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
222 S_IRUGO, acpi_device_dir(device)); 217 S_IRUGO, acpi_device_dir(device));
223 if (!entry) 218 if (!entry)
224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 return -ENODEV;
225 "Unable to create '%s' fs entry\n",
226 ACPI_BUTTON_FILE_INFO));
227 else { 220 else {
228 entry->proc_fops = &acpi_button_state_fops; 221 entry->proc_fops = &acpi_button_state_fops;
229 entry->data = acpi_driver_data(device); 222 entry->data = acpi_driver_data(device);
@@ -231,14 +224,13 @@ static int acpi_button_add_fs(struct acpi_device *device)
231 } 224 }
232 } 225 }
233 226
234 return_VALUE(0); 227 return 0;
235} 228}
236 229
237static int acpi_button_remove_fs(struct acpi_device *device) 230static int acpi_button_remove_fs(struct acpi_device *device)
238{ 231{
239 struct acpi_button *button = NULL; 232 struct acpi_button *button = NULL;
240 233
241 ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
242 234
243 button = acpi_driver_data(device); 235 button = acpi_driver_data(device);
244 if (acpi_device_dir(device)) { 236 if (acpi_device_dir(device)) {
@@ -253,7 +245,7 @@ static int acpi_button_remove_fs(struct acpi_device *device)
253 acpi_device_dir(device) = NULL; 245 acpi_device_dir(device) = NULL;
254 } 246 }
255 247
256 return_VALUE(0); 248 return 0;
257} 249}
258 250
259/* -------------------------------------------------------------------------- 251/* --------------------------------------------------------------------------
@@ -264,10 +256,9 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
264{ 256{
265 struct acpi_button *button = (struct acpi_button *)data; 257 struct acpi_button *button = (struct acpi_button *)data;
266 258
267 ACPI_FUNCTION_TRACE("acpi_button_notify");
268 259
269 if (!button || !button->device) 260 if (!button || !button->device)
270 return_VOID; 261 return;
271 262
272 switch (event) { 263 switch (event) {
273 case ACPI_BUTTON_NOTIFY_STATUS: 264 case ACPI_BUTTON_NOTIFY_STATUS:
@@ -280,21 +271,20 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
280 break; 271 break;
281 } 272 }
282 273
283 return_VOID; 274 return;
284} 275}
285 276
286static acpi_status acpi_button_notify_fixed(void *data) 277static acpi_status acpi_button_notify_fixed(void *data)
287{ 278{
288 struct acpi_button *button = (struct acpi_button *)data; 279 struct acpi_button *button = (struct acpi_button *)data;
289 280
290 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
291 281
292 if (!button) 282 if (!button)
293 return_ACPI_STATUS(AE_BAD_PARAMETER); 283 return AE_BAD_PARAMETER;
294 284
295 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); 285 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
296 286
297 return_ACPI_STATUS(AE_OK); 287 return AE_OK;
298} 288}
299 289
300static int acpi_button_add(struct acpi_device *device) 290static int acpi_button_add(struct acpi_device *device)
@@ -303,14 +293,13 @@ static int acpi_button_add(struct acpi_device *device)
303 acpi_status status = AE_OK; 293 acpi_status status = AE_OK;
304 struct acpi_button *button = NULL; 294 struct acpi_button *button = NULL;
305 295
306 ACPI_FUNCTION_TRACE("acpi_button_add");
307 296
308 if (!device) 297 if (!device)
309 return_VALUE(-EINVAL); 298 return -EINVAL;
310 299
311 button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); 300 button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL);
312 if (!button) 301 if (!button)
313 return_VALUE(-ENOMEM); 302 return -ENOMEM;
314 memset(button, 0, sizeof(struct acpi_button)); 303 memset(button, 0, sizeof(struct acpi_button));
315 304
316 button->device = device; 305 button->device = device;
@@ -349,8 +338,8 @@ static int acpi_button_add(struct acpi_device *device)
349 sprintf(acpi_device_class(device), "%s/%s", 338 sprintf(acpi_device_class(device), "%s/%s",
350 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); 339 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
351 } else { 340 } else {
352 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", 341 printk(KERN_ERR PREFIX "Unsupported hid [%s]\n",
353 acpi_device_hid(device))); 342 acpi_device_hid(device));
354 result = -ENODEV; 343 result = -ENODEV;
355 goto end; 344 goto end;
356 } 345 }
@@ -381,8 +370,6 @@ static int acpi_button_add(struct acpi_device *device)
381 } 370 }
382 371
383 if (ACPI_FAILURE(status)) { 372 if (ACPI_FAILURE(status)) {
384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
385 "Error installing notify handler\n"));
386 result = -ENODEV; 373 result = -ENODEV;
387 goto end; 374 goto end;
388 } 375 }
@@ -406,7 +393,7 @@ static int acpi_button_add(struct acpi_device *device)
406 kfree(button); 393 kfree(button);
407 } 394 }
408 395
409 return_VALUE(result); 396 return result;
410} 397}
411 398
412static int acpi_button_remove(struct acpi_device *device, int type) 399static int acpi_button_remove(struct acpi_device *device, int type)
@@ -414,10 +401,9 @@ static int acpi_button_remove(struct acpi_device *device, int type)
414 acpi_status status = 0; 401 acpi_status status = 0;
415 struct acpi_button *button = NULL; 402 struct acpi_button *button = NULL;
416 403
417 ACPI_FUNCTION_TRACE("acpi_button_remove");
418 404
419 if (!device || !acpi_driver_data(device)) 405 if (!device || !acpi_driver_data(device))
420 return_VALUE(-EINVAL); 406 return -EINVAL;
421 407
422 button = acpi_driver_data(device); 408 button = acpi_driver_data(device);
423 409
@@ -440,39 +426,33 @@ static int acpi_button_remove(struct acpi_device *device, int type)
440 break; 426 break;
441 } 427 }
442 428
443 if (ACPI_FAILURE(status))
444 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
445 "Error removing notify handler\n"));
446
447 acpi_button_remove_fs(device); 429 acpi_button_remove_fs(device);
448 430
449 kfree(button); 431 kfree(button);
450 432
451 return_VALUE(0); 433 return 0;
452} 434}
453 435
454static int __init acpi_button_init(void) 436static int __init acpi_button_init(void)
455{ 437{
456 int result = 0; 438 int result = 0;
457 439
458 ACPI_FUNCTION_TRACE("acpi_button_init");
459 440
460 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); 441 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
461 if (!acpi_button_dir) 442 if (!acpi_button_dir)
462 return_VALUE(-ENODEV); 443 return -ENODEV;
463 acpi_button_dir->owner = THIS_MODULE; 444 acpi_button_dir->owner = THIS_MODULE;
464 result = acpi_bus_register_driver(&acpi_button_driver); 445 result = acpi_bus_register_driver(&acpi_button_driver);
465 if (result < 0) { 446 if (result < 0) {
466 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 447 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
467 return_VALUE(-ENODEV); 448 return -ENODEV;
468 } 449 }
469 450
470 return_VALUE(0); 451 return 0;
471} 452}
472 453
473static void __exit acpi_button_exit(void) 454static void __exit acpi_button_exit(void)
474{ 455{
475 ACPI_FUNCTION_TRACE("acpi_button_exit");
476 456
477 acpi_bus_unregister_driver(&acpi_button_driver); 457 acpi_bus_unregister_driver(&acpi_button_driver);
478 458
@@ -484,7 +464,7 @@ static void __exit acpi_button_exit(void)
484 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 464 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
485 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 465 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
486 466
487 return_VOID; 467 return;
488} 468}
489 469
490module_init(acpi_button_init); 470module_init(acpi_button_init);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index b69a8cad82b7..7f7e41d40a3b 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -73,17 +73,16 @@ static int is_device_present(acpi_handle handle)
73 acpi_status status; 73 acpi_status status;
74 unsigned long sta; 74 unsigned long sta;
75 75
76 ACPI_FUNCTION_TRACE("is_device_present");
77 76
78 status = acpi_get_handle(handle, "_STA", &temp); 77 status = acpi_get_handle(handle, "_STA", &temp);
79 if (ACPI_FAILURE(status)) 78 if (ACPI_FAILURE(status))
80 return_VALUE(1); /* _STA not found, assmue device present */ 79 return 1; /* _STA not found, assmue device present */
81 80
82 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 81 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
83 if (ACPI_FAILURE(status)) 82 if (ACPI_FAILURE(status))
84 return_VALUE(0); /* Firmware error */ 83 return 0; /* Firmware error */
85 84
86 return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); 85 return ((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
87} 86}
88 87
89/*******************************************************************/ 88/*******************************************************************/
@@ -91,16 +90,15 @@ static int acpi_container_add(struct acpi_device *device)
91{ 90{
92 struct acpi_container *container; 91 struct acpi_container *container;
93 92
94 ACPI_FUNCTION_TRACE("acpi_container_add");
95 93
96 if (!device) { 94 if (!device) {
97 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "device is NULL\n")); 95 printk(KERN_ERR PREFIX "device is NULL\n");
98 return_VALUE(-EINVAL); 96 return -EINVAL;
99 } 97 }
100 98
101 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); 99 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
102 if (!container) 100 if (!container)
103 return_VALUE(-ENOMEM); 101 return -ENOMEM;
104 102
105 memset(container, 0, sizeof(struct acpi_container)); 103 memset(container, 0, sizeof(struct acpi_container));
106 container->handle = device->handle; 104 container->handle = device->handle;
@@ -111,7 +109,7 @@ static int acpi_container_add(struct acpi_device *device)
111 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", 109 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
112 acpi_device_name(device), acpi_device_bid(device))); 110 acpi_device_name(device), acpi_device_bid(device)));
113 111
114 return_VALUE(0); 112 return 0;
115} 113}
116 114
117static int acpi_container_remove(struct acpi_device *device, int type) 115static int acpi_container_remove(struct acpi_device *device, int type)
@@ -130,23 +128,22 @@ static int container_device_add(struct acpi_device **device, acpi_handle handle)
130 struct acpi_device *pdev; 128 struct acpi_device *pdev;
131 int result; 129 int result;
132 130
133 ACPI_FUNCTION_TRACE("container_device_add");
134 131
135 if (acpi_get_parent(handle, &phandle)) { 132 if (acpi_get_parent(handle, &phandle)) {
136 return_VALUE(-ENODEV); 133 return -ENODEV;
137 } 134 }
138 135
139 if (acpi_bus_get_device(phandle, &pdev)) { 136 if (acpi_bus_get_device(phandle, &pdev)) {
140 return_VALUE(-ENODEV); 137 return -ENODEV;
141 } 138 }
142 139
143 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) { 140 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) {
144 return_VALUE(-ENODEV); 141 return -ENODEV;
145 } 142 }
146 143
147 result = acpi_bus_start(*device); 144 result = acpi_bus_start(*device);
148 145
149 return_VALUE(result); 146 return result;
150} 147}
151 148
152static void container_notify_cb(acpi_handle handle, u32 type, void *context) 149static void container_notify_cb(acpi_handle handle, u32 type, void *context)
@@ -156,7 +153,6 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
156 int present; 153 int present;
157 acpi_status status; 154 acpi_status status;
158 155
159 ACPI_FUNCTION_TRACE("container_notify_cb");
160 156
161 present = is_device_present(handle); 157 present = is_device_present(handle);
162 158
@@ -192,7 +188,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
192 default: 188 default:
193 break; 189 break;
194 } 190 }
195 return_VOID; 191 return;
196} 192}
197 193
198static acpi_status 194static acpi_status
@@ -205,11 +201,10 @@ container_walk_namespace_cb(acpi_handle handle,
205 acpi_status status; 201 acpi_status status;
206 int *action = context; 202 int *action = context;
207 203
208 ACPI_FUNCTION_TRACE("container_walk_namespace_cb");
209 204
210 status = acpi_get_object_info(handle, &buffer); 205 status = acpi_get_object_info(handle, &buffer);
211 if (ACPI_FAILURE(status) || !buffer.pointer) { 206 if (ACPI_FAILURE(status) || !buffer.pointer) {
212 return_ACPI_STATUS(AE_OK); 207 return AE_OK;
213 } 208 }
214 209
215 info = buffer.pointer; 210 info = buffer.pointer;
@@ -243,7 +238,7 @@ container_walk_namespace_cb(acpi_handle handle,
243 end: 238 end:
244 acpi_os_free(buffer.pointer); 239 acpi_os_free(buffer.pointer);
245 240
246 return_ACPI_STATUS(AE_OK); 241 return AE_OK;
247} 242}
248 243
249static int __init acpi_container_init(void) 244static int __init acpi_container_init(void)
@@ -269,7 +264,6 @@ static void __exit acpi_container_exit(void)
269{ 264{
270 int action = UNINSTALL_NOTIFY_HANDLER; 265 int action = UNINSTALL_NOTIFY_HANDLER;
271 266
272 ACPI_FUNCTION_TRACE("acpi_container_exit");
273 267
274 acpi_walk_namespace(ACPI_TYPE_DEVICE, 268 acpi_walk_namespace(ACPI_TYPE_DEVICE,
275 ACPI_ROOT_OBJECT, 269 ACPI_ROOT_OBJECT,
@@ -278,7 +272,7 @@ static void __exit acpi_container_exit(void)
278 272
279 acpi_bus_unregister_driver(&acpi_container_driver); 273 acpi_bus_unregister_driver(&acpi_container_driver);
280 274
281 return_VOID; 275 return;
282} 276}
283 277
284module_init(acpi_container_init); 278module_init(acpi_container_init);
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index 263322b7d113..35c6af8a83cd 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -155,13 +155,12 @@ acpi_system_write_debug(struct file *file,
155{ 155{
156 char debug_string[12] = { '\0' }; 156 char debug_string[12] = { '\0' };
157 157
158 ACPI_FUNCTION_TRACE("acpi_system_write_debug");
159 158
160 if (count > sizeof(debug_string) - 1) 159 if (count > sizeof(debug_string) - 1)
161 return_VALUE(-EINVAL); 160 return -EINVAL;
162 161
163 if (copy_from_user(debug_string, buffer, count)) 162 if (copy_from_user(debug_string, buffer, count))
164 return_VALUE(-EFAULT); 163 return -EFAULT;
165 164
166 debug_string[count] = '\0'; 165 debug_string[count] = '\0';
167 166
@@ -173,10 +172,10 @@ acpi_system_write_debug(struct file *file,
173 acpi_dbg_level = simple_strtoul(debug_string, NULL, 0); 172 acpi_dbg_level = simple_strtoul(debug_string, NULL, 0);
174 break; 173 break;
175 default: 174 default:
176 return_VALUE(-EINVAL); 175 return -EINVAL;
177 } 176 }
178 177
179 return_VALUE(count); 178 return count;
180} 179}
181 180
182static int __init acpi_debug_init(void) 181static int __init acpi_debug_init(void)
@@ -185,10 +184,9 @@ static int __init acpi_debug_init(void)
185 int error = 0; 184 int error = 0;
186 char *name; 185 char *name;
187 186
188 ACPI_FUNCTION_TRACE("acpi_debug_init");
189 187
190 if (acpi_disabled) 188 if (acpi_disabled)
191 return_VALUE(0); 189 return 0;
192 190
193 /* 'debug_layer' [R/W] */ 191 /* 'debug_layer' [R/W] */
194 name = ACPI_SYSTEM_FILE_DEBUG_LAYER; 192 name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
@@ -213,15 +211,12 @@ static int __init acpi_debug_init(void)
213 goto Error; 211 goto Error;
214 212
215 Done: 213 Done:
216 return_VALUE(error); 214 return error;
217 215
218 Error: 216 Error:
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
220 "Unable to create '%s' proc fs entry\n", name));
221
222 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir); 217 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
223 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); 218 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);
224 error = -EFAULT; 219 error = -ENODEV;
225 goto Done; 220 goto Done;
226} 221}
227 222
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index bbdf990e9f65..daf51b5b5875 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -125,37 +125,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
125 if (info->table_desc->pointer->revision == 1) { 125 if (info->table_desc->pointer->revision == 1) {
126 node->flags |= ANOBJ_DATA_WIDTH_32; 126 node->flags |= ANOBJ_DATA_WIDTH_32;
127 } 127 }
128#ifdef ACPI_INIT_PARSE_METHODS
129 /*
130 * Note 11/2005: Removed this code to parse all methods during table
131 * load because it causes problems if there are any errors during the
132 * parse. Also, it seems like overkill and we probably don't want to
133 * abort a table load because of an issue with a single method.
134 */
135
136 /*
137 * Print a dot for each method unless we are going to print
138 * the entire pathname
139 */
140 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
141 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
142 }
143 128
144 /*
145 * Always parse methods to detect errors, we will delete
146 * the parse tree below
147 */
148 status = acpi_ds_parse_method(obj_handle);
149 if (ACPI_FAILURE(status)) {
150 ACPI_ERROR((AE_INFO,
151 "Method %p [%4.4s] - parse failure, %s",
152 obj_handle,
153 acpi_ut_get_node_name(obj_handle),
154 acpi_format_exception(status)));
155
156 /* This parse failed, but we will continue parsing more methods */
157 }
158#endif
159 info->method_count++; 129 info->method_count++;
160 break; 130 break;
161 131
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index bc9aca4e7401..a39a33f4847a 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -52,6 +52,10 @@
52#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
53ACPI_MODULE_NAME("dsmethod") 53ACPI_MODULE_NAME("dsmethod")
54 54
55/* Local prototypes */
56static acpi_status
57acpi_ds_create_method_mutex(union acpi_operand_object *method_desc);
58
55/******************************************************************************* 59/*******************************************************************************
56 * 60 *
57 * FUNCTION: acpi_ds_method_error 61 * FUNCTION: acpi_ds_method_error
@@ -67,6 +71,7 @@ ACPI_MODULE_NAME("dsmethod")
67 * Note: Allows the exception handler to change the status code 71 * Note: Allows the exception handler to change the status code
68 * 72 *
69 ******************************************************************************/ 73 ******************************************************************************/
74
70acpi_status 75acpi_status
71acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) 76acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
72{ 77{
@@ -113,11 +118,51 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
113 118
114/******************************************************************************* 119/*******************************************************************************
115 * 120 *
121 * FUNCTION: acpi_ds_create_method_mutex
122 *
123 * PARAMETERS: obj_desc - The method object
124 *
125 * RETURN: Status
126 *
127 * DESCRIPTION: Create a mutex object for a serialized control method
128 *
129 ******************************************************************************/
130
131static acpi_status
132acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
133{
134 union acpi_operand_object *mutex_desc;
135 acpi_status status;
136
137 ACPI_FUNCTION_NAME(ds_create_method_mutex);
138
139 /* Create the new mutex object */
140
141 mutex_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);
142 if (!mutex_desc) {
143 return_ACPI_STATUS(AE_NO_MEMORY);
144 }
145
146 /* Create the actual OS Mutex */
147
148 status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex);
149 if (ACPI_FAILURE(status)) {
150 return_ACPI_STATUS(status);
151 }
152
153 mutex_desc->mutex.sync_level = method_desc->method.sync_level;
154 method_desc->method.mutex = mutex_desc;
155 return_ACPI_STATUS(AE_OK);
156}
157
158/*******************************************************************************
159 *
116 * FUNCTION: acpi_ds_begin_method_execution 160 * FUNCTION: acpi_ds_begin_method_execution
117 * 161 *
118 * PARAMETERS: method_node - Node of the method 162 * PARAMETERS: method_node - Node of the method
119 * obj_desc - The method object 163 * obj_desc - The method object
120 * calling_method_node - Caller of this method (if non-null) 164 * walk_state - current state, NULL if not yet executing
165 * a method.
121 * 166 *
122 * RETURN: Status 167 * RETURN: Status
123 * 168 *
@@ -128,9 +173,9 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
128 ******************************************************************************/ 173 ******************************************************************************/
129 174
130acpi_status 175acpi_status
131acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node, 176acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
132 union acpi_operand_object * obj_desc, 177 union acpi_operand_object *obj_desc,
133 struct acpi_namespace_node * calling_method_node) 178 struct acpi_walk_state *walk_state)
134{ 179{
135 acpi_status status = AE_OK; 180 acpi_status status = AE_OK;
136 181
@@ -149,35 +194,80 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
149 } 194 }
150 195
151 /* 196 /*
152 * If there is a concurrency limit on this method, we need to 197 * If this method is serialized, we need to acquire the method mutex.
153 * obtain a unit from the method semaphore.
154 */ 198 */
155 if (obj_desc->method.semaphore) { 199 if (obj_desc->method.method_flags & AML_METHOD_SERIALIZED) {
156 /* 200 /*
157 * Allow recursive method calls, up to the reentrancy/concurrency 201 * Create a mutex for the method if it is defined to be Serialized
158 * limit imposed by the SERIALIZED rule and the sync_level method 202 * and a mutex has not already been created. We defer the mutex creation
159 * parameter. 203 * until a method is actually executed, to minimize the object count
160 *
161 * The point of this code is to avoid permanently blocking a
162 * thread that is making recursive method calls.
163 */ 204 */
164 if (method_node == calling_method_node) { 205 if (!obj_desc->method.mutex) {
165 if (obj_desc->method.thread_count >= 206 status = acpi_ds_create_method_mutex(obj_desc);
166 obj_desc->method.concurrency) { 207 if (ACPI_FAILURE(status)) {
167 return_ACPI_STATUS(AE_AML_METHOD_LIMIT); 208 return_ACPI_STATUS(status);
168 } 209 }
169 } 210 }
170 211
171 /* 212 /*
172 * Get a unit from the method semaphore. This releases the 213 * The current_sync_level (per-thread) must be less than or equal to
173 * interpreter if we block (then reacquires it) 214 * the sync level of the method. This mechanism provides some
215 * deadlock prevention
216 *
217 * Top-level method invocation has no walk state at this point
174 */ 218 */
175 status = 219 if (walk_state &&
176 acpi_ex_system_wait_semaphore(obj_desc->method.semaphore, 220 (walk_state->thread->current_sync_level >
177 ACPI_WAIT_FOREVER); 221 obj_desc->method.mutex->mutex.sync_level)) {
178 if (ACPI_FAILURE(status)) { 222 ACPI_ERROR((AE_INFO,
179 return_ACPI_STATUS(status); 223 "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)",
224 acpi_ut_get_node_name(method_node),
225 walk_state->thread->current_sync_level));
226
227 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
180 } 228 }
229
230 /*
231 * Obtain the method mutex if necessary. Do not acquire mutex for a
232 * recursive call.
233 */
234 if (!walk_state ||
235 !obj_desc->method.mutex->mutex.owner_thread ||
236 (walk_state->thread !=
237 obj_desc->method.mutex->mutex.owner_thread)) {
238 /*
239 * Acquire the method mutex. This releases the interpreter if we
240 * block (and reacquires it before it returns)
241 */
242 status =
243 acpi_ex_system_wait_mutex(obj_desc->method.mutex->
244 mutex.os_mutex,
245 ACPI_WAIT_FOREVER);
246 if (ACPI_FAILURE(status)) {
247 return_ACPI_STATUS(status);
248 }
249
250 /* Update the mutex and walk info and save the original sync_level */
251
252 if (walk_state) {
253 obj_desc->method.mutex->mutex.
254 original_sync_level =
255 walk_state->thread->current_sync_level;
256
257 obj_desc->method.mutex->mutex.owner_thread =
258 walk_state->thread;
259 walk_state->thread->current_sync_level =
260 obj_desc->method.sync_level;
261 } else {
262 obj_desc->method.mutex->mutex.
263 original_sync_level =
264 obj_desc->method.mutex->mutex.sync_level;
265 }
266 }
267
268 /* Always increase acquisition depth */
269
270 obj_desc->method.mutex->mutex.acquisition_depth++;
181 } 271 }
182 272
183 /* 273 /*
@@ -200,10 +290,10 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
200 return_ACPI_STATUS(status); 290 return_ACPI_STATUS(status);
201 291
202 cleanup: 292 cleanup:
203 /* On error, must signal the method semaphore if present */ 293 /* On error, must release the method mutex (if present) */
204 294
205 if (obj_desc->method.semaphore) { 295 if (obj_desc->method.mutex) {
206 (void)acpi_os_signal_semaphore(obj_desc->method.semaphore, 1); 296 acpi_os_release_mutex(obj_desc->method.mutex->mutex.os_mutex);
207 } 297 }
208 return_ACPI_STATUS(status); 298 return_ACPI_STATUS(status);
209} 299}
@@ -253,10 +343,10 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
253 return_ACPI_STATUS(AE_NULL_OBJECT); 343 return_ACPI_STATUS(AE_NULL_OBJECT);
254 } 344 }
255 345
256 /* Init for new method, possibly wait on concurrency semaphore */ 346 /* Init for new method, possibly wait on method mutex */
257 347
258 status = acpi_ds_begin_method_execution(method_node, obj_desc, 348 status = acpi_ds_begin_method_execution(method_node, obj_desc,
259 this_walk_state->method_node); 349 this_walk_state);
260 if (ACPI_FAILURE(status)) { 350 if (ACPI_FAILURE(status)) {
261 return_ACPI_STATUS(status); 351 return_ACPI_STATUS(status);
262 } 352 }
@@ -478,6 +568,8 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
478 * created, delete all locals and arguments, and delete the parse 568 * created, delete all locals and arguments, and delete the parse
479 * tree if requested. 569 * tree if requested.
480 * 570 *
571 * MUTEX: Interpreter is locked
572 *
481 ******************************************************************************/ 573 ******************************************************************************/
482 574
483void 575void
@@ -503,26 +595,21 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
503 } 595 }
504 596
505 /* 597 /*
506 * Lock the parser while we terminate this method. 598 * If method is serialized, release the mutex and restore the
507 * If this is the last thread executing the method, 599 * current sync level for this thread
508 * we have additional cleanup to perform
509 */ 600 */
510 status = acpi_ut_acquire_mutex(ACPI_MTX_CONTROL_METHOD); 601 if (method_desc->method.mutex) {
511 if (ACPI_FAILURE(status)) {
512 return_VOID;
513 }
514 602
515 /* Signal completion of the execution of this method if necessary */ 603 /* Acquisition Depth handles recursive calls */
516 604
517 if (method_desc->method.semaphore) { 605 method_desc->method.mutex->mutex.acquisition_depth--;
518 status = 606 if (!method_desc->method.mutex->mutex.acquisition_depth) {
519 acpi_os_signal_semaphore(method_desc->method.semaphore, 1); 607 walk_state->thread->current_sync_level =
520 if (ACPI_FAILURE(status)) { 608 method_desc->method.mutex->mutex.
521 609 original_sync_level;
522 /* Ignore error and continue */
523 610
524 ACPI_EXCEPTION((AE_INFO, status, 611 acpi_os_release_mutex(method_desc->method.mutex->mutex.
525 "Could not signal method semaphore")); 612 os_mutex);
526 } 613 }
527 } 614 }
528 615
@@ -537,7 +624,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
537 624
538 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 625 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
539 if (ACPI_FAILURE(status)) { 626 if (ACPI_FAILURE(status)) {
540 goto exit; 627 return_VOID;
541 } 628 }
542 629
543 /* 630 /*
@@ -580,18 +667,16 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
580 /* 667 /*
581 * Support to dynamically change a method from not_serialized to 668 * Support to dynamically change a method from not_serialized to
582 * Serialized if it appears that the method is incorrectly written and 669 * Serialized if it appears that the method is incorrectly written and
583 * does not support multiple thread execution. The best example of this 670 * does not support multiple thread execution. The best example of this
584 * is if such a method creates namespace objects and blocks. A second 671 * is if such a method creates namespace objects and blocks. A second
585 * thread will fail with an AE_ALREADY_EXISTS exception 672 * thread will fail with an AE_ALREADY_EXISTS exception
586 * 673 *
587 * This code is here because we must wait until the last thread exits 674 * This code is here because we must wait until the last thread exits
588 * before creating the synchronization semaphore. 675 * before creating the synchronization semaphore.
589 */ 676 */
590 if ((method_desc->method.concurrency == 1) && 677 if ((method_desc->method.method_flags & AML_METHOD_SERIALIZED)
591 (!method_desc->method.semaphore)) { 678 && (!method_desc->method.mutex)) {
592 status = acpi_os_create_semaphore(1, 1, 679 status = acpi_ds_create_method_mutex(method_desc);
593 &method_desc->method.
594 semaphore);
595 } 680 }
596 681
597 /* No more threads, we can free the owner_id */ 682 /* No more threads, we can free the owner_id */
@@ -599,144 +684,5 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
599 acpi_ut_release_owner_id(&method_desc->method.owner_id); 684 acpi_ut_release_owner_id(&method_desc->method.owner_id);
600 } 685 }
601 686
602 exit:
603 (void)acpi_ut_release_mutex(ACPI_MTX_CONTROL_METHOD);
604 return_VOID; 687 return_VOID;
605} 688}
606
607#ifdef ACPI_INIT_PARSE_METHODS
608 /*
609 * Note 11/2005: Removed this code to parse all methods during table
610 * load because it causes problems if there are any errors during the
611 * parse. Also, it seems like overkill and we probably don't want to
612 * abort a table load because of an issue with a single method.
613 */
614
615/*******************************************************************************
616 *
617 * FUNCTION: acpi_ds_parse_method
618 *
619 * PARAMETERS: Node - Method node
620 *
621 * RETURN: Status
622 *
623 * DESCRIPTION: Parse the AML that is associated with the method.
624 *
625 * MUTEX: Assumes parser is locked
626 *
627 ******************************************************************************/
628
629acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
630{
631 acpi_status status;
632 union acpi_operand_object *obj_desc;
633 union acpi_parse_object *op;
634 struct acpi_walk_state *walk_state;
635
636 ACPI_FUNCTION_TRACE_PTR(ds_parse_method, node);
637
638 /* Parameter Validation */
639
640 if (!node) {
641 return_ACPI_STATUS(AE_NULL_ENTRY);
642 }
643
644 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
645 "**** Parsing [%4.4s] **** NamedObj=%p\n",
646 acpi_ut_get_node_name(node), node));
647
648 /* Extract the method object from the method Node */
649
650 obj_desc = acpi_ns_get_attached_object(node);
651 if (!obj_desc) {
652 return_ACPI_STATUS(AE_NULL_OBJECT);
653 }
654
655 /* Create a mutex for the method if there is a concurrency limit */
656
657 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
658 (!obj_desc->method.semaphore)) {
659 status = acpi_os_create_semaphore(obj_desc->method.concurrency,
660 obj_desc->method.concurrency,
661 &obj_desc->method.semaphore);
662 if (ACPI_FAILURE(status)) {
663 return_ACPI_STATUS(status);
664 }
665 }
666
667 /*
668 * Allocate a new parser op to be the root of the parsed
669 * method tree
670 */
671 op = acpi_ps_alloc_op(AML_METHOD_OP);
672 if (!op) {
673 return_ACPI_STATUS(AE_NO_MEMORY);
674 }
675
676 /* Init new op with the method name and pointer back to the Node */
677
678 acpi_ps_set_name(op, node->name.integer);
679 op->common.node = node;
680
681 /*
682 * Get a new owner_id for objects created by this method. Namespace
683 * objects (such as Operation Regions) can be created during the
684 * first pass parse.
685 */
686 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
687 if (ACPI_FAILURE(status)) {
688 goto cleanup;
689 }
690
691 /* Create and initialize a new walk state */
692
693 walk_state =
694 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
695 NULL);
696 if (!walk_state) {
697 status = AE_NO_MEMORY;
698 goto cleanup2;
699 }
700
701 status = acpi_ds_init_aml_walk(walk_state, op, node,
702 obj_desc->method.aml_start,
703 obj_desc->method.aml_length, NULL, 1);
704 if (ACPI_FAILURE(status)) {
705 acpi_ds_delete_walk_state(walk_state);
706 goto cleanup2;
707 }
708
709 /*
710 * Parse the method, first pass
711 *
712 * The first pass load is where newly declared named objects are added into
713 * the namespace. Actual evaluation of the named objects (what would be
714 * called a "second pass") happens during the actual execution of the
715 * method so that operands to the named objects can take on dynamic
716 * run-time values.
717 */
718 status = acpi_ps_parse_aml(walk_state);
719 if (ACPI_FAILURE(status)) {
720 goto cleanup2;
721 }
722
723 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
724 "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n",
725 acpi_ut_get_node_name(node), node, op));
726
727 /*
728 * Delete the parse tree. We simply re-parse the method for every
729 * execution since there isn't much overhead (compared to keeping lots
730 * of parse trees around)
731 */
732 acpi_ns_delete_namespace_subtree(node);
733 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
734
735 cleanup2:
736 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
737
738 cleanup:
739 acpi_ps_delete_parse_tree(op);
740 return_ACPI_STATUS(status);
741}
742#endif
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index 3acbd9145d72..b1ded62d0df1 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -472,7 +472,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
472 acpi_ds_result_push(walk_state->result_obj, 472 acpi_ds_result_push(walk_state->result_obj,
473 walk_state); 473 walk_state);
474 } 474 }
475
476 break; 475 break;
477 476
478 default: 477 default:
@@ -510,6 +509,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
510 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 509 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
511 "Method Reference in a Package, Op=%p\n", 510 "Method Reference in a Package, Op=%p\n",
512 op)); 511 op));
512
513 op->common.node = 513 op->common.node =
514 (struct acpi_namespace_node *)op->asl.value. 514 (struct acpi_namespace_node *)op->asl.value.
515 arg->asl.node->object; 515 arg->asl.node->object;
@@ -670,7 +670,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
670 670
671 status = acpi_ds_result_stack_pop(walk_state); 671 status = acpi_ds_result_stack_pop(walk_state);
672 } 672 }
673
674 break; 673 break;
675 674
676 case AML_TYPE_UNDEFINED: 675 case AML_TYPE_UNDEFINED:
@@ -708,7 +707,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
708 * Check if we just completed the evaluation of a 707 * Check if we just completed the evaluation of a
709 * conditional predicate 708 * conditional predicate
710 */ 709 */
711
712 if ((ACPI_SUCCESS(status)) && 710 if ((ACPI_SUCCESS(status)) &&
713 (walk_state->control_state) && 711 (walk_state->control_state) &&
714 (walk_state->control_state->common.state == 712 (walk_state->control_state->common.state ==
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 35074399c617..e3ca7f6539c1 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -175,7 +175,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
175 if (status == AE_NOT_FOUND) { 175 if (status == AE_NOT_FOUND) {
176 /* 176 /*
177 * Table disassembly: 177 * Table disassembly:
178 * Target of Scope() not found. Generate an External for it, and 178 * Target of Scope() not found. Generate an External for it, and
179 * insert the name into the namespace. 179 * insert the name into the namespace.
180 */ 180 */
181 acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0); 181 acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0);
@@ -210,16 +210,15 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
210 case ACPI_TYPE_BUFFER: 210 case ACPI_TYPE_BUFFER:
211 211
212 /* 212 /*
213 * These types we will allow, but we will change the type. This 213 * These types we will allow, but we will change the type. This
214 * enables some existing code of the form: 214 * enables some existing code of the form:
215 * 215 *
216 * Name (DEB, 0) 216 * Name (DEB, 0)
217 * Scope (DEB) { ... } 217 * Scope (DEB) { ... }
218 * 218 *
219 * Note: silently change the type here. On the second pass, we will report 219 * Note: silently change the type here. On the second pass, we will report
220 * a warning 220 * a warning
221 */ 221 */
222
223 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 222 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
224 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 223 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
225 path, 224 path,
@@ -242,7 +241,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
242 break; 241 break;
243 242
244 default: 243 default:
245
246 /* 244 /*
247 * For all other named opcodes, we will enter the name into 245 * For all other named opcodes, we will enter the name into
248 * the namespace. 246 * the namespace.
@@ -259,7 +257,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
259 * buffer_field, or Package), the name of the object is already 257 * buffer_field, or Package), the name of the object is already
260 * in the namespace. 258 * in the namespace.
261 */ 259 */
262
263 if (walk_state->deferred_node) { 260 if (walk_state->deferred_node) {
264 261
265 /* This name is already in the namespace, get the node */ 262 /* This name is already in the namespace, get the node */
@@ -293,8 +290,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
293 } 290 }
294 291
295 /* 292 /*
296 * Enter the named type into the internal namespace. We enter the name 293 * Enter the named type into the internal namespace. We enter the name
297 * as we go downward in the parse tree. Any necessary subobjects that 294 * as we go downward in the parse tree. Any necessary subobjects that
298 * involve arguments to the opcode must be created as we go back up the 295 * involve arguments to the opcode must be created as we go back up the
299 * parse tree later. 296 * parse tree later.
300 */ 297 */
@@ -327,12 +324,12 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
327 (status); 324 (status);
328 } 325 }
329 } 326 }
327
330 status = AE_OK; 328 status = AE_OK;
331 } 329 }
332 } 330 }
333 331
334 if (ACPI_FAILURE(status)) { 332 if (ACPI_FAILURE(status)) {
335
336 ACPI_ERROR_NAMESPACE(path, status); 333 ACPI_ERROR_NAMESPACE(path, status);
337 return_ACPI_STATUS(status); 334 return_ACPI_STATUS(status);
338 } 335 }
@@ -434,9 +431,13 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
434 status = 431 status =
435 acpi_ex_create_region(op->named.data, 432 acpi_ex_create_region(op->named.data,
436 op->named.length, 433 op->named.length,
437 (acpi_adr_space_type) 434 (acpi_adr_space_type) ((op->
438 ((op->common.value.arg)-> 435 common.
439 common.value.integer), 436 value.
437 arg)->
438 common.
439 value.
440 integer),
440 walk_state); 441 walk_state);
441 if (ACPI_FAILURE(status)) { 442 if (ACPI_FAILURE(status)) {
442 return_ACPI_STATUS(status); 443 return_ACPI_STATUS(status);
@@ -474,7 +475,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
474 * method_op pkg_length name_string method_flags term_list 475 * method_op pkg_length name_string method_flags term_list
475 * 476 *
476 * Note: We must create the method node/object pair as soon as we 477 * Note: We must create the method node/object pair as soon as we
477 * see the method declaration. This allows later pass1 parsing 478 * see the method declaration. This allows later pass1 parsing
478 * of invocations of the method (need to know the number of 479 * of invocations of the method (need to know the number of
479 * arguments.) 480 * arguments.)
480 */ 481 */
@@ -499,6 +500,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
499 length, 500 length,
500 walk_state); 501 walk_state);
501 } 502 }
503
502 walk_state->operands[0] = NULL; 504 walk_state->operands[0] = NULL;
503 walk_state->num_operands = 0; 505 walk_state->num_operands = 0;
504 506
@@ -570,7 +572,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
570#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE 572#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
571 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || 573 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
572 (walk_state->op_info->class == AML_CLASS_CONTROL)) { 574 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
573
574 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 575 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
575 "Begin/EXEC: %s (fl %8.8X)\n", 576 "Begin/EXEC: %s (fl %8.8X)\n",
576 walk_state->op_info->name, 577 walk_state->op_info->name,
@@ -602,7 +603,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
602 } else { 603 } else {
603 /* Get name from the op */ 604 /* Get name from the op */
604 605
605 buffer_ptr = (char *)&op->named.name; 606 buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);
606 } 607 }
607 } else { 608 } else {
608 /* Get the namestring from the raw AML */ 609 /* Get the namestring from the raw AML */
@@ -629,7 +630,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
629 break; 630 break;
630 631
631 case AML_INT_NAMEPATH_OP: 632 case AML_INT_NAMEPATH_OP:
632
633 /* 633 /*
634 * The name_path is an object reference to an existing object. 634 * The name_path is an object reference to an existing object.
635 * Don't enter the name into the namespace, but look it up 635 * Don't enter the name into the namespace, but look it up
@@ -642,7 +642,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
642 break; 642 break;
643 643
644 case AML_SCOPE_OP: 644 case AML_SCOPE_OP:
645
646 /* 645 /*
647 * The Path is an object reference to an existing object. 646 * The Path is an object reference to an existing object.
648 * Don't enter the name into the namespace, but look it up 647 * Don't enter the name into the namespace, but look it up
@@ -664,6 +663,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
664#endif 663#endif
665 return_ACPI_STATUS(status); 664 return_ACPI_STATUS(status);
666 } 665 }
666
667 /* 667 /*
668 * We must check to make sure that the target is 668 * We must check to make sure that the target is
669 * one of the opcodes that actually opens a scope 669 * one of the opcodes that actually opens a scope
@@ -683,13 +683,12 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
683 case ACPI_TYPE_BUFFER: 683 case ACPI_TYPE_BUFFER:
684 684
685 /* 685 /*
686 * These types we will allow, but we will change the type. This 686 * These types we will allow, but we will change the type. This
687 * enables some existing code of the form: 687 * enables some existing code of the form:
688 * 688 *
689 * Name (DEB, 0) 689 * Name (DEB, 0)
690 * Scope (DEB) { ... } 690 * Scope (DEB) { ... }
691 */ 691 */
692
693 ACPI_WARNING((AE_INFO, 692 ACPI_WARNING((AE_INFO,
694 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", 693 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
695 buffer_ptr, 694 buffer_ptr,
@@ -729,14 +728,14 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
729 if (ACPI_FAILURE(status)) { 728 if (ACPI_FAILURE(status)) {
730 return_ACPI_STATUS(status); 729 return_ACPI_STATUS(status);
731 } 730 }
732
733 } 731 }
732
734 return_ACPI_STATUS(AE_OK); 733 return_ACPI_STATUS(AE_OK);
735 } 734 }
736 735
737 /* 736 /*
738 * Enter the named type into the internal namespace. We enter the name 737 * Enter the named type into the internal namespace. We enter the name
739 * as we go downward in the parse tree. Any necessary subobjects that 738 * as we go downward in the parse tree. Any necessary subobjects that
740 * involve arguments to the opcode must be created as we go back up the 739 * involve arguments to the opcode must be created as we go back up the
741 * parse tree later. 740 * parse tree later.
742 * 741 *
@@ -787,7 +786,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
787 * can get it again quickly when this scope is closed 786 * can get it again quickly when this scope is closed
788 */ 787 */
789 op->common.node = node; 788 op->common.node = node;
790
791 return_ACPI_STATUS(status); 789 return_ACPI_STATUS(status);
792} 790}
793 791
@@ -922,7 +920,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
922#ifndef ACPI_NO_METHOD_EXECUTION 920#ifndef ACPI_NO_METHOD_EXECUTION
923 921
924 case AML_TYPE_CREATE_FIELD: 922 case AML_TYPE_CREATE_FIELD:
925
926 /* 923 /*
927 * Create the field object, but the field buffer and index must 924 * Create the field object, but the field buffer and index must
928 * be evaluated later during the execution phase 925 * be evaluated later during the execution phase
@@ -931,7 +928,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
931 break; 928 break;
932 929
933 case AML_TYPE_NAMED_FIELD: 930 case AML_TYPE_NAMED_FIELD:
934
935 /* 931 /*
936 * If we are executing a method, initialize the field 932 * If we are executing a method, initialize the field
937 */ 933 */
@@ -1051,6 +1047,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1051 * argument is the space_id. (We must save the address of the 1047 * argument is the space_id. (We must save the address of the
1052 * AML of the address and length operands) 1048 * AML of the address and length operands)
1053 */ 1049 */
1050
1054 /* 1051 /*
1055 * If we have a valid region, initialize it 1052 * If we have a valid region, initialize it
1056 * Namespace is NOT locked at this point. 1053 * Namespace is NOT locked at this point.
@@ -1080,7 +1077,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1080 * method_op pkg_length name_string method_flags term_list 1077 * method_op pkg_length name_string method_flags term_list
1081 * 1078 *
1082 * Note: We must create the method node/object pair as soon as we 1079 * Note: We must create the method node/object pair as soon as we
1083 * see the method declaration. This allows later pass1 parsing 1080 * see the method declaration. This allows later pass1 parsing
1084 * of invocations of the method (need to know the number of 1081 * of invocations of the method (need to know the number of
1085 * arguments.) 1082 * arguments.)
1086 */ 1083 */
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
new file mode 100644
index 000000000000..510a94524298
--- /dev/null
+++ b/drivers/acpi/dock.c
@@ -0,0 +1,739 @@
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
35ACPI_MODULE_NAME("dock")
36MODULE_AUTHOR("Kristen Carlson Accardi");
37MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME);
38MODULE_LICENSE("GPL");
39
40static struct atomic_notifier_head dock_notifier_list;
41
42struct 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
52struct 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
64static 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 */
76static struct dock_dependent_device *
77alloc_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 */
97static void
98add_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 */
113static void
114dock_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 */
129static void
130dock_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 */
146static struct dock_dependent_device *
147find_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 */
172static 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 */
191int 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
202EXPORT_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 */
211static 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 */
237static 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 */
271static 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 */
294static 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
323static 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 */
339static 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 */
370static 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
396static inline void dock(struct dock_station *ds)
397{
398 handle_dock(ds, 1);
399}
400
401static inline void undock(struct dock_station *ds)
402{
403 handle_dock(ds, 0);
404}
405
406static inline void begin_dock(struct dock_station *ds)
407{
408 ds->flags |= DOCK_DOCKING;
409}
410
411static 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 */
425static 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 */
442int register_dock_notifier(struct notifier_block *nb)
443{
444 return atomic_notifier_chain_register(&dock_notifier_list, nb);
445}
446
447EXPORT_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 */
453void unregister_dock_notifier(struct notifier_block *nb)
454{
455 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
456}
457
458EXPORT_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 */
470int
471register_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
494EXPORT_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 */
500void 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
512EXPORT_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 */
526static 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 */
586static acpi_status
587find_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 */
614static 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
631 /* Find dependent devices */
632 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
633 ACPI_UINT32_MAX, find_dock_devices, dock_station,
634 NULL);
635
636 /* add the dock station as a device dependent on itself */
637 dd = alloc_dock_dependent_device(handle);
638 if (!dd) {
639 kfree(dock_station);
640 return -ENOMEM;
641 }
642 add_dock_dependent_device(dock_station, dd);
643
644 /* register for dock events */
645 status = acpi_install_notify_handler(dock_station->handle,
646 ACPI_SYSTEM_NOTIFY,
647 dock_notify, dock_station);
648
649 if (ACPI_FAILURE(status)) {
650 printk(KERN_ERR PREFIX "Error installing notify handler\n");
651 ret = -ENODEV;
652 goto dock_add_err;
653 }
654
655 printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME);
656
657 return 0;
658
659dock_add_err:
660 kfree(dock_station);
661 kfree(dd);
662 return ret;
663}
664
665/**
666 * dock_remove - free up resources related to the dock station
667 */
668static int dock_remove(void)
669{
670 struct dock_dependent_device *dd, *tmp;
671 acpi_status status;
672
673 if (!dock_station)
674 return 0;
675
676 /* remove dependent devices */
677 list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices,
678 list)
679 kfree(dd);
680
681 /* remove dock notify handler */
682 status = acpi_remove_notify_handler(dock_station->handle,
683 ACPI_SYSTEM_NOTIFY,
684 dock_notify);
685 if (ACPI_FAILURE(status))
686 printk(KERN_ERR "Error removing notify handler\n");
687
688 /* free dock station memory */
689 kfree(dock_station);
690 return 0;
691}
692
693/**
694 * find_dock - look for a dock station
695 * @handle: acpi handle of a device
696 * @lvl: unused
697 * @context: counter of dock stations found
698 * @rv: unused
699 *
700 * This is called by acpi_walk_namespace to look for dock stations.
701 */
702static acpi_status
703find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
704{
705 int *count = (int *)context;
706 acpi_status status = AE_OK;
707
708 if (is_dock(handle)) {
709 if (dock_add(handle) >= 0) {
710 (*count)++;
711 status = AE_CTRL_TERMINATE;
712 }
713 }
714 return status;
715}
716
717static int __init dock_init(void)
718{
719 int num = 0;
720
721 dock_station = NULL;
722
723 /* look for a dock station */
724 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
725 ACPI_UINT32_MAX, find_dock, &num, NULL);
726
727 if (!num)
728 return -ENODEV;
729
730 return 0;
731}
732
733static void __exit dock_exit(void)
734{
735 dock_remove();
736}
737
738postcore_initcall(dock_init);
739module_exit(dock_exit);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 18b3ea9dace2..8c5d7df7d343 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -207,16 +207,15 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
207{ 207{
208 int result = 0; 208 int result = 0;
209 209
210 ACPI_FUNCTION_TRACE("acpi_ec_wait");
211 210
212 ec->intr.expect_event = event; 211 ec->intr.expect_event = event;
213 smp_mb(); 212 smp_mb();
214 213
215 switch (event) { 214 switch (event) {
216 case ACPI_EC_EVENT_IBE: 215 case ACPI_EC_EVENT_IBE:
217 if (~acpi_ec_read_status(ec) & event) { 216 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) {
218 ec->intr.expect_event = 0; 217 ec->intr.expect_event = 0;
219 return_VALUE(0); 218 return 0;
220 } 219 }
221 break; 220 break;
222 default: 221 default:
@@ -238,16 +237,16 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
238 switch (event) { 237 switch (event) {
239 case ACPI_EC_EVENT_OBF: 238 case ACPI_EC_EVENT_OBF:
240 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF) 239 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
241 return_VALUE(0); 240 return 0;
242 break; 241 break;
243 242
244 case ACPI_EC_EVENT_IBE: 243 case ACPI_EC_EVENT_IBE:
245 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) 244 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
246 return_VALUE(0); 245 return 0;
247 break; 246 break;
248 } 247 }
249 248
250 return_VALUE(-ETIME); 249 return -ETIME;
251} 250}
252 251
253#ifdef ACPI_FUTURE_USAGE 252#ifdef ACPI_FUTURE_USAGE
@@ -260,7 +259,6 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec)
260 u32 tmp = 0; 259 u32 tmp = 0;
261 int status = 0; 260 int status = 0;
262 261
263 ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode");
264 262
265 status = acpi_ec_read_status(ec); 263 status = acpi_ec_read_status(ec);
266 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { 264 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
@@ -272,22 +270,21 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec)
272 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 270 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
273 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); 271 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
274 if (tmp != 0x90) { /* Burst ACK byte */ 272 if (tmp != 0x90) { /* Burst ACK byte */
275 return_VALUE(-EINVAL); 273 return -EINVAL;
276 } 274 }
277 } 275 }
278 276
279 atomic_set(&ec->intr.leaving_burst, 0); 277 atomic_set(&ec->intr.leaving_burst, 0);
280 return_VALUE(0); 278 return 0;
281 end: 279 end:
282 printk(KERN_WARNING PREFIX "Error in acpi_ec_wait\n"); 280 ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode");
283 return_VALUE(-1); 281 return -1;
284} 282}
285 283
286int acpi_ec_leave_burst_mode(union acpi_ec *ec) 284int acpi_ec_leave_burst_mode(union acpi_ec *ec)
287{ 285{
288 int status = 0; 286 int status = 0;
289 287
290 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
291 288
292 status = acpi_ec_read_status(ec); 289 status = acpi_ec_read_status(ec);
293 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ 290 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
@@ -298,10 +295,10 @@ int acpi_ec_leave_burst_mode(union acpi_ec *ec)
298 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 295 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
299 } 296 }
300 atomic_set(&ec->intr.leaving_burst, 1); 297 atomic_set(&ec->intr.leaving_burst, 1);
301 return_VALUE(0); 298 return 0;
302end: 299end:
303 printk(KERN_WARNING PREFIX "leave burst_mode:error\n"); 300 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode");
304 return_VALUE(-1); 301 return -1;
305} 302}
306#endif /* ACPI_FUTURE_USAGE */ 303#endif /* ACPI_FUTURE_USAGE */
307 304
@@ -325,17 +322,16 @@ static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data)
325 int result = 0; 322 int result = 0;
326 u32 glk = 0; 323 u32 glk = 0;
327 324
328 ACPI_FUNCTION_TRACE("acpi_ec_read");
329 325
330 if (!ec || !data) 326 if (!ec || !data)
331 return_VALUE(-EINVAL); 327 return -EINVAL;
332 328
333 *data = 0; 329 *data = 0;
334 330
335 if (ec->common.global_lock) { 331 if (ec->common.global_lock) {
336 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 332 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
337 if (ACPI_FAILURE(status)) 333 if (ACPI_FAILURE(status))
338 return_VALUE(-ENODEV); 334 return -ENODEV;
339 } 335 }
340 336
341 if (down_interruptible(&ec->poll.sem)) { 337 if (down_interruptible(&ec->poll.sem)) {
@@ -365,7 +361,7 @@ end_nosem:
365 if (ec->common.global_lock) 361 if (ec->common.global_lock)
366 acpi_release_global_lock(glk); 362 acpi_release_global_lock(glk);
367 363
368 return_VALUE(result); 364 return result;
369} 365}
370 366
371static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data) 367static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
@@ -374,15 +370,14 @@ static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
374 acpi_status status = AE_OK; 370 acpi_status status = AE_OK;
375 u32 glk = 0; 371 u32 glk = 0;
376 372
377 ACPI_FUNCTION_TRACE("acpi_ec_write");
378 373
379 if (!ec) 374 if (!ec)
380 return_VALUE(-EINVAL); 375 return -EINVAL;
381 376
382 if (ec->common.global_lock) { 377 if (ec->common.global_lock) {
383 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 378 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
384 if (ACPI_FAILURE(status)) 379 if (ACPI_FAILURE(status))
385 return_VALUE(-ENODEV); 380 return -ENODEV;
386 } 381 }
387 382
388 if (down_interruptible(&ec->poll.sem)) { 383 if (down_interruptible(&ec->poll.sem)) {
@@ -415,7 +410,7 @@ end_nosem:
415 if (ec->common.global_lock) 410 if (ec->common.global_lock)
416 acpi_release_global_lock(glk); 411 acpi_release_global_lock(glk);
417 412
418 return_VALUE(result); 413 return result;
419} 414}
420 415
421static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) 416static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
@@ -423,17 +418,16 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
423 int status = 0; 418 int status = 0;
424 u32 glk; 419 u32 glk;
425 420
426 ACPI_FUNCTION_TRACE("acpi_ec_read");
427 421
428 if (!ec || !data) 422 if (!ec || !data)
429 return_VALUE(-EINVAL); 423 return -EINVAL;
430 424
431 *data = 0; 425 *data = 0;
432 426
433 if (ec->common.global_lock) { 427 if (ec->common.global_lock) {
434 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 428 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
435 if (ACPI_FAILURE(status)) 429 if (ACPI_FAILURE(status))
436 return_VALUE(-ENODEV); 430 return -ENODEV;
437 } 431 }
438 432
439 WARN_ON(in_interrupt()); 433 WARN_ON(in_interrupt());
@@ -467,7 +461,7 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
467 if (ec->common.global_lock) 461 if (ec->common.global_lock)
468 acpi_release_global_lock(glk); 462 acpi_release_global_lock(glk);
469 463
470 return_VALUE(status); 464 return status;
471} 465}
472 466
473static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) 467static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
@@ -475,15 +469,14 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
475 int status = 0; 469 int status = 0;
476 u32 glk; 470 u32 glk;
477 471
478 ACPI_FUNCTION_TRACE("acpi_ec_write");
479 472
480 if (!ec) 473 if (!ec)
481 return_VALUE(-EINVAL); 474 return -EINVAL;
482 475
483 if (ec->common.global_lock) { 476 if (ec->common.global_lock) {
484 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 477 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
485 if (ACPI_FAILURE(status)) 478 if (ACPI_FAILURE(status))
486 return_VALUE(-ENODEV); 479 return -ENODEV;
487 } 480 }
488 481
489 WARN_ON(in_interrupt()); 482 WARN_ON(in_interrupt());
@@ -516,7 +509,7 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
516 if (ec->common.global_lock) 509 if (ec->common.global_lock)
517 acpi_release_global_lock(glk); 510 acpi_release_global_lock(glk);
518 511
519 return_VALUE(status); 512 return status;
520} 513}
521 514
522/* 515/*
@@ -574,17 +567,16 @@ static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data)
574 acpi_status status = AE_OK; 567 acpi_status status = AE_OK;
575 u32 glk = 0; 568 u32 glk = 0;
576 569
577 ACPI_FUNCTION_TRACE("acpi_ec_query");
578 570
579 if (!ec || !data) 571 if (!ec || !data)
580 return_VALUE(-EINVAL); 572 return -EINVAL;
581 573
582 *data = 0; 574 *data = 0;
583 575
584 if (ec->common.global_lock) { 576 if (ec->common.global_lock) {
585 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 577 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
586 if (ACPI_FAILURE(status)) 578 if (ACPI_FAILURE(status))
587 return_VALUE(-ENODEV); 579 return -ENODEV;
588 } 580 }
589 581
590 /* 582 /*
@@ -613,23 +605,22 @@ end_nosem:
613 if (ec->common.global_lock) 605 if (ec->common.global_lock)
614 acpi_release_global_lock(glk); 606 acpi_release_global_lock(glk);
615 607
616 return_VALUE(result); 608 return result;
617} 609}
618static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data) 610static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
619{ 611{
620 int status = 0; 612 int status = 0;
621 u32 glk; 613 u32 glk;
622 614
623 ACPI_FUNCTION_TRACE("acpi_ec_query");
624 615
625 if (!ec || !data) 616 if (!ec || !data)
626 return_VALUE(-EINVAL); 617 return -EINVAL;
627 *data = 0; 618 *data = 0;
628 619
629 if (ec->common.global_lock) { 620 if (ec->common.global_lock) {
630 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 621 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
631 if (ACPI_FAILURE(status)) 622 if (ACPI_FAILURE(status))
632 return_VALUE(-ENODEV); 623 return -ENODEV;
633 } 624 }
634 625
635 down(&ec->intr.sem); 626 down(&ec->intr.sem);
@@ -662,7 +653,7 @@ static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
662 if (ec->common.global_lock) 653 if (ec->common.global_lock)
663 acpi_release_global_lock(glk); 654 acpi_release_global_lock(glk);
664 655
665 return_VALUE(status); 656 return status;
666} 657}
667 658
668/* -------------------------------------------------------------------------- 659/* --------------------------------------------------------------------------
@@ -691,13 +682,12 @@ static void acpi_ec_gpe_poll_query(void *ec_cxt)
691 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 682 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
692 }; 683 };
693 684
694 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
695 685
696 if (!ec_cxt) 686 if (!ec_cxt)
697 goto end; 687 goto end;
698 688
699 if (down_interruptible (&ec->poll.sem)) { 689 if (down_interruptible (&ec->poll.sem)) {
700 return_VOID; 690 return;
701 } 691 }
702 acpi_hw_low_level_read(8, &value, &ec->common.command_addr); 692 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
703 up(&ec->poll.sem); 693 up(&ec->poll.sem);
@@ -734,7 +724,6 @@ static void acpi_ec_gpe_intr_query(void *ec_cxt)
734 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 724 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
735 }; 725 };
736 726
737 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
738 727
739 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) 728 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI)
740 result = acpi_ec_query(ec, &value); 729 result = acpi_ec_query(ec, &value);
@@ -793,12 +782,15 @@ static u32 acpi_ec_gpe_intr_handler(void *data)
793 case ACPI_EC_EVENT_OBF: 782 case ACPI_EC_EVENT_OBF:
794 if (!(value & ACPI_EC_FLAG_OBF)) 783 if (!(value & ACPI_EC_FLAG_OBF))
795 break; 784 break;
785 ec->intr.expect_event = 0;
786 wake_up(&ec->intr.wait);
787 break;
796 case ACPI_EC_EVENT_IBE: 788 case ACPI_EC_EVENT_IBE:
797 if ((value & ACPI_EC_FLAG_IBF)) 789 if ((value & ACPI_EC_FLAG_IBF))
798 break; 790 break;
799 ec->intr.expect_event = 0; 791 ec->intr.expect_event = 0;
800 wake_up(&ec->intr.wait); 792 wake_up(&ec->intr.wait);
801 return ACPI_INTERRUPT_HANDLED; 793 break;
802 default: 794 default:
803 break; 795 break;
804 } 796 }
@@ -846,15 +838,14 @@ acpi_ec_space_handler(u32 function,
846 acpi_integer f_v = 0; 838 acpi_integer f_v = 0;
847 int i = 0; 839 int i = 0;
848 840
849 ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
850 841
851 if ((address > 0xFF) || !value || !handler_context) 842 if ((address > 0xFF) || !value || !handler_context)
852 return_VALUE(AE_BAD_PARAMETER); 843 return AE_BAD_PARAMETER;
853 844
854 if (bit_width != 8 && acpi_strict) { 845 if (bit_width != 8 && acpi_strict) {
855 printk(KERN_WARNING PREFIX 846 printk(KERN_WARNING PREFIX
856 "acpi_ec_space_handler: bit_width should be 8\n"); 847 "acpi_ec_space_handler: bit_width should be 8\n");
857 return_VALUE(AE_BAD_PARAMETER); 848 return AE_BAD_PARAMETER;
858 } 849 }
859 850
860 ec = (union acpi_ec *)handler_context; 851 ec = (union acpi_ec *)handler_context;
@@ -893,16 +884,16 @@ acpi_ec_space_handler(u32 function,
893 out: 884 out:
894 switch (result) { 885 switch (result) {
895 case -EINVAL: 886 case -EINVAL:
896 return_VALUE(AE_BAD_PARAMETER); 887 return AE_BAD_PARAMETER;
897 break; 888 break;
898 case -ENODEV: 889 case -ENODEV:
899 return_VALUE(AE_NOT_FOUND); 890 return AE_NOT_FOUND;
900 break; 891 break;
901 case -ETIME: 892 case -ETIME:
902 return_VALUE(AE_TIME); 893 return AE_TIME;
903 break; 894 break;
904 default: 895 default:
905 return_VALUE(AE_OK); 896 return AE_OK;
906 } 897 }
907} 898}
908 899
@@ -916,7 +907,6 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
916{ 907{
917 union acpi_ec *ec = (union acpi_ec *)seq->private; 908 union acpi_ec *ec = (union acpi_ec *)seq->private;
918 909
919 ACPI_FUNCTION_TRACE("acpi_ec_read_info");
920 910
921 if (!ec) 911 if (!ec)
922 goto end; 912 goto end;
@@ -931,7 +921,7 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
931 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 921 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
932 922
933 end: 923 end:
934 return_VALUE(0); 924 return 0;
935} 925}
936 926
937static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) 927static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
@@ -951,33 +941,29 @@ static int acpi_ec_add_fs(struct acpi_device *device)
951{ 941{
952 struct proc_dir_entry *entry = NULL; 942 struct proc_dir_entry *entry = NULL;
953 943
954 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
955 944
956 if (!acpi_device_dir(device)) { 945 if (!acpi_device_dir(device)) {
957 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 946 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
958 acpi_ec_dir); 947 acpi_ec_dir);
959 if (!acpi_device_dir(device)) 948 if (!acpi_device_dir(device))
960 return_VALUE(-ENODEV); 949 return -ENODEV;
961 } 950 }
962 951
963 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, 952 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
964 acpi_device_dir(device)); 953 acpi_device_dir(device));
965 if (!entry) 954 if (!entry)
966 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 955 return -ENODEV;
967 "Unable to create '%s' fs entry\n",
968 ACPI_EC_FILE_INFO));
969 else { 956 else {
970 entry->proc_fops = &acpi_ec_info_ops; 957 entry->proc_fops = &acpi_ec_info_ops;
971 entry->data = acpi_driver_data(device); 958 entry->data = acpi_driver_data(device);
972 entry->owner = THIS_MODULE; 959 entry->owner = THIS_MODULE;
973 } 960 }
974 961
975 return_VALUE(0); 962 return 0;
976} 963}
977 964
978static int acpi_ec_remove_fs(struct acpi_device *device) 965static int acpi_ec_remove_fs(struct acpi_device *device)
979{ 966{
980 ACPI_FUNCTION_TRACE("acpi_ec_remove_fs");
981 967
982 if (acpi_device_dir(device)) { 968 if (acpi_device_dir(device)) {
983 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device)); 969 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
@@ -985,7 +971,7 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
985 acpi_device_dir(device) = NULL; 971 acpi_device_dir(device) = NULL;
986 } 972 }
987 973
988 return_VALUE(0); 974 return 0;
989} 975}
990 976
991/* -------------------------------------------------------------------------- 977/* --------------------------------------------------------------------------
@@ -998,14 +984,13 @@ static int acpi_ec_poll_add(struct acpi_device *device)
998 acpi_status status = AE_OK; 984 acpi_status status = AE_OK;
999 union acpi_ec *ec = NULL; 985 union acpi_ec *ec = NULL;
1000 986
1001 ACPI_FUNCTION_TRACE("acpi_ec_add");
1002 987
1003 if (!device) 988 if (!device)
1004 return_VALUE(-EINVAL); 989 return -EINVAL;
1005 990
1006 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 991 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1007 if (!ec) 992 if (!ec)
1008 return_VALUE(-ENOMEM); 993 return -ENOMEM;
1009 memset(ec, 0, sizeof(union acpi_ec)); 994 memset(ec, 0, sizeof(union acpi_ec));
1010 995
1011 ec->common.handle = device->handle; 996 ec->common.handle = device->handle;
@@ -1038,8 +1023,7 @@ static int acpi_ec_poll_add(struct acpi_device *device)
1038 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, 1023 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1039 &ec->common.gpe_bit); 1024 &ec->common.gpe_bit);
1040 if (ACPI_FAILURE(status)) { 1025 if (ACPI_FAILURE(status)) {
1041 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1026 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit"));
1042 "Error obtaining GPE bit assignment\n"));
1043 result = -ENODEV; 1027 result = -ENODEV;
1044 goto end; 1028 goto end;
1045 } 1029 }
@@ -1059,7 +1043,7 @@ static int acpi_ec_poll_add(struct acpi_device *device)
1059 if (result) 1043 if (result)
1060 kfree(ec); 1044 kfree(ec);
1061 1045
1062 return_VALUE(result); 1046 return result;
1063} 1047}
1064static int acpi_ec_intr_add(struct acpi_device *device) 1048static int acpi_ec_intr_add(struct acpi_device *device)
1065{ 1049{
@@ -1067,14 +1051,13 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1067 acpi_status status = AE_OK; 1051 acpi_status status = AE_OK;
1068 union acpi_ec *ec = NULL; 1052 union acpi_ec *ec = NULL;
1069 1053
1070 ACPI_FUNCTION_TRACE("acpi_ec_add");
1071 1054
1072 if (!device) 1055 if (!device)
1073 return_VALUE(-EINVAL); 1056 return -EINVAL;
1074 1057
1075 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 1058 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1076 if (!ec) 1059 if (!ec)
1077 return_VALUE(-ENOMEM); 1060 return -ENOMEM;
1078 memset(ec, 0, sizeof(union acpi_ec)); 1061 memset(ec, 0, sizeof(union acpi_ec));
1079 1062
1080 ec->common.handle = device->handle; 1063 ec->common.handle = device->handle;
@@ -1110,8 +1093,7 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1110 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, 1093 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1111 &ec->common.gpe_bit); 1094 &ec->common.gpe_bit);
1112 if (ACPI_FAILURE(status)) { 1095 if (ACPI_FAILURE(status)) {
1113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1096 printk(KERN_ERR PREFIX "Obtaining GPE bit assignment\n");
1114 "Error obtaining GPE bit assignment\n"));
1115 result = -ENODEV; 1097 result = -ENODEV;
1116 goto end; 1098 goto end;
1117 } 1099 }
@@ -1131,17 +1113,16 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1131 if (result) 1113 if (result)
1132 kfree(ec); 1114 kfree(ec);
1133 1115
1134 return_VALUE(result); 1116 return result;
1135} 1117}
1136 1118
1137static int acpi_ec_remove(struct acpi_device *device, int type) 1119static int acpi_ec_remove(struct acpi_device *device, int type)
1138{ 1120{
1139 union acpi_ec *ec = NULL; 1121 union acpi_ec *ec = NULL;
1140 1122
1141 ACPI_FUNCTION_TRACE("acpi_ec_remove");
1142 1123
1143 if (!device) 1124 if (!device)
1144 return_VALUE(-EINVAL); 1125 return -EINVAL;
1145 1126
1146 ec = acpi_driver_data(device); 1127 ec = acpi_driver_data(device);
1147 1128
@@ -1149,7 +1130,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
1149 1130
1150 kfree(ec); 1131 kfree(ec);
1151 1132
1152 return_VALUE(0); 1133 return 0;
1153} 1134}
1154 1135
1155static acpi_status 1136static acpi_status
@@ -1188,15 +1169,14 @@ static int acpi_ec_start(struct acpi_device *device)
1188 acpi_status status = AE_OK; 1169 acpi_status status = AE_OK;
1189 union acpi_ec *ec = NULL; 1170 union acpi_ec *ec = NULL;
1190 1171
1191 ACPI_FUNCTION_TRACE("acpi_ec_start");
1192 1172
1193 if (!device) 1173 if (!device)
1194 return_VALUE(-EINVAL); 1174 return -EINVAL;
1195 1175
1196 ec = acpi_driver_data(device); 1176 ec = acpi_driver_data(device);
1197 1177
1198 if (!ec) 1178 if (!ec)
1199 return_VALUE(-EINVAL); 1179 return -EINVAL;
1200 1180
1201 /* 1181 /*
1202 * Get I/O port addresses. Convert to GAS format. 1182 * Get I/O port addresses. Convert to GAS format.
@@ -1205,9 +1185,8 @@ static int acpi_ec_start(struct acpi_device *device)
1205 acpi_ec_io_ports, ec); 1185 acpi_ec_io_ports, ec);
1206 if (ACPI_FAILURE(status) 1186 if (ACPI_FAILURE(status)
1207 || ec->common.command_addr.register_bit_width == 0) { 1187 || ec->common.command_addr.register_bit_width == 0) {
1208 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1188 printk(KERN_ERR PREFIX "Error getting I/O port addresses\n");
1209 "Error getting I/O port addresses")); 1189 return -ENODEV;
1210 return_VALUE(-ENODEV);
1211 } 1190 }
1212 1191
1213 ec->common.status_addr = ec->common.command_addr; 1192 ec->common.status_addr = ec->common.command_addr;
@@ -1224,7 +1203,7 @@ static int acpi_ec_start(struct acpi_device *device)
1224 ACPI_GPE_EDGE_TRIGGERED, 1203 ACPI_GPE_EDGE_TRIGGERED,
1225 &acpi_ec_gpe_handler, ec); 1204 &acpi_ec_gpe_handler, ec);
1226 if (ACPI_FAILURE(status)) { 1205 if (ACPI_FAILURE(status)) {
1227 return_VALUE(-ENODEV); 1206 return -ENODEV;
1228 } 1207 }
1229 acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1208 acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1230 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 1209 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
@@ -1236,10 +1215,10 @@ static int acpi_ec_start(struct acpi_device *device)
1236 if (ACPI_FAILURE(status)) { 1215 if (ACPI_FAILURE(status)) {
1237 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 1216 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1238 &acpi_ec_gpe_handler); 1217 &acpi_ec_gpe_handler);
1239 return_VALUE(-ENODEV); 1218 return -ENODEV;
1240 } 1219 }
1241 1220
1242 return_VALUE(AE_OK); 1221 return AE_OK;
1243} 1222}
1244 1223
1245static int acpi_ec_stop(struct acpi_device *device, int type) 1224static int acpi_ec_stop(struct acpi_device *device, int type)
@@ -1247,10 +1226,9 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
1247 acpi_status status = AE_OK; 1226 acpi_status status = AE_OK;
1248 union acpi_ec *ec = NULL; 1227 union acpi_ec *ec = NULL;
1249 1228
1250 ACPI_FUNCTION_TRACE("acpi_ec_stop");
1251 1229
1252 if (!device) 1230 if (!device)
1253 return_VALUE(-EINVAL); 1231 return -EINVAL;
1254 1232
1255 ec = acpi_driver_data(device); 1233 ec = acpi_driver_data(device);
1256 1234
@@ -1258,15 +1236,15 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
1258 ACPI_ADR_SPACE_EC, 1236 ACPI_ADR_SPACE_EC,
1259 &acpi_ec_space_handler); 1237 &acpi_ec_space_handler);
1260 if (ACPI_FAILURE(status)) 1238 if (ACPI_FAILURE(status))
1261 return_VALUE(-ENODEV); 1239 return -ENODEV;
1262 1240
1263 status = 1241 status =
1264 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 1242 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1265 &acpi_ec_gpe_handler); 1243 &acpi_ec_gpe_handler);
1266 if (ACPI_FAILURE(status)) 1244 if (ACPI_FAILURE(status))
1267 return_VALUE(-ENODEV); 1245 return -ENODEV;
1268 1246
1269 return_VALUE(0); 1247 return 0;
1270} 1248}
1271 1249
1272static acpi_status __init 1250static acpi_status __init
@@ -1536,23 +1514,22 @@ static int __init acpi_ec_init(void)
1536{ 1514{
1537 int result = 0; 1515 int result = 0;
1538 1516
1539 ACPI_FUNCTION_TRACE("acpi_ec_init");
1540 1517
1541 if (acpi_disabled) 1518 if (acpi_disabled)
1542 return_VALUE(0); 1519 return 0;
1543 1520
1544 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); 1521 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
1545 if (!acpi_ec_dir) 1522 if (!acpi_ec_dir)
1546 return_VALUE(-ENODEV); 1523 return -ENODEV;
1547 1524
1548 /* Now register the driver for the EC */ 1525 /* Now register the driver for the EC */
1549 result = acpi_bus_register_driver(&acpi_ec_driver); 1526 result = acpi_bus_register_driver(&acpi_ec_driver);
1550 if (result < 0) { 1527 if (result < 0) {
1551 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); 1528 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1552 return_VALUE(-ENODEV); 1529 return -ENODEV;
1553 } 1530 }
1554 1531
1555 return_VALUE(result); 1532 return result;
1556} 1533}
1557 1534
1558subsys_initcall(acpi_ec_init); 1535subsys_initcall(acpi_ec_init);
@@ -1561,13 +1538,12 @@ subsys_initcall(acpi_ec_init);
1561#if 0 1538#if 0
1562static void __exit acpi_ec_exit(void) 1539static void __exit acpi_ec_exit(void)
1563{ 1540{
1564 ACPI_FUNCTION_TRACE("acpi_ec_exit");
1565 1541
1566 acpi_bus_unregister_driver(&acpi_ec_driver); 1542 acpi_bus_unregister_driver(&acpi_ec_driver);
1567 1543
1568 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); 1544 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1569 1545
1570 return_VOID; 1546 return;
1571} 1547}
1572#endif /* 0 */ 1548#endif /* 0 */
1573 1549
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 2dbb1b0f11d5..a901b23e95e7 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -48,18 +48,17 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
48 static int chars_remaining = 0; 48 static int chars_remaining = 0;
49 static char *ptr; 49 static char *ptr;
50 50
51 ACPI_FUNCTION_TRACE("acpi_system_read_event");
52 51
53 if (!chars_remaining) { 52 if (!chars_remaining) {
54 memset(&event, 0, sizeof(struct acpi_bus_event)); 53 memset(&event, 0, sizeof(struct acpi_bus_event));
55 54
56 if ((file->f_flags & O_NONBLOCK) 55 if ((file->f_flags & O_NONBLOCK)
57 && (list_empty(&acpi_bus_event_list))) 56 && (list_empty(&acpi_bus_event_list)))
58 return_VALUE(-EAGAIN); 57 return -EAGAIN;
59 58
60 result = acpi_bus_receive_event(&event); 59 result = acpi_bus_receive_event(&event);
61 if (result) 60 if (result)
62 return_VALUE(result); 61 return result;
63 62
64 chars_remaining = sprintf(str, "%s %s %08x %08x\n", 63 chars_remaining = sprintf(str, "%s %s %08x %08x\n",
65 event.device_class ? event. 64 event.device_class ? event.
@@ -75,13 +74,13 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
75 } 74 }
76 75
77 if (copy_to_user(buffer, ptr, count)) 76 if (copy_to_user(buffer, ptr, count))
78 return_VALUE(-EFAULT); 77 return -EFAULT;
79 78
80 *ppos += count; 79 *ppos += count;
81 chars_remaining -= count; 80 chars_remaining -= count;
82 ptr += count; 81 ptr += count;
83 82
84 return_VALUE(count); 83 return count;
85} 84}
86 85
87static int acpi_system_close_event(struct inode *inode, struct file *file) 86static int acpi_system_close_event(struct inode *inode, struct file *file)
@@ -112,22 +111,18 @@ static int __init acpi_event_init(void)
112 struct proc_dir_entry *entry; 111 struct proc_dir_entry *entry;
113 int error = 0; 112 int error = 0;
114 113
115 ACPI_FUNCTION_TRACE("acpi_event_init");
116 114
117 if (acpi_disabled) 115 if (acpi_disabled)
118 return_VALUE(0); 116 return 0;
119 117
120 /* 'event' [R] */ 118 /* 'event' [R] */
121 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); 119 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
122 if (entry) 120 if (entry)
123 entry->proc_fops = &acpi_system_event_ops; 121 entry->proc_fops = &acpi_system_event_ops;
124 else { 122 else {
125 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 123 error = -ENODEV;
126 "Unable to create '%s' proc fs entry\n",
127 "event"));
128 error = -EFAULT;
129 } 124 }
130 return_VALUE(error); 125 return error;
131} 126}
132 127
133subsys_initcall(acpi_event_init); 128subsys_initcall(acpi_event_init);
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index f01d339407f8..c76c0583ca6a 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -382,7 +382,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
382 u32 status_reg; 382 u32 status_reg;
383 u32 enable_reg; 383 u32 enable_reg;
384 acpi_cpu_flags flags; 384 acpi_cpu_flags flags;
385 acpi_cpu_flags hw_flags;
386 acpi_native_uint i; 385 acpi_native_uint i;
387 acpi_native_uint j; 386 acpi_native_uint j;
388 387
@@ -394,8 +393,11 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
394 return (int_status); 393 return (int_status);
395 } 394 }
396 395
397 /* We need to hold the GPE lock now, hardware lock in the loop */ 396 /*
398 397 * We need to obtain the GPE lock for both the data structs and registers
398 * Note: Not necessary to obtain the hardware lock, since the GPE registers
399 * are owned by the gpe_lock.
400 */
399 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 401 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
400 402
401 /* Examine all GPE blocks attached to this interrupt level */ 403 /* Examine all GPE blocks attached to this interrupt level */
@@ -413,8 +415,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
413 415
414 gpe_register_info = &gpe_block->register_info[i]; 416 gpe_register_info = &gpe_block->register_info[i];
415 417
416 hw_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
417
418 /* Read the Status Register */ 418 /* Read the Status Register */
419 419
420 status = 420 status =
@@ -423,8 +423,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
423 &gpe_register_info-> 423 &gpe_register_info->
424 status_address); 424 status_address);
425 if (ACPI_FAILURE(status)) { 425 if (ACPI_FAILURE(status)) {
426 acpi_os_release_lock(acpi_gbl_hardware_lock,
427 hw_flags);
428 goto unlock_and_exit; 426 goto unlock_and_exit;
429 } 427 }
430 428
@@ -435,8 +433,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
435 &enable_reg, 433 &enable_reg,
436 &gpe_register_info-> 434 &gpe_register_info->
437 enable_address); 435 enable_address);
438 acpi_os_release_lock(acpi_gbl_hardware_lock, hw_flags);
439
440 if (ACPI_FAILURE(status)) { 436 if (ACPI_FAILURE(status)) {
441 goto unlock_and_exit; 437 goto unlock_and_exit;
442 } 438 }
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 76c34a66e0e0..4f948df17ab9 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -414,12 +414,13 @@ acpi_remove_notify_handler(acpi_handle device,
414 414
415 if ((!device) || 415 if ((!device) ||
416 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 416 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
417 return_ACPI_STATUS(AE_BAD_PARAMETER); 417 status = AE_BAD_PARAMETER;
418 goto exit;
418 } 419 }
419 420
420 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 421 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
421 if (ACPI_FAILURE(status)) { 422 if (ACPI_FAILURE(status)) {
422 return_ACPI_STATUS(status); 423 goto exit;
423 } 424 }
424 425
425 /* Convert and validate the device handle */ 426 /* Convert and validate the device handle */
@@ -427,7 +428,7 @@ acpi_remove_notify_handler(acpi_handle device,
427 node = acpi_ns_map_handle_to_node(device); 428 node = acpi_ns_map_handle_to_node(device);
428 if (!node) { 429 if (!node) {
429 status = AE_BAD_PARAMETER; 430 status = AE_BAD_PARAMETER;
430 goto unlock_and_exit; 431 goto unlock;
431 } 432 }
432 433
433 /* Root Object */ 434 /* Root Object */
@@ -441,7 +442,7 @@ acpi_remove_notify_handler(acpi_handle device,
441 ((handler_type & ACPI_DEVICE_NOTIFY) && 442 ((handler_type & ACPI_DEVICE_NOTIFY) &&
442 !acpi_gbl_device_notify.handler)) { 443 !acpi_gbl_device_notify.handler)) {
443 status = AE_NOT_EXIST; 444 status = AE_NOT_EXIST;
444 goto unlock_and_exit; 445 goto unlock;
445 } 446 }
446 447
447 /* Make sure all deferred tasks are completed */ 448 /* Make sure all deferred tasks are completed */
@@ -450,7 +451,7 @@ acpi_remove_notify_handler(acpi_handle device,
450 acpi_os_wait_events_complete(NULL); 451 acpi_os_wait_events_complete(NULL);
451 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 452 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
452 if (ACPI_FAILURE(status)) { 453 if (ACPI_FAILURE(status)) {
453 return_ACPI_STATUS(status); 454 goto exit;
454 } 455 }
455 456
456 if (handler_type & ACPI_SYSTEM_NOTIFY) { 457 if (handler_type & ACPI_SYSTEM_NOTIFY) {
@@ -473,7 +474,7 @@ acpi_remove_notify_handler(acpi_handle device,
473 474
474 if (!acpi_ev_is_notify_object(node)) { 475 if (!acpi_ev_is_notify_object(node)) {
475 status = AE_TYPE; 476 status = AE_TYPE;
476 goto unlock_and_exit; 477 goto unlock;
477 } 478 }
478 479
479 /* Check for an existing internal object */ 480 /* Check for an existing internal object */
@@ -481,7 +482,7 @@ acpi_remove_notify_handler(acpi_handle device,
481 obj_desc = acpi_ns_get_attached_object(node); 482 obj_desc = acpi_ns_get_attached_object(node);
482 if (!obj_desc) { 483 if (!obj_desc) {
483 status = AE_NOT_EXIST; 484 status = AE_NOT_EXIST;
484 goto unlock_and_exit; 485 goto unlock;
485 } 486 }
486 487
487 /* Object exists - make sure there's an existing handler */ 488 /* Object exists - make sure there's an existing handler */
@@ -491,7 +492,7 @@ acpi_remove_notify_handler(acpi_handle device,
491 if ((!notify_obj) || 492 if ((!notify_obj) ||
492 (notify_obj->notify.handler != handler)) { 493 (notify_obj->notify.handler != handler)) {
493 status = AE_BAD_PARAMETER; 494 status = AE_BAD_PARAMETER;
494 goto unlock_and_exit; 495 goto unlock;
495 } 496 }
496 /* Make sure all deferred tasks are completed */ 497 /* Make sure all deferred tasks are completed */
497 498
@@ -499,7 +500,7 @@ acpi_remove_notify_handler(acpi_handle device,
499 acpi_os_wait_events_complete(NULL); 500 acpi_os_wait_events_complete(NULL);
500 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 501 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
501 if (ACPI_FAILURE(status)) { 502 if (ACPI_FAILURE(status)) {
502 return_ACPI_STATUS(status); 503 goto exit;
503 } 504 }
504 505
505 /* Remove the handler */ 506 /* Remove the handler */
@@ -512,7 +513,7 @@ acpi_remove_notify_handler(acpi_handle device,
512 if ((!notify_obj) || 513 if ((!notify_obj) ||
513 (notify_obj->notify.handler != handler)) { 514 (notify_obj->notify.handler != handler)) {
514 status = AE_BAD_PARAMETER; 515 status = AE_BAD_PARAMETER;
515 goto unlock_and_exit; 516 goto unlock;
516 } 517 }
517 /* Make sure all deferred tasks are completed */ 518 /* Make sure all deferred tasks are completed */
518 519
@@ -520,7 +521,7 @@ acpi_remove_notify_handler(acpi_handle device,
520 acpi_os_wait_events_complete(NULL); 521 acpi_os_wait_events_complete(NULL);
521 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 522 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
522 if (ACPI_FAILURE(status)) { 523 if (ACPI_FAILURE(status)) {
523 return_ACPI_STATUS(status); 524 goto exit;
524 } 525 }
525 526
526 /* Remove the handler */ 527 /* Remove the handler */
@@ -529,8 +530,11 @@ acpi_remove_notify_handler(acpi_handle device,
529 } 530 }
530 } 531 }
531 532
532 unlock_and_exit: 533unlock:
533 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 534 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
535exit:
536 if (ACPI_FAILURE(status))
537 ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler"));
534 return_ACPI_STATUS(status); 538 return_ACPI_STATUS(status);
535} 539}
536 540
@@ -568,12 +572,13 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
568 /* Parameter validation */ 572 /* Parameter validation */
569 573
570 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { 574 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
571 return_ACPI_STATUS(AE_BAD_PARAMETER); 575 status = AE_BAD_PARAMETER;
576 goto exit;
572 } 577 }
573 578
574 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 579 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
575 if (ACPI_FAILURE(status)) { 580 if (ACPI_FAILURE(status)) {
576 return_ACPI_STATUS(status); 581 goto exit;
577 } 582 }
578 583
579 /* Ensure that we have a valid GPE number */ 584 /* Ensure that we have a valid GPE number */
@@ -581,7 +586,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
581 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 586 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
582 if (!gpe_event_info) { 587 if (!gpe_event_info) {
583 status = AE_BAD_PARAMETER; 588 status = AE_BAD_PARAMETER;
584 goto unlock_and_exit; 589 goto unlock;
585 } 590 }
586 591
587 /* Make sure that there isn't a handler there already */ 592 /* Make sure that there isn't a handler there already */
@@ -589,7 +594,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
589 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 594 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
590 ACPI_GPE_DISPATCH_HANDLER) { 595 ACPI_GPE_DISPATCH_HANDLER) {
591 status = AE_ALREADY_EXISTS; 596 status = AE_ALREADY_EXISTS;
592 goto unlock_and_exit; 597 goto unlock;
593 } 598 }
594 599
595 /* Allocate and init handler object */ 600 /* Allocate and init handler object */
@@ -597,7 +602,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
597 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); 602 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info));
598 if (!handler) { 603 if (!handler) {
599 status = AE_NO_MEMORY; 604 status = AE_NO_MEMORY;
600 goto unlock_and_exit; 605 goto unlock;
601 } 606 }
602 607
603 handler->address = address; 608 handler->address = address;
@@ -608,7 +613,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
608 613
609 status = acpi_ev_disable_gpe(gpe_event_info); 614 status = acpi_ev_disable_gpe(gpe_event_info);
610 if (ACPI_FAILURE(status)) { 615 if (ACPI_FAILURE(status)) {
611 goto unlock_and_exit; 616 goto unlock;
612 } 617 }
613 618
614 /* Install the handler */ 619 /* Install the handler */
@@ -623,8 +628,12 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
623 628
624 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 629 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
625 630
626 unlock_and_exit: 631unlock:
627 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 632 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
633exit:
634 if (ACPI_FAILURE(status))
635 ACPI_EXCEPTION((AE_INFO, status,
636 "Installing notify handler failed"));
628 return_ACPI_STATUS(status); 637 return_ACPI_STATUS(status);
629} 638}
630 639
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 823352435e08..83fed079a276 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -266,6 +266,10 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
266 } 266 }
267 } 267 }
268 268
269 ACPI_INFO((AE_INFO,
270 "Dynamic OEM Table Load - [%4.4s] OemId [%6.6s] OemTableId [%8.8s]",
271 table->signature, table->oem_id, table->oem_table_id));
272
269 *return_desc = ddb_handle; 273 *return_desc = ddb_handle;
270 return_ACPI_STATUS(status); 274 return_ACPI_STATUS(status);
271} 275}
@@ -446,6 +450,10 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
446 return_ACPI_STATUS(status); 450 return_ACPI_STATUS(status);
447 } 451 }
448 452
453 ACPI_INFO((AE_INFO,
454 "Dynamic SSDT Load - OemId [%6.6s] OemTableId [%8.8s]",
455 table_ptr->oem_id, table_ptr->oem_table_id));
456
449 cleanup: 457 cleanup:
450 if (ACPI_FAILURE(status)) { 458 if (ACPI_FAILURE(status)) {
451 ACPI_FREE(table_ptr); 459 ACPI_FREE(table_ptr);
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index 106dc7219df7..34eec82c1b1e 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -177,7 +177,7 @@ acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
177 * that the event is created in an unsignalled state 177 * that the event is created in an unsignalled state
178 */ 178 */
179 status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, 179 status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
180 &obj_desc->event.semaphore); 180 &obj_desc->event.os_semaphore);
181 if (ACPI_FAILURE(status)) { 181 if (ACPI_FAILURE(status)) {
182 goto cleanup; 182 goto cleanup;
183 } 183 }
@@ -226,12 +226,9 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
226 goto cleanup; 226 goto cleanup;
227 } 227 }
228 228
229 /* 229 /* Create the actual OS Mutex */
230 * Create the actual OS semaphore. 230
231 * One unit max to make it a mutex, with one initial unit to allow 231 status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex);
232 * the mutex to be acquired.
233 */
234 status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore);
235 if (ACPI_FAILURE(status)) { 232 if (ACPI_FAILURE(status)) {
236 goto cleanup; 233 goto cleanup;
237 } 234 }
@@ -565,7 +562,7 @@ acpi_ex_create_method(u8 * aml_start,
565 obj_desc->method.aml_length = aml_length; 562 obj_desc->method.aml_length = aml_length;
566 563
567 /* 564 /*
568 * Disassemble the method flags. Split off the Arg Count 565 * Disassemble the method flags. Split off the Arg Count
569 * for efficiency 566 * for efficiency
570 */ 567 */
571 method_flags = (u8) operand[1]->integer.value; 568 method_flags = (u8) operand[1]->integer.value;
@@ -576,21 +573,19 @@ acpi_ex_create_method(u8 * aml_start,
576 (u8) (method_flags & AML_METHOD_ARG_COUNT); 573 (u8) (method_flags & AML_METHOD_ARG_COUNT);
577 574
578 /* 575 /*
579 * Get the concurrency count. If required, a semaphore will be 576 * Get the sync_level. If method is serialized, a mutex will be
580 * created for this method when it is parsed. 577 * created for this method when it is parsed.
581 */ 578 */
582 if (acpi_gbl_all_methods_serialized) { 579 if (acpi_gbl_all_methods_serialized) {
583 obj_desc->method.concurrency = 1; 580 obj_desc->method.sync_level = 0;
584 obj_desc->method.method_flags |= AML_METHOD_SERIALIZED; 581 obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;
585 } else if (method_flags & AML_METHOD_SERIALIZED) { 582 } else if (method_flags & AML_METHOD_SERIALIZED) {
586 /* 583 /*
587 * ACPI 1.0: Concurrency = 1 584 * ACPI 1.0: sync_level = 0
588 * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1) 585 * ACPI 2.0: sync_level = sync_level in method declaration
589 */ 586 */
590 obj_desc->method.concurrency = (u8) 587 obj_desc->method.sync_level = (u8)
591 (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); 588 ((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4);
592 } else {
593 obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY;
594 } 589 }
595 590
596 /* Attach the new object to the method Node */ 591 /* Attach the new object to the method Node */
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 7b9718e976bf..2450943add33 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -118,14 +118,14 @@ static struct acpi_exdump_info acpi_ex_dump_device[4] = {
118 118
119static struct acpi_exdump_info acpi_ex_dump_event[2] = { 119static struct acpi_exdump_info acpi_ex_dump_event[2] = {
120 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL}, 120 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
121 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"} 121 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.os_semaphore), "OsSemaphore"}
122}; 122};
123 123
124static struct acpi_exdump_info acpi_ex_dump_method[8] = { 124static struct acpi_exdump_info acpi_ex_dump_method[8] = {
125 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, 125 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "ParamCount"}, 126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "ParamCount"},
127 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"}, 127 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"},
128 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"}, 128 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.mutex), "Mutex"},
129 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"}, 129 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
130 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"}, 130 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
131 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"}, 131 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
@@ -138,7 +138,7 @@ static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
138 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"}, 138 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
139 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), 139 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
140 "Acquire Depth"}, 140 "Acquire Depth"},
141 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"} 141 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
142}; 142};
143 143
144static struct acpi_exdump_info acpi_ex_dump_region[7] = { 144static struct acpi_exdump_info acpi_ex_dump_region[7] = {
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index 051053f7cccb..40f0bee6faa5 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -727,11 +727,23 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
727 return_ACPI_STATUS(status); 727 return_ACPI_STATUS(status);
728 } 728 }
729 729
730 /* Merge with previous datum if necessary */ 730 /*
731 731 * Merge with previous datum if necessary.
732 merged_datum |= raw_datum << 732 *
733 (obj_desc->common_field.access_bit_width - 733 * Note: Before the shift, check if the shift value will be larger than
734 obj_desc->common_field.start_field_bit_offset); 734 * the integer size. If so, there is no need to perform the operation.
735 * This avoids the differences in behavior between different compilers
736 * concerning shift values larger than the target data width.
737 */
738 if ((obj_desc->common_field.access_bit_width -
739 obj_desc->common_field.start_field_bit_offset) <
740 ACPI_INTEGER_BIT_SIZE) {
741 merged_datum |=
742 raw_datum << (obj_desc->common_field.
743 access_bit_width -
744 obj_desc->common_field.
745 start_field_bit_offset);
746 }
735 747
736 if (i == datum_count) { 748 if (i == datum_count) {
737 break; 749 break;
@@ -808,13 +820,23 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
808 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 820 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
809 } 821 }
810 822
811 /* Compute the number of datums (access width data items) */ 823 /*
824 * Create the bitmasks used for bit insertion.
825 * Note: This if/else is used to bypass compiler differences with the
826 * shift operator
827 */
828 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {
829 width_mask = ACPI_INTEGER_MAX;
830 } else {
831 width_mask =
832 ACPI_MASK_BITS_ABOVE(obj_desc->common_field.
833 access_bit_width);
834 }
812 835
813 width_mask = 836 mask = width_mask &
814 ACPI_MASK_BITS_ABOVE(obj_desc->common_field.access_bit_width); 837 ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
815 mask = 838
816 width_mask & ACPI_MASK_BITS_BELOW(obj_desc->common_field. 839 /* Compute the number of datums (access width data items) */
817 start_field_bit_offset);
818 840
819 datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length, 841 datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
820 obj_desc->common_field.access_bit_width); 842 obj_desc->common_field.access_bit_width);
@@ -848,12 +870,29 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
848 return_ACPI_STATUS(status); 870 return_ACPI_STATUS(status);
849 } 871 }
850 872
851 /* Start new output datum by merging with previous input datum */
852
853 field_offset += obj_desc->common_field.access_byte_width; 873 field_offset += obj_desc->common_field.access_byte_width;
854 merged_datum = raw_datum >> 874
855 (obj_desc->common_field.access_bit_width - 875 /*
856 obj_desc->common_field.start_field_bit_offset); 876 * Start new output datum by merging with previous input datum
877 * if necessary.
878 *
879 * Note: Before the shift, check if the shift value will be larger than
880 * the integer size. If so, there is no need to perform the operation.
881 * This avoids the differences in behavior between different compilers
882 * concerning shift values larger than the target data width.
883 */
884 if ((obj_desc->common_field.access_bit_width -
885 obj_desc->common_field.start_field_bit_offset) <
886 ACPI_INTEGER_BIT_SIZE) {
887 merged_datum =
888 raw_datum >> (obj_desc->common_field.
889 access_bit_width -
890 obj_desc->common_field.
891 start_field_bit_offset);
892 } else {
893 merged_datum = 0;
894 }
895
857 mask = width_mask; 896 mask = width_mask;
858 897
859 if (i == datum_count) { 898 if (i == datum_count) {
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index 93098d68cadf..d8ac2877cf05 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -161,12 +161,13 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
161 161
162 /* 162 /*
163 * Current Sync must be less than or equal to the sync level of the 163 * Current Sync must be less than or equal to the sync level of the
164 * mutex. This mechanism provides some deadlock prevention 164 * mutex. This mechanism provides some deadlock prevention
165 */ 165 */
166 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 166 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
167 ACPI_ERROR((AE_INFO, 167 ACPI_ERROR((AE_INFO,
168 "Cannot acquire Mutex [%4.4s], incorrect SyncLevel", 168 "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)",
169 acpi_ut_get_node_name(obj_desc->mutex.node))); 169 acpi_ut_get_node_name(obj_desc->mutex.node),
170 walk_state->thread->current_sync_level));
170 return_ACPI_STATUS(AE_AML_MUTEX_ORDER); 171 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
171 } 172 }
172 173
@@ -178,8 +179,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
178 179
179 if ((obj_desc->mutex.owner_thread->thread_id == 180 if ((obj_desc->mutex.owner_thread->thread_id ==
180 walk_state->thread->thread_id) || 181 walk_state->thread->thread_id) ||
181 (obj_desc->mutex.semaphore == 182 (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK)) {
182 acpi_gbl_global_lock_semaphore)) {
183 /* 183 /*
184 * The mutex is already owned by this thread, 184 * The mutex is already owned by this thread,
185 * just increment the acquisition depth 185 * just increment the acquisition depth
@@ -264,7 +264,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
264 */ 264 */
265 if ((obj_desc->mutex.owner_thread->thread_id != 265 if ((obj_desc->mutex.owner_thread->thread_id !=
266 walk_state->thread->thread_id) 266 walk_state->thread->thread_id)
267 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { 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 walk_state->thread->thread_id,
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index 52beee3674a0..6b5d1e6ce94b 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -63,14 +63,14 @@ ACPI_MODULE_NAME("exsystem")
63 * interpreter is released. 63 * interpreter is released.
64 * 64 *
65 ******************************************************************************/ 65 ******************************************************************************/
66acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout) 66acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
67{ 67{
68 acpi_status status; 68 acpi_status status;
69 acpi_status status2; 69 acpi_status status2;
70 70
71 ACPI_FUNCTION_TRACE(ex_system_wait_semaphore); 71 ACPI_FUNCTION_TRACE(ex_system_wait_semaphore);
72 72
73 status = acpi_os_wait_semaphore(semaphore, 1, 0); 73 status = acpi_os_wait_semaphore(semaphore, 1, ACPI_DO_NOT_WAIT);
74 if (ACPI_SUCCESS(status)) { 74 if (ACPI_SUCCESS(status)) {
75 return_ACPI_STATUS(status); 75 return_ACPI_STATUS(status);
76 } 76 }
@@ -103,6 +103,59 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)
103 103
104/******************************************************************************* 104/*******************************************************************************
105 * 105 *
106 * FUNCTION: acpi_ex_system_wait_mutex
107 *
108 * PARAMETERS: Mutex - Mutex to wait on
109 * Timeout - Max time to wait
110 *
111 * RETURN: Status
112 *
113 * DESCRIPTION: Implements a semaphore wait with a check to see if the
114 * semaphore is available immediately. If it is not, the
115 * interpreter is released.
116 *
117 ******************************************************************************/
118
119acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)
120{
121 acpi_status status;
122 acpi_status status2;
123
124 ACPI_FUNCTION_TRACE(ex_system_wait_mutex);
125
126 status = acpi_os_acquire_mutex(mutex, ACPI_DO_NOT_WAIT);
127 if (ACPI_SUCCESS(status)) {
128 return_ACPI_STATUS(status);
129 }
130
131 if (status == AE_TIME) {
132
133 /* We must wait, so unlock the interpreter */
134
135 acpi_ex_exit_interpreter();
136
137 status = acpi_os_acquire_mutex(mutex, timeout);
138
139 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
140 "*** Thread awake after blocking, %s\n",
141 acpi_format_exception(status)));
142
143 /* Reacquire the interpreter */
144
145 status2 = acpi_ex_enter_interpreter();
146 if (ACPI_FAILURE(status2)) {
147
148 /* Report fatal error, could not acquire interpreter */
149
150 return_ACPI_STATUS(status2);
151 }
152 }
153
154 return_ACPI_STATUS(status);
155}
156
157/*******************************************************************************
158 *
106 * FUNCTION: acpi_ex_system_do_stall 159 * FUNCTION: acpi_ex_system_do_stall
107 * 160 *
108 * PARAMETERS: how_long - The amount of time to stall, 161 * PARAMETERS: how_long - The amount of time to stall,
@@ -176,7 +229,7 @@ acpi_status acpi_ex_system_do_suspend(acpi_integer how_long)
176 * 229 *
177 * FUNCTION: acpi_ex_system_acquire_mutex 230 * FUNCTION: acpi_ex_system_acquire_mutex
178 * 231 *
179 * PARAMETERS: time_desc - The 'time to delay' object descriptor 232 * PARAMETERS: time_desc - Maximum time to wait for the mutex
180 * obj_desc - The object descriptor for this op 233 * obj_desc - The object descriptor for this op
181 * 234 *
182 * RETURN: Status 235 * RETURN: Status
@@ -201,14 +254,14 @@ acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc,
201 254
202 /* Support for the _GL_ Mutex object -- go get the global lock */ 255 /* Support for the _GL_ Mutex object -- go get the global lock */
203 256
204 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 257 if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {
205 status = 258 status =
206 acpi_ev_acquire_global_lock((u16) time_desc->integer.value); 259 acpi_ev_acquire_global_lock((u16) time_desc->integer.value);
207 return_ACPI_STATUS(status); 260 return_ACPI_STATUS(status);
208 } 261 }
209 262
210 status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore, 263 status = acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex,
211 (u16) time_desc->integer.value); 264 (u16) time_desc->integer.value);
212 return_ACPI_STATUS(status); 265 return_ACPI_STATUS(status);
213} 266}
214 267
@@ -239,13 +292,13 @@ acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc)
239 292
240 /* Support for the _GL_ Mutex object -- release the global lock */ 293 /* Support for the _GL_ Mutex object -- release the global lock */
241 294
242 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 295 if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {
243 status = acpi_ev_release_global_lock(); 296 status = acpi_ev_release_global_lock();
244 return_ACPI_STATUS(status); 297 return_ACPI_STATUS(status);
245 } 298 }
246 299
247 status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1); 300 acpi_os_release_mutex(obj_desc->mutex.os_mutex);
248 return_ACPI_STATUS(status); 301 return_ACPI_STATUS(AE_OK);
249} 302}
250 303
251/******************************************************************************* 304/*******************************************************************************
@@ -268,7 +321,8 @@ acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc)
268 ACPI_FUNCTION_TRACE(ex_system_signal_event); 321 ACPI_FUNCTION_TRACE(ex_system_signal_event);
269 322
270 if (obj_desc) { 323 if (obj_desc) {
271 status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1); 324 status =
325 acpi_os_signal_semaphore(obj_desc->event.os_semaphore, 1);
272 } 326 }
273 327
274 return_ACPI_STATUS(status); 328 return_ACPI_STATUS(status);
@@ -299,7 +353,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
299 353
300 if (obj_desc) { 354 if (obj_desc) {
301 status = 355 status =
302 acpi_ex_system_wait_semaphore(obj_desc->event.semaphore, 356 acpi_ex_system_wait_semaphore(obj_desc->event.os_semaphore,
303 (u16) time_desc->integer. 357 (u16) time_desc->integer.
304 value); 358 value);
305 } 359 }
@@ -322,7 +376,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
322acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc) 376acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
323{ 377{
324 acpi_status status = AE_OK; 378 acpi_status status = AE_OK;
325 void *temp_semaphore; 379 acpi_semaphore temp_semaphore;
326 380
327 ACPI_FUNCTION_ENTRY(); 381 ACPI_FUNCTION_ENTRY();
328 382
@@ -333,8 +387,8 @@ acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
333 status = 387 status =
334 acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); 388 acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
335 if (ACPI_SUCCESS(status)) { 389 if (ACPI_SUCCESS(status)) {
336 (void)acpi_os_delete_semaphore(obj_desc->event.semaphore); 390 (void)acpi_os_delete_semaphore(obj_desc->event.os_semaphore);
337 obj_desc->event.semaphore = temp_semaphore; 391 obj_desc->event.os_semaphore = temp_semaphore;
338 } 392 }
339 393
340 return (status); 394 return (status);
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 1cd25784b7a4..38acc69b21bc 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -78,7 +78,6 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
78 struct acpi_fan *fan = seq->private; 78 struct acpi_fan *fan = seq->private;
79 int state = 0; 79 int state = 0;
80 80
81 ACPI_FUNCTION_TRACE("acpi_fan_read_state");
82 81
83 if (fan) { 82 if (fan) {
84 if (acpi_bus_get_power(fan->handle, &state)) 83 if (acpi_bus_get_power(fan->handle, &state))
@@ -87,7 +86,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
87 seq_printf(seq, "status: %s\n", 86 seq_printf(seq, "status: %s\n",
88 !state ? "on" : "off"); 87 !state ? "on" : "off");
89 } 88 }
90 return_VALUE(0); 89 return 0;
91} 90}
92 91
93static int acpi_fan_state_open_fs(struct inode *inode, struct file *file) 92static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
@@ -104,22 +103,21 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
104 struct acpi_fan *fan = (struct acpi_fan *)m->private; 103 struct acpi_fan *fan = (struct acpi_fan *)m->private;
105 char state_string[12] = { '\0' }; 104 char state_string[12] = { '\0' };
106 105
107 ACPI_FUNCTION_TRACE("acpi_fan_write_state");
108 106
109 if (!fan || (count > sizeof(state_string) - 1)) 107 if (!fan || (count > sizeof(state_string) - 1))
110 return_VALUE(-EINVAL); 108 return -EINVAL;
111 109
112 if (copy_from_user(state_string, buffer, count)) 110 if (copy_from_user(state_string, buffer, count))
113 return_VALUE(-EFAULT); 111 return -EFAULT;
114 112
115 state_string[count] = '\0'; 113 state_string[count] = '\0';
116 114
117 result = acpi_bus_set_power(fan->handle, 115 result = acpi_bus_set_power(fan->handle,
118 simple_strtoul(state_string, NULL, 0)); 116 simple_strtoul(state_string, NULL, 0));
119 if (result) 117 if (result)
120 return_VALUE(result); 118 return result;
121 119
122 return_VALUE(count); 120 return count;
123} 121}
124 122
125static struct file_operations acpi_fan_state_ops = { 123static struct file_operations acpi_fan_state_ops = {
@@ -135,16 +133,15 @@ static int acpi_fan_add_fs(struct acpi_device *device)
135{ 133{
136 struct proc_dir_entry *entry = NULL; 134 struct proc_dir_entry *entry = NULL;
137 135
138 ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
139 136
140 if (!device) 137 if (!device)
141 return_VALUE(-EINVAL); 138 return -EINVAL;
142 139
143 if (!acpi_device_dir(device)) { 140 if (!acpi_device_dir(device)) {
144 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 141 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
145 acpi_fan_dir); 142 acpi_fan_dir);
146 if (!acpi_device_dir(device)) 143 if (!acpi_device_dir(device))
147 return_VALUE(-ENODEV); 144 return -ENODEV;
148 acpi_device_dir(device)->owner = THIS_MODULE; 145 acpi_device_dir(device)->owner = THIS_MODULE;
149 } 146 }
150 147
@@ -153,21 +150,18 @@ static int acpi_fan_add_fs(struct acpi_device *device)
153 S_IFREG | S_IRUGO | S_IWUSR, 150 S_IFREG | S_IRUGO | S_IWUSR,
154 acpi_device_dir(device)); 151 acpi_device_dir(device));
155 if (!entry) 152 if (!entry)
156 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 153 return -ENODEV;
157 "Unable to create '%s' fs entry\n",
158 ACPI_FAN_FILE_STATE));
159 else { 154 else {
160 entry->proc_fops = &acpi_fan_state_ops; 155 entry->proc_fops = &acpi_fan_state_ops;
161 entry->data = acpi_driver_data(device); 156 entry->data = acpi_driver_data(device);
162 entry->owner = THIS_MODULE; 157 entry->owner = THIS_MODULE;
163 } 158 }
164 159
165 return_VALUE(0); 160 return 0;
166} 161}
167 162
168static int acpi_fan_remove_fs(struct acpi_device *device) 163static int acpi_fan_remove_fs(struct acpi_device *device)
169{ 164{
170 ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
171 165
172 if (acpi_device_dir(device)) { 166 if (acpi_device_dir(device)) {
173 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device)); 167 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
@@ -175,7 +169,7 @@ static int acpi_fan_remove_fs(struct acpi_device *device)
175 acpi_device_dir(device) = NULL; 169 acpi_device_dir(device) = NULL;
176 } 170 }
177 171
178 return_VALUE(0); 172 return 0;
179} 173}
180 174
181/* -------------------------------------------------------------------------- 175/* --------------------------------------------------------------------------
@@ -188,14 +182,13 @@ static int acpi_fan_add(struct acpi_device *device)
188 struct acpi_fan *fan = NULL; 182 struct acpi_fan *fan = NULL;
189 int state = 0; 183 int state = 0;
190 184
191 ACPI_FUNCTION_TRACE("acpi_fan_add");
192 185
193 if (!device) 186 if (!device)
194 return_VALUE(-EINVAL); 187 return -EINVAL;
195 188
196 fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL); 189 fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL);
197 if (!fan) 190 if (!fan)
198 return_VALUE(-ENOMEM); 191 return -ENOMEM;
199 memset(fan, 0, sizeof(struct acpi_fan)); 192 memset(fan, 0, sizeof(struct acpi_fan));
200 193
201 fan->handle = device->handle; 194 fan->handle = device->handle;
@@ -205,8 +198,7 @@ static int acpi_fan_add(struct acpi_device *device)
205 198
206 result = acpi_bus_get_power(fan->handle, &state); 199 result = acpi_bus_get_power(fan->handle, &state);
207 if (result) { 200 if (result) {
208 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 201 printk(KERN_ERR PREFIX "Reading power state\n");
209 "Error reading power state\n"));
210 goto end; 202 goto end;
211 } 203 }
212 204
@@ -226,17 +218,16 @@ static int acpi_fan_add(struct acpi_device *device)
226 if (result) 218 if (result)
227 kfree(fan); 219 kfree(fan);
228 220
229 return_VALUE(result); 221 return result;
230} 222}
231 223
232static int acpi_fan_remove(struct acpi_device *device, int type) 224static int acpi_fan_remove(struct acpi_device *device, int type)
233{ 225{
234 struct acpi_fan *fan = NULL; 226 struct acpi_fan *fan = NULL;
235 227
236 ACPI_FUNCTION_TRACE("acpi_fan_remove");
237 228
238 if (!device || !acpi_driver_data(device)) 229 if (!device || !acpi_driver_data(device))
239 return_VALUE(-EINVAL); 230 return -EINVAL;
240 231
241 fan = (struct acpi_fan *)acpi_driver_data(device); 232 fan = (struct acpi_fan *)acpi_driver_data(device);
242 233
@@ -244,7 +235,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
244 235
245 kfree(fan); 236 kfree(fan);
246 237
247 return_VALUE(0); 238 return 0;
248} 239}
249 240
250static int acpi_fan_suspend(struct acpi_device *device, int state) 241static int acpi_fan_suspend(struct acpi_device *device, int state)
@@ -283,31 +274,29 @@ static int __init acpi_fan_init(void)
283{ 274{
284 int result = 0; 275 int result = 0;
285 276
286 ACPI_FUNCTION_TRACE("acpi_fan_init");
287 277
288 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); 278 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
289 if (!acpi_fan_dir) 279 if (!acpi_fan_dir)
290 return_VALUE(-ENODEV); 280 return -ENODEV;
291 acpi_fan_dir->owner = THIS_MODULE; 281 acpi_fan_dir->owner = THIS_MODULE;
292 282
293 result = acpi_bus_register_driver(&acpi_fan_driver); 283 result = acpi_bus_register_driver(&acpi_fan_driver);
294 if (result < 0) { 284 if (result < 0) {
295 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); 285 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
296 return_VALUE(-ENODEV); 286 return -ENODEV;
297 } 287 }
298 288
299 return_VALUE(0); 289 return 0;
300} 290}
301 291
302static void __exit acpi_fan_exit(void) 292static void __exit acpi_fan_exit(void)
303{ 293{
304 ACPI_FUNCTION_TRACE("acpi_fan_exit");
305 294
306 acpi_bus_unregister_driver(&acpi_fan_driver); 295 acpi_bus_unregister_driver(&acpi_fan_driver);
307 296
308 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); 297 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
309 298
310 return_VOID; 299 return;
311} 300}
312 301
313module_init(acpi_fan_init); 302module_init(acpi_fan_init);
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index ae142de19507..3143f36fcec9 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -172,9 +172,9 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
172 } 172 }
173 173
174 /* 174 /*
175 * The package must have at least two elements. NOTE (March 2005): This 175 * The package must have at least two elements. NOTE (March 2005): This
176 * goes against the current ACPI spec which defines this object as a 176 * goes against the current ACPI spec which defines this object as a
177 * package with one encoded DWORD element. However, existing practice 177 * package with one encoded DWORD element. However, existing practice
178 * by BIOS vendors seems to be to have 2 or more elements, at least 178 * by BIOS vendors seems to be to have 2 or more elements, at least
179 * one per sleep type (A/B). 179 * one per sleep type (A/B).
180 */ 180 */
@@ -255,7 +255,7 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
255 * return_value - Value that was read from the register 255 * return_value - Value that was read from the register
256 * Flags - Lock the hardware or not 256 * Flags - Lock the hardware or not
257 * 257 *
258 * RETURN: Status and the value read from specified Register. Value 258 * RETURN: Status and the value read from specified Register. Value
259 * returned is normalized to bit0 (is shifted all the way right) 259 * returned is normalized to bit0 (is shifted all the way right)
260 * 260 *
261 * DESCRIPTION: ACPI bit_register read function. 261 * DESCRIPTION: ACPI bit_register read function.
@@ -361,8 +361,8 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
361 case ACPI_REGISTER_PM1_STATUS: 361 case ACPI_REGISTER_PM1_STATUS:
362 362
363 /* 363 /*
364 * Status Registers are different from the rest. Clear by 364 * Status Registers are different from the rest. Clear by
365 * writing 1, and writing 0 has no effect. So, the only relevant 365 * writing 1, and writing 0 has no effect. So, the only relevant
366 * information is the single bit we're interested in, all others should 366 * information is the single bit we're interested in, all others should
367 * be written as 0 so they will be left unchanged. 367 * be written as 0 so they will be left unchanged.
368 */ 368 */
@@ -467,14 +467,13 @@ ACPI_EXPORT_SYMBOL(acpi_set_register)
467 * 467 *
468 * FUNCTION: acpi_hw_register_read 468 * FUNCTION: acpi_hw_register_read
469 * 469 *
470 * PARAMETERS: use_lock - Mutex hw access 470 * PARAMETERS: use_lock - Lock hardware? True/False
471 * register_id - register_iD + Offset 471 * register_id - ACPI Register ID
472 * return_value - Where the register value is returned 472 * return_value - Where the register value is returned
473 * 473 *
474 * RETURN: Status and the value read. 474 * RETURN: Status and the value read.
475 * 475 *
476 * DESCRIPTION: Acpi register read function. Registers are read at the 476 * DESCRIPTION: Read from the specified ACPI register
477 * given offset.
478 * 477 *
479 ******************************************************************************/ 478 ******************************************************************************/
480acpi_status 479acpi_status
@@ -580,14 +579,26 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
580 * 579 *
581 * FUNCTION: acpi_hw_register_write 580 * FUNCTION: acpi_hw_register_write
582 * 581 *
583 * PARAMETERS: use_lock - Mutex hw access 582 * PARAMETERS: use_lock - Lock hardware? True/False
584 * register_id - register_iD + Offset 583 * register_id - ACPI Register ID
585 * Value - The value to write 584 * Value - The value to write
586 * 585 *
587 * RETURN: Status 586 * RETURN: Status
588 * 587 *
589 * DESCRIPTION: Acpi register Write function. Registers are written at the 588 * DESCRIPTION: Write to the specified ACPI register
590 * given offset. 589 *
590 * NOTE: In accordance with the ACPI specification, this function automatically
591 * preserves the value of the following bits, meaning that these bits cannot be
592 * changed via this interface:
593 *
594 * PM1_CONTROL[0] = SCI_EN
595 * PM1_CONTROL[9]
596 * PM1_STATUS[11]
597 *
598 * ACPI References:
599 * 1) Hardware Ignored Bits: When software writes to a register with ignored
600 * bit fields, it preserves the ignored bit fields
601 * 2) SCI_EN: OSPM always preserves this bit position
591 * 602 *
592 ******************************************************************************/ 603 ******************************************************************************/
593 604
@@ -595,6 +606,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
595{ 606{
596 acpi_status status; 607 acpi_status status;
597 acpi_cpu_flags lock_flags = 0; 608 acpi_cpu_flags lock_flags = 0;
609 u32 read_value;
598 610
599 ACPI_FUNCTION_TRACE(hw_register_write); 611 ACPI_FUNCTION_TRACE(hw_register_write);
600 612
@@ -605,6 +617,22 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
605 switch (register_id) { 617 switch (register_id) {
606 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 618 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
607 619
620 /* Perform a read first to preserve certain bits (per ACPI spec) */
621
622 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
623 ACPI_REGISTER_PM1_STATUS,
624 &read_value);
625 if (ACPI_FAILURE(status)) {
626 goto unlock_and_exit;
627 }
628
629 /* Insert the bits to be preserved */
630
631 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
632 read_value);
633
634 /* Now we can write the data */
635
608 status = 636 status =
609 acpi_hw_low_level_write(16, value, 637 acpi_hw_low_level_write(16, value,
610 &acpi_gbl_FADT->xpm1a_evt_blk); 638 &acpi_gbl_FADT->xpm1a_evt_blk);
@@ -635,6 +663,25 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
635 663
636 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 664 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
637 665
666 /*
667 * Perform a read first to preserve certain bits (per ACPI spec)
668 *
669 * Note: This includes SCI_EN, we never want to change this bit
670 */
671 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
672 ACPI_REGISTER_PM1_CONTROL,
673 &read_value);
674 if (ACPI_FAILURE(status)) {
675 goto unlock_and_exit;
676 }
677
678 /* Insert the bits to be preserved */
679
680 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
681 read_value);
682
683 /* Now we can write the data */
684
638 status = 685 status =
639 acpi_hw_low_level_write(16, value, 686 acpi_hw_low_level_write(16, value,
640 &acpi_gbl_FADT->xpm1a_cnt_blk); 687 &acpi_gbl_FADT->xpm1a_cnt_blk);
@@ -726,7 +773,7 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
726 return (AE_OK); 773 return (AE_OK);
727 } 774 }
728 775
729 /* Get a local copy of the address. Handles possible alignment issues */ 776 /* Get a local copy of the address. Handles possible alignment issues */
730 777
731 ACPI_MOVE_64_TO_64(&address, &reg->address); 778 ACPI_MOVE_64_TO_64(&address, &reg->address);
732 if (!address) { 779 if (!address) {
@@ -798,7 +845,7 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
798 return (AE_OK); 845 return (AE_OK);
799 } 846 }
800 847
801 /* Get a local copy of the address. Handles possible alignment issues */ 848 /* Get a local copy of the address. Handles possible alignment issues */
802 849
803 ACPI_MOVE_64_TO_64(&address, &reg->address); 850 ACPI_MOVE_64_TO_64(&address, &reg->address);
804 if (!address) { 851 if (!address) {
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
index c25b2b92edcf..fd81a0f5222f 100644
--- a/drivers/acpi/hotkey.c
+++ b/drivers/acpi/hotkey.c
@@ -231,11 +231,10 @@ struct list_head hotkey_entries; /* head of the list of hotkey_list */
231 231
232static int hotkey_info_seq_show(struct seq_file *seq, void *offset) 232static int hotkey_info_seq_show(struct seq_file *seq, void *offset)
233{ 233{
234 ACPI_FUNCTION_TRACE("hotkey_info_seq_show");
235 234
236 seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION); 235 seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION);
237 236
238 return_VALUE(0); 237 return 0;
239} 238}
240 239
241static int hotkey_info_open_fs(struct inode *inode, struct file *file) 240static int hotkey_info_open_fs(struct inode *inode, struct file *file)
@@ -266,7 +265,6 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
266 (struct acpi_polling_hotkey *)seq->private; 265 (struct acpi_polling_hotkey *)seq->private;
267 char *buf; 266 char *buf;
268 267
269 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
270 268
271 if (poll_hotkey->poll_result) { 269 if (poll_hotkey->poll_result) {
272 buf = format_result(poll_hotkey->poll_result); 270 buf = format_result(poll_hotkey->poll_result);
@@ -274,7 +272,7 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
274 seq_printf(seq, "%s", buf); 272 seq_printf(seq, "%s", buf);
275 kfree(buf); 273 kfree(buf);
276 } 274 }
277 return_VALUE(0); 275 return 0;
278} 276}
279 277
280static int hotkey_polling_open_fs(struct inode *inode, struct file *file) 278static int hotkey_polling_open_fs(struct inode *inode, struct file *file)
@@ -293,7 +291,6 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
293 struct list_head *entries; 291 struct list_head *entries;
294 int val = -1; 292 int val = -1;
295 293
296 ACPI_FUNCTION_TRACE("hotkey_get_internal_event");
297 294
298 list_for_each(entries, list->entries) { 295 list_for_each(entries, list->entries) {
299 union acpi_hotkey *key = 296 union acpi_hotkey *key =
@@ -305,7 +302,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
305 } 302 }
306 } 303 }
307 304
308 return_VALUE(val); 305 return val;
309} 306}
310 307
311static void 308static void
@@ -314,15 +311,14 @@ acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data)
314 struct acpi_device *device = NULL; 311 struct acpi_device *device = NULL;
315 u32 internal_event; 312 u32 internal_event;
316 313
317 ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler");
318 314
319 if (acpi_bus_get_device(handle, &device)) 315 if (acpi_bus_get_device(handle, &device))
320 return_VOID; 316 return;
321 317
322 internal_event = hotkey_get_internal_event(event, &global_hotkey_list); 318 internal_event = hotkey_get_internal_event(event, &global_hotkey_list);
323 acpi_bus_generate_event(device, internal_event, 0); 319 acpi_bus_generate_event(device, internal_event, 0);
324 320
325 return_VOID; 321 return;
326} 322}
327 323
328/* Need to invent automatically hotkey add method */ 324/* Need to invent automatically hotkey add method */
@@ -346,7 +342,6 @@ static int create_polling_proc(union acpi_hotkey *device)
346 char proc_name[80]; 342 char proc_name[80];
347 mode_t mode; 343 mode_t mode;
348 344
349 ACPI_FUNCTION_TRACE("create_polling_proc");
350 mode = S_IFREG | S_IRUGO | S_IWUGO; 345 mode = S_IFREG | S_IRUGO | S_IWUGO;
351 346
352 sprintf(proc_name, "%d", device->link.hotkey_standard_num); 347 sprintf(proc_name, "%d", device->link.hotkey_standard_num);
@@ -356,10 +351,7 @@ static int create_polling_proc(union acpi_hotkey *device)
356 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); 351 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir);
357 352
358 if (!proc) { 353 if (!proc) {
359 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 354 return -ENODEV;
360 "Hotkey: Unable to create %s entry\n",
361 device->poll_hotkey.poll_method));
362 return_VALUE(-ENODEV);
363 } else { 355 } else {
364 proc->proc_fops = &hotkey_polling_fops; 356 proc->proc_fops = &hotkey_polling_fops;
365 proc->owner = THIS_MODULE; 357 proc->owner = THIS_MODULE;
@@ -368,7 +360,7 @@ static int create_polling_proc(union acpi_hotkey *device)
368 proc->gid = 0; 360 proc->gid = 0;
369 device->poll_hotkey.proc = proc; 361 device->poll_hotkey.proc = proc;
370 } 362 }
371 return_VALUE(0); 363 return 0;
372} 364}
373 365
374static int hotkey_add(union acpi_hotkey *device) 366static int hotkey_add(union acpi_hotkey *device)
@@ -376,7 +368,6 @@ static int hotkey_add(union acpi_hotkey *device)
376 int status = 0; 368 int status = 0;
377 struct acpi_device *dev = NULL; 369 struct acpi_device *dev = NULL;
378 370
379 ACPI_FUNCTION_TRACE("hotkey_add");
380 371
381 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { 372 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) {
382 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); 373 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
@@ -391,14 +382,13 @@ static int hotkey_add(union acpi_hotkey *device)
391 382
392 list_add_tail(&device->link.entries, global_hotkey_list.entries); 383 list_add_tail(&device->link.entries, global_hotkey_list.entries);
393 384
394 return_VALUE(status); 385 return status;
395} 386}
396 387
397static int hotkey_remove(union acpi_hotkey *device) 388static int hotkey_remove(union acpi_hotkey *device)
398{ 389{
399 struct list_head *entries, *next; 390 struct list_head *entries, *next;
400 391
401 ACPI_FUNCTION_TRACE("hotkey_remove");
402 392
403 list_for_each_safe(entries, next, global_hotkey_list.entries) { 393 list_for_each_safe(entries, next, global_hotkey_list.entries) {
404 union acpi_hotkey *key = 394 union acpi_hotkey *key =
@@ -412,14 +402,13 @@ static int hotkey_remove(union acpi_hotkey *device)
412 } 402 }
413 } 403 }
414 kfree(device); 404 kfree(device);
415 return_VALUE(0); 405 return 0;
416} 406}
417 407
418static int hotkey_update(union acpi_hotkey *key) 408static int hotkey_update(union acpi_hotkey *key)
419{ 409{
420 struct list_head *entries; 410 struct list_head *entries;
421 411
422 ACPI_FUNCTION_TRACE("hotkey_update");
423 412
424 list_for_each(entries, global_hotkey_list.entries) { 413 list_for_each(entries, global_hotkey_list.entries) {
425 union acpi_hotkey *tmp = 414 union acpi_hotkey *tmp =
@@ -461,19 +450,18 @@ static int hotkey_update(union acpi_hotkey *key)
461 */ 450 */
462 kfree(key); 451 kfree(key);
463 } 452 }
464 return_VALUE(0); 453 return 0;
465 break; 454 break;
466 } 455 }
467 } 456 }
468 457
469 return_VALUE(-ENODEV); 458 return -ENODEV;
470} 459}
471 460
472static void free_hotkey_device(union acpi_hotkey *key) 461static void free_hotkey_device(union acpi_hotkey *key)
473{ 462{
474 struct acpi_device *dev; 463 struct acpi_device *dev;
475 464
476 ACPI_FUNCTION_TRACE("free_hotkey_device");
477 465
478 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 466 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
479 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); 467 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
@@ -493,7 +481,7 @@ static void free_hotkey_device(union acpi_hotkey *key)
493 free_poll_hotkey_buffer(key); 481 free_poll_hotkey_buffer(key);
494 } 482 }
495 kfree(key); 483 kfree(key);
496 return_VOID; 484 return;
497} 485}
498 486
499static void free_hotkey_buffer(union acpi_hotkey *key) 487static void free_hotkey_buffer(union acpi_hotkey *key)
@@ -514,7 +502,6 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
514 acpi_handle tmp_handle; 502 acpi_handle tmp_handle;
515 acpi_status status = AE_OK; 503 acpi_status status = AE_OK;
516 504
517 ACPI_FUNCTION_TRACE("init_hotkey_device");
518 505
519 if (std_num < 0 || IS_POLL(std_num) || !key) 506 if (std_num < 0 || IS_POLL(std_num) || !key)
520 goto do_fail; 507 goto do_fail;
@@ -541,9 +528,9 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
541 method, &tmp_handle); 528 method, &tmp_handle);
542 if (ACPI_FAILURE(status)) 529 if (ACPI_FAILURE(status))
543 goto do_fail; 530 goto do_fail;
544 return_VALUE(AE_OK); 531 return AE_OK;
545 do_fail: 532 do_fail:
546 return_VALUE(-ENODEV); 533 return -ENODEV;
547} 534}
548 535
549static int 536static int
@@ -555,7 +542,6 @@ init_poll_hotkey_device(union acpi_hotkey *key,
555 acpi_status status = AE_OK; 542 acpi_status status = AE_OK;
556 acpi_handle tmp_handle; 543 acpi_handle tmp_handle;
557 544
558 ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
559 545
560 if (std_num < 0 || IS_EVENT(std_num) || !key) 546 if (std_num < 0 || IS_EVENT(std_num) || !key)
561 goto do_fail; 547 goto do_fail;
@@ -590,22 +576,20 @@ init_poll_hotkey_device(union acpi_hotkey *key,
590 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 576 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
591 if (!key->poll_hotkey.poll_result) 577 if (!key->poll_hotkey.poll_result)
592 goto do_fail; 578 goto do_fail;
593 return_VALUE(AE_OK); 579 return AE_OK;
594 do_fail: 580 do_fail:
595 return_VALUE(-ENODEV); 581 return -ENODEV;
596} 582}
597 583
598static int hotkey_open_config(struct inode *inode, struct file *file) 584static int hotkey_open_config(struct inode *inode, struct file *file)
599{ 585{
600 ACPI_FUNCTION_TRACE("hotkey_open_config"); 586 return (single_open
601 return_VALUE(single_open
602 (file, hotkey_config_seq_show, PDE(inode)->data)); 587 (file, hotkey_config_seq_show, PDE(inode)->data));
603} 588}
604 589
605static int hotkey_poll_open_config(struct inode *inode, struct file *file) 590static int hotkey_poll_open_config(struct inode *inode, struct file *file)
606{ 591{
607 ACPI_FUNCTION_TRACE("hotkey_poll_open_config"); 592 return (single_open
608 return_VALUE(single_open
609 (file, hotkey_poll_config_seq_show, PDE(inode)->data)); 593 (file, hotkey_poll_config_seq_show, PDE(inode)->data));
610} 594}
611 595
@@ -618,7 +602,6 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
618 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 602 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
619 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; 603 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
620 604
621 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
622 605
623 list_for_each(entries, hotkey_list->entries) { 606 list_for_each(entries, hotkey_list->entries) {
624 union acpi_hotkey *key = 607 union acpi_hotkey *key =
@@ -636,7 +619,7 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
636 } 619 }
637 } 620 }
638 seq_puts(seq, "\n"); 621 seq_puts(seq, "\n");
639 return_VALUE(0); 622 return 0;
640} 623}
641 624
642static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) 625static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
@@ -648,7 +631,6 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
648 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 631 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
649 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; 632 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
650 633
651 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
652 634
653 list_for_each(entries, hotkey_list->entries) { 635 list_for_each(entries, hotkey_list->entries) {
654 union acpi_hotkey *key = 636 union acpi_hotkey *key =
@@ -666,7 +648,7 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
666 } 648 }
667 } 649 }
668 seq_puts(seq, "\n"); 650 seq_puts(seq, "\n");
669 return_VALUE(0); 651 return 0;
670} 652}
671 653
672static int 654static int
@@ -678,7 +660,6 @@ get_parms(char *config_record,
678 char **method, int *internal_event_num, int *external_event_num) 660 char **method, int *internal_event_num, int *external_event_num)
679{ 661{
680 char *tmp, *tmp1, count; 662 char *tmp, *tmp1, count;
681 ACPI_FUNCTION_TRACE(("get_parms"));
682 663
683 sscanf(config_record, "%d", cmd); 664 sscanf(config_record, "%d", cmd);
684 665
@@ -744,9 +725,9 @@ get_parms(char *config_record,
744 0) 725 0)
745 goto do_fail; 726 goto do_fail;
746 727
747 return_VALUE(6); 728 return 6;
748 do_fail: 729 do_fail:
749 return_VALUE(-1); 730 return -1;
750} 731}
751 732
752/* count is length for one input record */ 733/* count is length for one input record */
@@ -763,16 +744,15 @@ static ssize_t hotkey_write_config(struct file *file,
763 int ret = 0; 744 int ret = 0;
764 union acpi_hotkey *key = NULL; 745 union acpi_hotkey *key = NULL;
765 746
766 ACPI_FUNCTION_TRACE(("hotkey_write_config"));
767 747
768 config_record = (char *)kmalloc(count + 1, GFP_KERNEL); 748 config_record = (char *)kmalloc(count + 1, GFP_KERNEL);
769 if (!config_record) 749 if (!config_record)
770 return_VALUE(-ENOMEM); 750 return -ENOMEM;
771 751
772 if (copy_from_user(config_record, buffer, count)) { 752 if (copy_from_user(config_record, buffer, count)) {
773 kfree(config_record); 753 kfree(config_record);
774 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n")); 754 printk(KERN_ERR PREFIX "Invalid data\n");
775 return_VALUE(-EINVAL); 755 return -EINVAL;
776 } 756 }
777 config_record[count] = 0; 757 config_record[count] = 0;
778 758
@@ -792,9 +772,8 @@ static ssize_t hotkey_write_config(struct file *file,
792 kfree(bus_method); 772 kfree(bus_method);
793 kfree(action_handle); 773 kfree(action_handle);
794 kfree(method); 774 kfree(method);
795 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 775 printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret);
796 "Invalid data format ret=%d\n", ret)); 776 return -EINVAL;
797 return_VALUE(-EINVAL);
798 } 777 }
799 778
800 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); 779 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
@@ -806,7 +785,7 @@ static ssize_t hotkey_write_config(struct file *file,
806 tmp = get_hotkey_by_event(&global_hotkey_list, 785 tmp = get_hotkey_by_event(&global_hotkey_list,
807 internal_event_num); 786 internal_event_num);
808 if (!tmp) 787 if (!tmp)
809 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key")); 788 printk(KERN_ERR PREFIX "Invalid key\n");
810 else 789 else
811 memcpy(key, tmp, sizeof(union acpi_hotkey)); 790 memcpy(key, tmp, sizeof(union acpi_hotkey));
812 goto cont_cmd; 791 goto cont_cmd;
@@ -828,8 +807,8 @@ static ssize_t hotkey_write_config(struct file *file,
828 else 807 else
829 free_poll_hotkey_buffer(key); 808 free_poll_hotkey_buffer(key);
830 kfree(key); 809 kfree(key);
831 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n")); 810 printk(KERN_ERR PREFIX "Invalid hotkey\n");
832 return_VALUE(-EINVAL); 811 return -EINVAL;
833 } 812 }
834 813
835 cont_cmd: 814 cont_cmd:
@@ -855,15 +834,15 @@ static ssize_t hotkey_write_config(struct file *file,
855 goto fail_out; 834 goto fail_out;
856 break; 835 break;
857 } 836 }
858 return_VALUE(count); 837 return count;
859 fail_out: 838 fail_out:
860 if (IS_EVENT(internal_event_num)) 839 if (IS_EVENT(internal_event_num))
861 free_hotkey_buffer(key); 840 free_hotkey_buffer(key);
862 else 841 else
863 free_poll_hotkey_buffer(key); 842 free_poll_hotkey_buffer(key);
864 kfree(key); 843 kfree(key);
865 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid key\n")); 844 printk(KERN_ERR PREFIX "invalid key\n");
866 return_VALUE(-EINVAL); 845 return -EINVAL;
867} 846}
868 847
869/* 848/*
@@ -880,7 +859,6 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
880 union acpi_object in_obj; /* the only param we use */ 859 union acpi_object in_obj; /* the only param we use */
881 acpi_status status; 860 acpi_status status;
882 861
883 ACPI_FUNCTION_TRACE("write_acpi_int");
884 params.count = 1; 862 params.count = 1;
885 params.pointer = &in_obj; 863 params.pointer = &in_obj;
886 in_obj.type = ACPI_TYPE_INTEGER; 864 in_obj.type = ACPI_TYPE_INTEGER;
@@ -888,7 +866,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
888 866
889 status = acpi_evaluate_object(handle, (char *)method, &params, output); 867 status = acpi_evaluate_object(handle, (char *)method, &params, output);
890 868
891 return_VALUE(status == AE_OK); 869 return (status == AE_OK);
892} 870}
893 871
894static int read_acpi_int(acpi_handle handle, const char *method, 872static int read_acpi_int(acpi_handle handle, const char *method,
@@ -898,7 +876,6 @@ static int read_acpi_int(acpi_handle handle, const char *method,
898 union acpi_object out_obj; 876 union acpi_object out_obj;
899 acpi_status status; 877 acpi_status status;
900 878
901 ACPI_FUNCTION_TRACE("read_acpi_int");
902 output.length = sizeof(out_obj); 879 output.length = sizeof(out_obj);
903 output.pointer = &out_obj; 880 output.pointer = &out_obj;
904 881
@@ -907,8 +884,8 @@ static int read_acpi_int(acpi_handle handle, const char *method,
907 val->integer.value = out_obj.integer.value; 884 val->integer.value = out_obj.integer.value;
908 val->type = out_obj.type; 885 val->type = out_obj.type;
909 } else 886 } else
910 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "null val pointer")); 887 printk(KERN_ERR PREFIX "null val pointer\n");
911 return_VALUE((status == AE_OK) 888 return ((status == AE_OK)
912 && (out_obj.type == ACPI_TYPE_INTEGER)); 889 && (out_obj.type == ACPI_TYPE_INTEGER));
913} 890}
914 891
@@ -945,24 +922,23 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
945 int event, method_type, type, value; 922 int event, method_type, type, value;
946 union acpi_hotkey *key; 923 union acpi_hotkey *key;
947 924
948 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
949 925
950 arg = (char *)kmalloc(count + 1, GFP_KERNEL); 926 arg = (char *)kmalloc(count + 1, GFP_KERNEL);
951 if (!arg) 927 if (!arg)
952 return_VALUE(-ENOMEM); 928 return -ENOMEM;
953 arg[count] = 0; 929 arg[count] = 0;
954 930
955 if (copy_from_user(arg, buffer, count)) { 931 if (copy_from_user(arg, buffer, count)) {
956 kfree(arg); 932 kfree(arg);
957 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2")); 933 printk(KERN_ERR PREFIX "Invalid argument 2\n");
958 return_VALUE(-EINVAL); 934 return -EINVAL;
959 } 935 }
960 936
961 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 937 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) !=
962 4) { 938 4) {
963 kfree(arg); 939 kfree(arg);
964 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); 940 printk(KERN_ERR PREFIX "Invalid argument 3\n");
965 return_VALUE(-EINVAL); 941 return -EINVAL;
966 } 942 }
967 kfree(arg); 943 kfree(arg);
968 if (type == ACPI_TYPE_INTEGER) { 944 if (type == ACPI_TYPE_INTEGER) {
@@ -987,12 +963,12 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
987 963
988 } 964 }
989 } else { 965 } else {
990 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported")); 966 printk(KERN_WARNING "Not supported\n");
991 return_VALUE(-EINVAL); 967 return -EINVAL;
992 } 968 }
993 return_VALUE(count); 969 return count;
994 do_fail: 970 do_fail:
995 return_VALUE(-EINVAL); 971 return -EINVAL;
996 972
997} 973}
998 974
@@ -1001,7 +977,6 @@ static int __init hotkey_init(void)
1001 int result; 977 int result;
1002 mode_t mode = S_IFREG | S_IRUGO | S_IWUGO; 978 mode_t mode = S_IFREG | S_IRUGO | S_IWUGO;
1003 979
1004 ACPI_FUNCTION_TRACE("hotkey_init");
1005 980
1006 if (acpi_disabled) 981 if (acpi_disabled)
1007 return -ENODEV; 982 return -ENODEV;
@@ -1013,9 +988,6 @@ static int __init hotkey_init(void)
1013 988
1014 hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir); 989 hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir);
1015 if (!hotkey_proc_dir) { 990 if (!hotkey_proc_dir) {
1016 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1017 "Hotkey: Unable to create %s entry\n",
1018 HOTKEY_PROC));
1019 return (-ENODEV); 991 return (-ENODEV);
1020 } 992 }
1021 hotkey_proc_dir->owner = THIS_MODULE; 993 hotkey_proc_dir->owner = THIS_MODULE;
@@ -1023,9 +995,6 @@ static int __init hotkey_init(void)
1023 hotkey_config = 995 hotkey_config =
1024 create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir); 996 create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir);
1025 if (!hotkey_config) { 997 if (!hotkey_config) {
1026 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1027 "Hotkey: Unable to create %s entry\n",
1028 HOTKEY_EV_CONFIG));
1029 goto do_fail1; 998 goto do_fail1;
1030 } else { 999 } else {
1031 hotkey_config->proc_fops = &hotkey_config_fops; 1000 hotkey_config->proc_fops = &hotkey_config_fops;
@@ -1038,10 +1007,6 @@ static int __init hotkey_init(void)
1038 hotkey_poll_config = 1007 hotkey_poll_config =
1039 create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir); 1008 create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir);
1040 if (!hotkey_poll_config) { 1009 if (!hotkey_poll_config) {
1041 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1042 "Hotkey: Unable to create %s entry\n",
1043 HOTKEY_EV_CONFIG));
1044
1045 goto do_fail2; 1010 goto do_fail2;
1046 } else { 1011 } else {
1047 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops; 1012 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops;
@@ -1053,9 +1018,6 @@ static int __init hotkey_init(void)
1053 1018
1054 hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir); 1019 hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir);
1055 if (!hotkey_action) { 1020 if (!hotkey_action) {
1056 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1057 "Hotkey: Unable to create %s entry\n",
1058 HOTKEY_ACTION));
1059 goto do_fail3; 1021 goto do_fail3;
1060 } else { 1022 } else {
1061 hotkey_action->proc_fops = &hotkey_action_fops; 1023 hotkey_action->proc_fops = &hotkey_action_fops;
@@ -1066,9 +1028,6 @@ static int __init hotkey_init(void)
1066 1028
1067 hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir); 1029 hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir);
1068 if (!hotkey_info) { 1030 if (!hotkey_info) {
1069 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1070 "Hotkey: Unable to create %s entry\n",
1071 HOTKEY_INFO));
1072 goto do_fail4; 1031 goto do_fail4;
1073 } else { 1032 } else {
1074 hotkey_info->proc_fops = &hotkey_info_fops; 1033 hotkey_info->proc_fops = &hotkey_info_fops;
@@ -1104,7 +1063,6 @@ static void __exit hotkey_exit(void)
1104{ 1063{
1105 struct list_head *entries, *next; 1064 struct list_head *entries, *next;
1106 1065
1107 ACPI_FUNCTION_TRACE("hotkey_exit");
1108 1066
1109 list_for_each_safe(entries, next, global_hotkey_list.entries) { 1067 list_for_each_safe(entries, next, global_hotkey_list.entries) {
1110 union acpi_hotkey *key = 1068 union acpi_hotkey *key =
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index d51d68f5dd8d..ec6b7f9ede34 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -52,13 +52,12 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
52{ 52{
53 struct resource *requested_res = NULL; 53 struct resource *requested_res = NULL;
54 54
55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
56 55
57 if (res->type == ACPI_RESOURCE_TYPE_IO) { 56 if (res->type == ACPI_RESOURCE_TYPE_IO) {
58 struct acpi_resource_io *io_res = &res->data.io; 57 struct acpi_resource_io *io_res = &res->data.io;
59 58
60 if (io_res->minimum != io_res->maximum) 59 if (io_res->minimum != io_res->maximum)
61 return_VALUE(AE_OK); 60 return AE_OK;
62 if (IS_RESERVED_ADDR 61 if (IS_RESERVED_ADDR
63 (io_res->minimum, io_res->address_length)) { 62 (io_res->minimum, io_res->address_length)) {
64 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 63 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -92,7 +91,7 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
92 91
93 if (requested_res) 92 if (requested_res)
94 requested_res->flags &= ~IORESOURCE_BUSY; 93 requested_res->flags &= ~IORESOURCE_BUSY;
95 return_VALUE(AE_OK); 94 return AE_OK;
96} 95}
97 96
98static int acpi_motherboard_add(struct acpi_device *device) 97static int acpi_motherboard_add(struct acpi_device *device)
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index 48fadade52e2..c1c6c236df9a 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -196,33 +196,30 @@ acpi_status acpi_ns_root_initialize(void)
196 (u8) (ACPI_TO_INTEGER(val) - 1); 196 (u8) (ACPI_TO_INTEGER(val) - 1);
197 197
198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) { 198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
199 /* 199
200 * Create a counting semaphore for the 200 /* Create a counting semaphore for the global lock */
201 * global lock 201
202 */
203 status = 202 status =
204 acpi_os_create_semaphore 203 acpi_os_create_semaphore
205 (ACPI_NO_UNIT_LIMIT, 1, 204 (ACPI_NO_UNIT_LIMIT, 1,
206 &obj_desc->mutex.semaphore); 205 &acpi_gbl_global_lock_semaphore);
207 if (ACPI_FAILURE(status)) { 206 if (ACPI_FAILURE(status)) {
208 acpi_ut_remove_reference 207 acpi_ut_remove_reference
209 (obj_desc); 208 (obj_desc);
210 goto unlock_and_exit; 209 goto unlock_and_exit;
211 } 210 }
212 211
213 /* 212 /* Mark this mutex as very special */
214 * We just created the mutex for the 213
215 * global lock, save it 214 obj_desc->mutex.os_mutex =
216 */ 215 ACPI_GLOBAL_LOCK;
217 acpi_gbl_global_lock_semaphore =
218 obj_desc->mutex.semaphore;
219 } else { 216 } else {
220 /* Create a mutex */ 217 /* Create a mutex */
221 218
222 status = acpi_os_create_semaphore(1, 1, 219 status =
223 &obj_desc-> 220 acpi_os_create_mutex(&obj_desc->
224 mutex. 221 mutex.
225 semaphore); 222 os_mutex);
226 if (ACPI_FAILURE(status)) { 223 if (ACPI_FAILURE(status)) {
227 acpi_ut_remove_reference 224 acpi_ut_remove_reference
228 (obj_desc); 225 (obj_desc);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 1bb558adee66..afd937b158b3 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -137,6 +137,7 @@ void acpi_os_vprintf(const char *fmt, va_list args)
137#endif 137#endif
138} 138}
139 139
140
140extern int acpi_in_resume; 141extern int acpi_in_resume;
141void *acpi_os_allocate(acpi_size size) 142void *acpi_os_allocate(acpi_size size)
142{ 143{
@@ -586,19 +587,18 @@ static void acpi_os_execute_deferred(void *context)
586{ 587{
587 struct acpi_os_dpc *dpc = NULL; 588 struct acpi_os_dpc *dpc = NULL;
588 589
589 ACPI_FUNCTION_TRACE("os_execute_deferred");
590 590
591 dpc = (struct acpi_os_dpc *)context; 591 dpc = (struct acpi_os_dpc *)context;
592 if (!dpc) { 592 if (!dpc) {
593 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); 593 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
594 return_VOID; 594 return;
595 } 595 }
596 596
597 dpc->function(dpc->context); 597 dpc->function(dpc->context);
598 598
599 kfree(dpc); 599 kfree(dpc);
600 600
601 return_VOID; 601 return;
602} 602}
603 603
604static int acpi_os_execute_thread(void *context) 604static int acpi_os_execute_thread(void *context)
@@ -688,35 +688,19 @@ EXPORT_SYMBOL(acpi_os_wait_events_complete);
688/* 688/*
689 * Allocate the memory for a spinlock and initialize it. 689 * Allocate the memory for a spinlock and initialize it.
690 */ 690 */
691acpi_status acpi_os_create_lock(acpi_handle * out_handle) 691acpi_status acpi_os_create_lock(acpi_spinlock * handle)
692{ 692{
693 spinlock_t *lock_ptr; 693 spin_lock_init(*handle);
694
695 ACPI_FUNCTION_TRACE("os_create_lock");
696
697 lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
698
699 spin_lock_init(lock_ptr);
700
701 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
702 694
703 *out_handle = lock_ptr; 695 return AE_OK;
704
705 return_ACPI_STATUS(AE_OK);
706} 696}
707 697
708/* 698/*
709 * Deallocate the memory for a spinlock. 699 * Deallocate the memory for a spinlock.
710 */ 700 */
711void acpi_os_delete_lock(acpi_handle handle) 701void acpi_os_delete_lock(acpi_spinlock handle)
712{ 702{
713 ACPI_FUNCTION_TRACE("os_create_lock"); 703 return;
714
715 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
716
717 acpi_os_free(handle);
718
719 return_VOID;
720} 704}
721 705
722acpi_status 706acpi_status
@@ -724,11 +708,10 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
724{ 708{
725 struct semaphore *sem = NULL; 709 struct semaphore *sem = NULL;
726 710
727 ACPI_FUNCTION_TRACE("os_create_semaphore");
728 711
729 sem = acpi_os_allocate(sizeof(struct semaphore)); 712 sem = acpi_os_allocate(sizeof(struct semaphore));
730 if (!sem) 713 if (!sem)
731 return_ACPI_STATUS(AE_NO_MEMORY); 714 return AE_NO_MEMORY;
732 memset(sem, 0, sizeof(struct semaphore)); 715 memset(sem, 0, sizeof(struct semaphore));
733 716
734 sema_init(sem, initial_units); 717 sema_init(sem, initial_units);
@@ -738,7 +721,7 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
738 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", 721 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
739 *handle, initial_units)); 722 *handle, initial_units));
740 723
741 return_ACPI_STATUS(AE_OK); 724 return AE_OK;
742} 725}
743 726
744EXPORT_SYMBOL(acpi_os_create_semaphore); 727EXPORT_SYMBOL(acpi_os_create_semaphore);
@@ -754,17 +737,16 @@ acpi_status acpi_os_delete_semaphore(acpi_handle handle)
754{ 737{
755 struct semaphore *sem = (struct semaphore *)handle; 738 struct semaphore *sem = (struct semaphore *)handle;
756 739
757 ACPI_FUNCTION_TRACE("os_delete_semaphore");
758 740
759 if (!sem) 741 if (!sem)
760 return_ACPI_STATUS(AE_BAD_PARAMETER); 742 return AE_BAD_PARAMETER;
761 743
762 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); 744 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
763 745
764 acpi_os_free(sem); 746 acpi_os_free(sem);
765 sem = NULL; 747 sem = NULL;
766 748
767 return_ACPI_STATUS(AE_OK); 749 return AE_OK;
768} 750}
769 751
770EXPORT_SYMBOL(acpi_os_delete_semaphore); 752EXPORT_SYMBOL(acpi_os_delete_semaphore);
@@ -784,13 +766,12 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
784 struct semaphore *sem = (struct semaphore *)handle; 766 struct semaphore *sem = (struct semaphore *)handle;
785 int ret = 0; 767 int ret = 0;
786 768
787 ACPI_FUNCTION_TRACE("os_wait_semaphore");
788 769
789 if (!sem || (units < 1)) 770 if (!sem || (units < 1))
790 return_ACPI_STATUS(AE_BAD_PARAMETER); 771 return AE_BAD_PARAMETER;
791 772
792 if (units > 1) 773 if (units > 1)
793 return_ACPI_STATUS(AE_SUPPORT); 774 return AE_SUPPORT;
794 775
795 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", 776 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
796 handle, units, timeout)); 777 handle, units, timeout));
@@ -839,17 +820,17 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
839 } 820 }
840 821
841 if (ACPI_FAILURE(status)) { 822 if (ACPI_FAILURE(status)) {
842 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 823 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
843 "Failed to acquire semaphore[%p|%d|%d], %s\n", 824 "Failed to acquire semaphore[%p|%d|%d], %s",
844 handle, units, timeout, 825 handle, units, timeout,
845 acpi_format_exception(status))); 826 acpi_format_exception(status)));
846 } else { 827 } else {
847 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 828 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
848 "Acquired semaphore[%p|%d|%d]\n", handle, 829 "Acquired semaphore[%p|%d|%d]", handle,
849 units, timeout)); 830 units, timeout));
850 } 831 }
851 832
852 return_ACPI_STATUS(status); 833 return status;
853} 834}
854 835
855EXPORT_SYMBOL(acpi_os_wait_semaphore); 836EXPORT_SYMBOL(acpi_os_wait_semaphore);
@@ -861,20 +842,19 @@ acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
861{ 842{
862 struct semaphore *sem = (struct semaphore *)handle; 843 struct semaphore *sem = (struct semaphore *)handle;
863 844
864 ACPI_FUNCTION_TRACE("os_signal_semaphore");
865 845
866 if (!sem || (units < 1)) 846 if (!sem || (units < 1))
867 return_ACPI_STATUS(AE_BAD_PARAMETER); 847 return AE_BAD_PARAMETER;
868 848
869 if (units > 1) 849 if (units > 1)
870 return_ACPI_STATUS(AE_SUPPORT); 850 return AE_SUPPORT;
871 851
872 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, 852 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
873 units)); 853 units));
874 854
875 up(sem); 855 up(sem);
876 856
877 return_ACPI_STATUS(AE_OK); 857 return AE_OK;
878} 858}
879 859
880EXPORT_SYMBOL(acpi_os_signal_semaphore); 860EXPORT_SYMBOL(acpi_os_signal_semaphore);
@@ -1043,10 +1023,10 @@ EXPORT_SYMBOL(max_cstate);
1043 * handle is a pointer to the spinlock_t. 1023 * handle is a pointer to the spinlock_t.
1044 */ 1024 */
1045 1025
1046acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle) 1026acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1047{ 1027{
1048 acpi_cpu_flags flags; 1028 acpi_cpu_flags flags;
1049 spin_lock_irqsave((spinlock_t *) handle, flags); 1029 spin_lock_irqsave(lockp, flags);
1050 return flags; 1030 return flags;
1051} 1031}
1052 1032
@@ -1054,9 +1034,9 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
1054 * Release a spinlock. See above. 1034 * Release a spinlock. See above.
1055 */ 1035 */
1056 1036
1057void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags) 1037void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1058{ 1038{
1059 spin_unlock_irqrestore((spinlock_t *) handle, flags); 1039 spin_unlock_irqrestore(lockp, flags);
1060} 1040}
1061 1041
1062#ifndef ACPI_USE_LOCAL_CACHE 1042#ifndef ACPI_USE_LOCAL_CACHE
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index 7ee2f2e77525..a02aa62fe1e5 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -469,6 +469,16 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
469 } 469 }
470 470
471 walk_state->thread = thread; 471 walk_state->thread = thread;
472
473 /*
474 * If executing a method, the starting sync_level is this method's
475 * sync_level
476 */
477 if (walk_state->method_desc) {
478 walk_state->thread->current_sync_level =
479 walk_state->method_desc->method.sync_level;
480 }
481
472 acpi_ds_push_walk_state(walk_state, thread); 482 acpi_ds_push_walk_state(walk_state, thread);
473 483
474 /* 484 /*
@@ -505,6 +515,10 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
505 status = 515 status =
506 acpi_ds_call_control_method(thread, walk_state, 516 acpi_ds_call_control_method(thread, walk_state,
507 NULL); 517 NULL);
518 if (ACPI_FAILURE(status)) {
519 status =
520 acpi_ds_method_error(status, walk_state);
521 }
508 522
509 /* 523 /*
510 * If the transfer to the new method method call worked, a new walk 524 * If the transfer to the new method method call worked, a new walk
@@ -525,7 +539,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
525 /* Check for possible multi-thread reentrancy problem */ 539 /* Check for possible multi-thread reentrancy problem */
526 540
527 if ((status == AE_ALREADY_EXISTS) && 541 if ((status == AE_ALREADY_EXISTS) &&
528 (!walk_state->method_desc->method.semaphore)) { 542 (!walk_state->method_desc->method.mutex)) {
529 /* 543 /*
530 * Method tried to create an object twice. The probable cause is 544 * Method tried to create an object twice. The probable cause is
531 * that the method cannot handle reentrancy. 545 * that the method cannot handle reentrancy.
@@ -537,7 +551,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
537 */ 551 */
538 walk_state->method_desc->method.method_flags |= 552 walk_state->method_desc->method.method_flags |=
539 AML_METHOD_SERIALIZED; 553 AML_METHOD_SERIALIZED;
540 walk_state->method_desc->method.concurrency = 1; 554 walk_state->method_desc->method.sync_level = 0;
541 } 555 }
542 } 556 }
543 557
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 2a718df769b5..1e2ae6e7a7e4 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -47,11 +47,10 @@ struct acpi_pci_data {
47static void acpi_pci_data_handler(acpi_handle handle, u32 function, 47static void acpi_pci_data_handler(acpi_handle handle, u32 function,
48 void *context) 48 void *context)
49{ 49{
50 ACPI_FUNCTION_TRACE("acpi_pci_data_handler");
51 50
52 /* TBD: Anything we need to do here? */ 51 /* TBD: Anything we need to do here? */
53 52
54 return_VOID; 53 return;
55} 54}
56 55
57/** 56/**
@@ -68,25 +67,24 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
68 struct acpi_device *device = NULL; 67 struct acpi_device *device = NULL;
69 struct acpi_pci_data *data = NULL; 68 struct acpi_pci_data *data = NULL;
70 69
71 ACPI_FUNCTION_TRACE("acpi_get_pci_id");
72 70
73 if (!id) 71 if (!id)
74 return_ACPI_STATUS(AE_BAD_PARAMETER); 72 return AE_BAD_PARAMETER;
75 73
76 result = acpi_bus_get_device(handle, &device); 74 result = acpi_bus_get_device(handle, &device);
77 if (result) { 75 if (result) {
78 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 76 printk(KERN_ERR PREFIX
79 "Invalid ACPI Bus context for device %s\n", 77 "Invalid ACPI Bus context for device %s\n",
80 acpi_device_bid(device))); 78 acpi_device_bid(device));
81 return_ACPI_STATUS(AE_NOT_EXIST); 79 return AE_NOT_EXIST;
82 } 80 }
83 81
84 status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data); 82 status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data);
85 if (ACPI_FAILURE(status) || !data) { 83 if (ACPI_FAILURE(status) || !data) {
86 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 84 ACPI_EXCEPTION((AE_INFO, status,
87 "Invalid ACPI-PCI context for device %s\n", 85 "Invalid ACPI-PCI context for device %s",
88 acpi_device_bid(device))); 86 acpi_device_bid(device)));
89 return_ACPI_STATUS(status); 87 return status;
90 } 88 }
91 89
92 *id = data->id; 90 *id = data->id;
@@ -103,7 +101,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
103 acpi_device_bid(device), id->segment, id->bus, 101 acpi_device_bid(device), id->segment, id->bus,
104 id->device, id->function)); 102 id->device, id->function));
105 103
106 return_ACPI_STATUS(AE_OK); 104 return AE_OK;
107} 105}
108 106
109EXPORT_SYMBOL(acpi_get_pci_id); 107EXPORT_SYMBOL(acpi_get_pci_id);
@@ -120,14 +118,13 @@ int acpi_pci_bind(struct acpi_device *device)
120 struct pci_dev *dev; 118 struct pci_dev *dev;
121 struct pci_bus *bus; 119 struct pci_bus *bus;
122 120
123 ACPI_FUNCTION_TRACE("acpi_pci_bind");
124 121
125 if (!device || !device->parent) 122 if (!device || !device->parent)
126 return_VALUE(-EINVAL); 123 return -EINVAL;
127 124
128 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 125 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
129 if (!pathname) 126 if (!pathname)
130 return_VALUE(-ENOMEM); 127 return -ENOMEM;
131 memset(pathname, 0, ACPI_PATHNAME_MAX); 128 memset(pathname, 0, ACPI_PATHNAME_MAX);
132 buffer.length = ACPI_PATHNAME_MAX; 129 buffer.length = ACPI_PATHNAME_MAX;
133 buffer.pointer = pathname; 130 buffer.pointer = pathname;
@@ -135,7 +132,7 @@ int acpi_pci_bind(struct acpi_device *device)
135 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 132 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
136 if (!data) { 133 if (!data) {
137 kfree(pathname); 134 kfree(pathname);
138 return_VALUE(-ENOMEM); 135 return -ENOMEM;
139 } 136 }
140 memset(data, 0, sizeof(struct acpi_pci_data)); 137 memset(data, 0, sizeof(struct acpi_pci_data));
141 138
@@ -151,9 +148,9 @@ int acpi_pci_bind(struct acpi_device *device)
151 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, 148 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
152 (void **)&pdata); 149 (void **)&pdata);
153 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { 150 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
154 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 151 ACPI_EXCEPTION((AE_INFO, status,
155 "Invalid ACPI-PCI context for parent device %s\n", 152 "Invalid ACPI-PCI context for parent device %s",
156 acpi_device_bid(device->parent))); 153 acpi_device_bid(device->parent)));
157 result = -ENODEV; 154 result = -ENODEV;
158 goto end; 155 goto end;
159 } 156 }
@@ -206,10 +203,10 @@ int acpi_pci_bind(struct acpi_device *device)
206 goto end; 203 goto end;
207 } 204 }
208 if (!data->dev->bus) { 205 if (!data->dev->bus) {
209 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 206 printk(KERN_ERR PREFIX
210 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 207 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
211 data->id.segment, data->id.bus, 208 data->id.segment, data->id.bus,
212 data->id.device, data->id.function)); 209 data->id.device, data->id.function);
213 result = -ENODEV; 210 result = -ENODEV;
214 goto end; 211 goto end;
215 } 212 }
@@ -237,9 +234,9 @@ int acpi_pci_bind(struct acpi_device *device)
237 */ 234 */
238 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 235 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
239 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
240 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 237 ACPI_EXCEPTION((AE_INFO, status,
241 "Unable to attach ACPI-PCI context to device %s\n", 238 "Unable to attach ACPI-PCI context to device %s",
242 acpi_device_bid(device))); 239 acpi_device_bid(device)));
243 result = -ENODEV; 240 result = -ENODEV;
244 goto end; 241 goto end;
245 } 242 }
@@ -269,7 +266,7 @@ int acpi_pci_bind(struct acpi_device *device)
269 if (result) 266 if (result)
270 kfree(data); 267 kfree(data);
271 268
272 return_VALUE(result); 269 return result;
273} 270}
274 271
275int acpi_pci_unbind(struct acpi_device *device) 272int acpi_pci_unbind(struct acpi_device *device)
@@ -280,14 +277,13 @@ int acpi_pci_unbind(struct acpi_device *device)
280 char *pathname = NULL; 277 char *pathname = NULL;
281 struct acpi_buffer buffer = { 0, NULL }; 278 struct acpi_buffer buffer = { 0, NULL };
282 279
283 ACPI_FUNCTION_TRACE("acpi_pci_unbind");
284 280
285 if (!device || !device->parent) 281 if (!device || !device->parent)
286 return_VALUE(-EINVAL); 282 return -EINVAL;
287 283
288 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 284 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
289 if (!pathname) 285 if (!pathname)
290 return_VALUE(-ENOMEM); 286 return -ENOMEM;
291 memset(pathname, 0, ACPI_PATHNAME_MAX); 287 memset(pathname, 0, ACPI_PATHNAME_MAX);
292 288
293 buffer.length = ACPI_PATHNAME_MAX; 289 buffer.length = ACPI_PATHNAME_MAX;
@@ -301,18 +297,18 @@ int acpi_pci_unbind(struct acpi_device *device)
301 acpi_get_data(device->handle, acpi_pci_data_handler, 297 acpi_get_data(device->handle, acpi_pci_data_handler,
302 (void **)&data); 298 (void **)&data);
303 if (ACPI_FAILURE(status)) { 299 if (ACPI_FAILURE(status)) {
304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 300 ACPI_EXCEPTION((AE_INFO, status,
305 "Unable to get data from device %s\n", 301 "Unable to get data from device %s",
306 acpi_device_bid(device))); 302 acpi_device_bid(device)));
307 result = -ENODEV; 303 result = -ENODEV;
308 goto end; 304 goto end;
309 } 305 }
310 306
311 status = acpi_detach_data(device->handle, acpi_pci_data_handler); 307 status = acpi_detach_data(device->handle, acpi_pci_data_handler);
312 if (ACPI_FAILURE(status)) { 308 if (ACPI_FAILURE(status)) {
313 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 309 ACPI_EXCEPTION((AE_INFO, status,
314 "Unable to detach data from device %s\n", 310 "Unable to detach data from device %s",
315 acpi_device_bid(device))); 311 acpi_device_bid(device)));
316 result = -ENODEV; 312 result = -ENODEV;
317 goto end; 313 goto end;
318 } 314 }
@@ -322,7 +318,7 @@ int acpi_pci_unbind(struct acpi_device *device)
322 kfree(data); 318 kfree(data);
323 319
324 end: 320 end:
325 return_VALUE(result); 321 return result;
326} 322}
327 323
328int 324int
@@ -335,11 +331,10 @@ acpi_pci_bind_root(struct acpi_device *device,
335 char *pathname = NULL; 331 char *pathname = NULL;
336 struct acpi_buffer buffer = { 0, NULL }; 332 struct acpi_buffer buffer = { 0, NULL };
337 333
338 ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
339 334
340 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 335 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
341 if (!pathname) 336 if (!pathname)
342 return_VALUE(-ENOMEM); 337 return -ENOMEM;
343 memset(pathname, 0, ACPI_PATHNAME_MAX); 338 memset(pathname, 0, ACPI_PATHNAME_MAX);
344 339
345 buffer.length = ACPI_PATHNAME_MAX; 340 buffer.length = ACPI_PATHNAME_MAX;
@@ -347,13 +342,13 @@ acpi_pci_bind_root(struct acpi_device *device,
347 342
348 if (!device || !id || !bus) { 343 if (!device || !id || !bus) {
349 kfree(pathname); 344 kfree(pathname);
350 return_VALUE(-EINVAL); 345 return -EINVAL;
351 } 346 }
352 347
353 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 348 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
354 if (!data) { 349 if (!data) {
355 kfree(pathname); 350 kfree(pathname);
356 return_VALUE(-ENOMEM); 351 return -ENOMEM;
357 } 352 }
358 memset(data, 0, sizeof(struct acpi_pci_data)); 353 memset(data, 0, sizeof(struct acpi_pci_data));
359 354
@@ -369,9 +364,9 @@ acpi_pci_bind_root(struct acpi_device *device,
369 364
370 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 365 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
371 if (ACPI_FAILURE(status)) { 366 if (ACPI_FAILURE(status)) {
372 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 367 ACPI_EXCEPTION((AE_INFO, status,
373 "Unable to attach ACPI-PCI context to device %s\n", 368 "Unable to attach ACPI-PCI context to device %s",
374 pathname)); 369 pathname));
375 result = -ENODEV; 370 result = -ENODEV;
376 goto end; 371 goto end;
377 } 372 }
@@ -381,5 +376,5 @@ acpi_pci_bind_root(struct acpi_device *device,
381 if (result != 0) 376 if (result != 0)
382 kfree(data); 377 kfree(data);
383 378
384 return_VALUE(result); 379 return result;
385} 380}
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 65aee79b3971..fb96e3bf969b 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -55,10 +55,9 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
55 struct list_head *node = NULL; 55 struct list_head *node = NULL;
56 struct acpi_prt_entry *entry = NULL; 56 struct acpi_prt_entry *entry = NULL;
57 57
58 ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry");
59 58
60 if (!acpi_prt.count) 59 if (!acpi_prt.count)
61 return_PTR(NULL); 60 return NULL;
62 61
63 /* 62 /*
64 * Parse through all PRT entries looking for a match on the specified 63 * Parse through all PRT entries looking for a match on the specified
@@ -73,12 +72,12 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
73 && (device == entry->id.device) 72 && (device == entry->id.device)
74 && (pin == entry->pin)) { 73 && (pin == entry->pin)) {
75 spin_unlock(&acpi_prt_lock); 74 spin_unlock(&acpi_prt_lock);
76 return_PTR(entry); 75 return entry;
77 } 76 }
78 } 77 }
79 78
80 spin_unlock(&acpi_prt_lock); 79 spin_unlock(&acpi_prt_lock);
81 return_PTR(NULL); 80 return NULL;
82} 81}
83 82
84static int 83static int
@@ -87,14 +86,13 @@ acpi_pci_irq_add_entry(acpi_handle handle,
87{ 86{
88 struct acpi_prt_entry *entry = NULL; 87 struct acpi_prt_entry *entry = NULL;
89 88
90 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry");
91 89
92 if (!prt) 90 if (!prt)
93 return_VALUE(-EINVAL); 91 return -EINVAL;
94 92
95 entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); 93 entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
96 if (!entry) 94 if (!entry)
97 return_VALUE(-ENOMEM); 95 return -ENOMEM;
98 memset(entry, 0, sizeof(struct acpi_prt_entry)); 96 memset(entry, 0, sizeof(struct acpi_prt_entry));
99 97
100 entry->id.segment = segment; 98 entry->id.segment = segment;
@@ -141,7 +139,7 @@ acpi_pci_irq_add_entry(acpi_handle handle,
141 acpi_prt.count++; 139 acpi_prt.count++;
142 spin_unlock(&acpi_prt_lock); 140 spin_unlock(&acpi_prt_lock);
143 141
144 return_VALUE(0); 142 return 0;
145} 143}
146 144
147static void 145static void
@@ -163,11 +161,10 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
163 struct acpi_pci_routing_table *entry = NULL; 161 struct acpi_pci_routing_table *entry = NULL;
164 static int first_time = 1; 162 static int first_time = 1;
165 163
166 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt");
167 164
168 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 165 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
169 if (!pathname) 166 if (!pathname)
170 return_VALUE(-ENOMEM); 167 return -ENOMEM;
171 memset(pathname, 0, ACPI_PATHNAME_MAX); 168 memset(pathname, 0, ACPI_PATHNAME_MAX);
172 169
173 if (first_time) { 170 if (first_time) {
@@ -197,24 +194,24 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
197 kfree(pathname); 194 kfree(pathname);
198 status = acpi_get_irq_routing_table(handle, &buffer); 195 status = acpi_get_irq_routing_table(handle, &buffer);
199 if (status != AE_BUFFER_OVERFLOW) { 196 if (status != AE_BUFFER_OVERFLOW) {
200 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", 197 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
201 acpi_format_exception(status))); 198 acpi_format_exception(status)));
202 return_VALUE(-ENODEV); 199 return -ENODEV;
203 } 200 }
204 201
205 prt = kmalloc(buffer.length, GFP_KERNEL); 202 prt = kmalloc(buffer.length, GFP_KERNEL);
206 if (!prt) { 203 if (!prt) {
207 return_VALUE(-ENOMEM); 204 return -ENOMEM;
208 } 205 }
209 memset(prt, 0, buffer.length); 206 memset(prt, 0, buffer.length);
210 buffer.pointer = prt; 207 buffer.pointer = prt;
211 208
212 status = acpi_get_irq_routing_table(handle, &buffer); 209 status = acpi_get_irq_routing_table(handle, &buffer);
213 if (ACPI_FAILURE(status)) { 210 if (ACPI_FAILURE(status)) {
214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", 211 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
215 acpi_format_exception(status))); 212 acpi_format_exception(status)));
216 kfree(buffer.pointer); 213 kfree(buffer.pointer);
217 return_VALUE(-ENODEV); 214 return -ENODEV;
218 } 215 }
219 216
220 entry = prt; 217 entry = prt;
@@ -227,7 +224,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
227 224
228 kfree(prt); 225 kfree(prt);
229 226
230 return_VALUE(0); 227 return 0;
231} 228}
232 229
233void acpi_pci_irq_del_prt(int segment, int bus) 230void acpi_pci_irq_del_prt(int segment, int bus)
@@ -262,16 +259,15 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
262{ 259{
263 int irq; 260 int irq;
264 261
265 ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq");
266 262
267 if (entry->link.handle) { 263 if (entry->link.handle) {
268 irq = acpi_pci_link_allocate_irq(entry->link.handle, 264 irq = acpi_pci_link_allocate_irq(entry->link.handle,
269 entry->link.index, triggering, 265 entry->link.index, triggering,
270 polarity, link); 266 polarity, link);
271 if (irq < 0) { 267 if (irq < 0) {
272 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 268 printk(KERN_WARNING PREFIX
273 "Invalid IRQ link routing entry\n")); 269 "Invalid IRQ link routing entry\n");
274 return_VALUE(-1); 270 return -1;
275 } 271 }
276 } else { 272 } else {
277 irq = entry->link.index; 273 irq = entry->link.index;
@@ -280,7 +276,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
280 } 276 }
281 277
282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); 278 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
283 return_VALUE(irq); 279 return irq;
284} 280}
285 281
286static int 282static int
@@ -289,13 +285,12 @@ acpi_pci_free_irq(struct acpi_prt_entry *entry,
289{ 285{
290 int irq; 286 int irq;
291 287
292 ACPI_FUNCTION_TRACE("acpi_pci_free_irq");
293 if (entry->link.handle) { 288 if (entry->link.handle) {
294 irq = acpi_pci_link_free_irq(entry->link.handle); 289 irq = acpi_pci_link_free_irq(entry->link.handle);
295 } else { 290 } else {
296 irq = entry->link.index; 291 irq = entry->link.index;
297 } 292 }
298 return_VALUE(irq); 293 return irq;
299} 294}
300 295
301/* 296/*
@@ -315,7 +310,6 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
315 int bus_nr = bus->number; 310 int bus_nr = bus->number;
316 int ret; 311 int ret;
317 312
318 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
319 313
320 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 314 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
321 "Searching for PRT entry for %02x:%02x:%02x[%c]\n", 315 "Searching for PRT entry for %02x:%02x:%02x[%c]\n",
@@ -324,11 +318,11 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
324 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); 318 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
325 if (!entry) { 319 if (!entry) {
326 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n")); 320 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
327 return_VALUE(-1); 321 return -1;
328 } 322 }
329 323
330 ret = func(entry, triggering, polarity, link); 324 ret = func(entry, triggering, polarity, link);
331 return_VALUE(ret); 325 return ret;
332} 326}
333 327
334/* 328/*
@@ -346,10 +340,9 @@ acpi_pci_irq_derive(struct pci_dev *dev,
346 int irq = -1; 340 int irq = -1;
347 u8 bridge_pin = 0; 341 u8 bridge_pin = 0;
348 342
349 ACPI_FUNCTION_TRACE("acpi_pci_irq_derive");
350 343
351 if (!dev) 344 if (!dev)
352 return_VALUE(-EINVAL); 345 return -EINVAL;
353 346
354 /* 347 /*
355 * Attempt to derive an IRQ for this device from a parent bridge's 348 * Attempt to derive an IRQ for this device from a parent bridge's
@@ -366,7 +359,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
366 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 359 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
367 "No interrupt pin configured for device %s\n", 360 "No interrupt pin configured for device %s\n",
368 pci_name(bridge))); 361 pci_name(bridge)));
369 return_VALUE(-1); 362 return -1;
370 } 363 }
371 /* Pin is from 0 to 3 */ 364 /* Pin is from 0 to 3 */
372 bridge_pin--; 365 bridge_pin--;
@@ -379,16 +372,15 @@ acpi_pci_irq_derive(struct pci_dev *dev,
379 } 372 }
380 373
381 if (irq < 0) { 374 if (irq < 0) {
382 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 375 printk(KERN_WARNING PREFIX "Unable to derive IRQ for device %s\n",
383 "Unable to derive IRQ for device %s\n", 376 pci_name(dev));
384 pci_name(dev))); 377 return -1;
385 return_VALUE(-1);
386 } 378 }
387 379
388 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", 380 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n",
389 irq, pci_name(dev), pci_name(bridge))); 381 irq, pci_name(dev), pci_name(bridge)));
390 382
391 return_VALUE(irq); 383 return irq;
392} 384}
393 385
394/* 386/*
@@ -406,24 +398,22 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
406 char *link = NULL; 398 char *link = NULL;
407 int rc; 399 int rc;
408 400
409 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable");
410 401
411 if (!dev) 402 if (!dev)
412 return_VALUE(-EINVAL); 403 return -EINVAL;
413 404
414 pin = dev->pin; 405 pin = dev->pin;
415 if (!pin) { 406 if (!pin) {
416 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 407 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
417 "No interrupt pin configured for device %s\n", 408 "No interrupt pin configured for device %s\n",
418 pci_name(dev))); 409 pci_name(dev)));
419 return_VALUE(0); 410 return 0;
420 } 411 }
421 pin--; 412 pin--;
422 413
423 if (!dev->bus) { 414 if (!dev->bus) {
424 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 415 printk(KERN_ERR PREFIX "Invalid (NULL) 'bus' field\n");
425 "Invalid (NULL) 'bus' field\n")); 416 return -ENODEV;
426 return_VALUE(-ENODEV);
427 } 417 }
428 418
429 /* 419 /*
@@ -455,10 +445,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
455 printk(" - using IRQ %d\n", dev->irq); 445 printk(" - using IRQ %d\n", dev->irq);
456 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, 446 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE,
457 ACPI_ACTIVE_LOW); 447 ACPI_ACTIVE_LOW);
458 return_VALUE(0); 448 return 0;
459 } else { 449 } else {
460 printk("\n"); 450 printk("\n");
461 return_VALUE(0); 451 return 0;
462 } 452 }
463 } 453 }
464 454
@@ -466,7 +456,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
466 if (rc < 0) { 456 if (rc < 0) {
467 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " 457 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
468 "to register GSI\n", pci_name(dev), ('A' + pin)); 458 "to register GSI\n", pci_name(dev), ('A' + pin));
469 return_VALUE(rc); 459 return rc;
470 } 460 }
471 dev->irq = rc; 461 dev->irq = rc;
472 462
@@ -480,7 +470,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
480 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 470 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
481 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 471 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
482 472
483 return_VALUE(0); 473 return 0;
484} 474}
485 475
486EXPORT_SYMBOL(acpi_pci_irq_enable); 476EXPORT_SYMBOL(acpi_pci_irq_enable);
@@ -497,14 +487,13 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
497 int triggering = ACPI_LEVEL_SENSITIVE; 487 int triggering = ACPI_LEVEL_SENSITIVE;
498 int polarity = ACPI_ACTIVE_LOW; 488 int polarity = ACPI_ACTIVE_LOW;
499 489
500 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
501 490
502 if (!dev || !dev->bus) 491 if (!dev || !dev->bus)
503 return_VOID; 492 return;
504 493
505 pin = dev->pin; 494 pin = dev->pin;
506 if (!pin) 495 if (!pin)
507 return_VOID; 496 return;
508 pin--; 497 pin--;
509 498
510 /* 499 /*
@@ -522,7 +511,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
522 &triggering, &polarity, NULL, 511 &triggering, &polarity, NULL,
523 acpi_pci_free_irq); 512 acpi_pci_free_irq);
524 if (gsi < 0) 513 if (gsi < 0)
525 return_VOID; 514 return;
526 515
527 /* 516 /*
528 * TBD: It might be worth clearing dev->irq by magic constant 517 * TBD: It might be worth clearing dev->irq by magic constant
@@ -534,5 +523,5 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
534 523
535 acpi_unregister_gsi(gsi); 524 acpi_unregister_gsi(gsi);
536 525
537 return_VOID; 526 return;
538} 527}
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 228bdb626502..1badce27a83f 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -107,26 +107,23 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
107 struct acpi_pci_link *link = (struct acpi_pci_link *)context; 107 struct acpi_pci_link *link = (struct acpi_pci_link *)context;
108 u32 i = 0; 108 u32 i = 0;
109 109
110 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
111 110
112 switch (resource->type) { 111 switch (resource->type) {
113 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 112 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
114 return_ACPI_STATUS(AE_OK); 113 return AE_OK;
115 case ACPI_RESOURCE_TYPE_IRQ: 114 case ACPI_RESOURCE_TYPE_IRQ:
116 { 115 {
117 struct acpi_resource_irq *p = &resource->data.irq; 116 struct acpi_resource_irq *p = &resource->data.irq;
118 if (!p || !p->interrupt_count) { 117 if (!p || !p->interrupt_count) {
119 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 118 printk(KERN_WARNING PREFIX "Blank IRQ resource\n");
120 "Blank IRQ resource\n")); 119 return AE_OK;
121 return_ACPI_STATUS(AE_OK);
122 } 120 }
123 for (i = 0; 121 for (i = 0;
124 (i < p->interrupt_count 122 (i < p->interrupt_count
125 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 123 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
126 if (!p->interrupts[i]) { 124 if (!p->interrupts[i]) {
127 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 125 printk(KERN_WARNING PREFIX "Invalid IRQ %d\n",
128 "Invalid IRQ %d\n", 126 p->interrupts[i]);
129 p->interrupts[i]));
130 continue; 127 continue;
131 } 128 }
132 link->irq.possible[i] = p->interrupts[i]; 129 link->irq.possible[i] = p->interrupts[i];
@@ -142,17 +139,16 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
142 struct acpi_resource_extended_irq *p = 139 struct acpi_resource_extended_irq *p =
143 &resource->data.extended_irq; 140 &resource->data.extended_irq;
144 if (!p || !p->interrupt_count) { 141 if (!p || !p->interrupt_count) {
145 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 142 printk(KERN_WARNING PREFIX
146 "Blank EXT IRQ resource\n")); 143 "Blank EXT IRQ resource\n");
147 return_ACPI_STATUS(AE_OK); 144 return AE_OK;
148 } 145 }
149 for (i = 0; 146 for (i = 0;
150 (i < p->interrupt_count 147 (i < p->interrupt_count
151 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 148 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
152 if (!p->interrupts[i]) { 149 if (!p->interrupts[i]) {
153 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 150 printk(KERN_WARNING PREFIX "Invalid IRQ %d\n",
154 "Invalid IRQ %d\n", 151 p->interrupts[i]);
155 p->interrupts[i]));
156 continue; 152 continue;
157 } 153 }
158 link->irq.possible[i] = p->interrupts[i]; 154 link->irq.possible[i] = p->interrupts[i];
@@ -164,35 +160,33 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
164 break; 160 break;
165 } 161 }
166 default: 162 default:
167 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 163 printk(KERN_ERR PREFIX "Resource is not an IRQ entry\n");
168 "Resource is not an IRQ entry\n")); 164 return AE_OK;
169 return_ACPI_STATUS(AE_OK);
170 } 165 }
171 166
172 return_ACPI_STATUS(AE_CTRL_TERMINATE); 167 return AE_CTRL_TERMINATE;
173} 168}
174 169
175static int acpi_pci_link_get_possible(struct acpi_pci_link *link) 170static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
176{ 171{
177 acpi_status status; 172 acpi_status status;
178 173
179 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
180 174
181 if (!link) 175 if (!link)
182 return_VALUE(-EINVAL); 176 return -EINVAL;
183 177
184 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, 178 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
185 acpi_pci_link_check_possible, link); 179 acpi_pci_link_check_possible, link);
186 if (ACPI_FAILURE(status)) { 180 if (ACPI_FAILURE(status)) {
187 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n")); 181 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRS"));
188 return_VALUE(-ENODEV); 182 return -ENODEV;
189 } 183 }
190 184
191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 185 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
192 "Found %d possible IRQs\n", 186 "Found %d possible IRQs\n",
193 link->irq.possible_count)); 187 link->irq.possible_count));
194 188
195 return_VALUE(0); 189 return 0;
196} 190}
197 191
198static acpi_status 192static acpi_status
@@ -200,7 +194,6 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
200{ 194{
201 int *irq = (int *)context; 195 int *irq = (int *)context;
202 196
203 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
204 197
205 switch (resource->type) { 198 switch (resource->type) {
206 case ACPI_RESOURCE_TYPE_IRQ: 199 case ACPI_RESOURCE_TYPE_IRQ:
@@ -213,7 +206,7 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
213 */ 206 */
214 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 207 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
215 "Blank IRQ resource\n")); 208 "Blank IRQ resource\n"));
216 return_ACPI_STATUS(AE_OK); 209 return AE_OK;
217 } 210 }
218 *irq = p->interrupts[0]; 211 *irq = p->interrupts[0];
219 break; 212 break;
@@ -227,20 +220,20 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
227 * extended IRQ descriptors must 220 * extended IRQ descriptors must
228 * return at least 1 IRQ 221 * return at least 1 IRQ
229 */ 222 */
230 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 223 printk(KERN_WARNING PREFIX
231 "Blank EXT IRQ resource\n")); 224 "Blank EXT IRQ resource\n");
232 return_ACPI_STATUS(AE_OK); 225 return AE_OK;
233 } 226 }
234 *irq = p->interrupts[0]; 227 *irq = p->interrupts[0];
235 break; 228 break;
236 } 229 }
237 break; 230 break;
238 default: 231 default:
239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type)); 232 printk(KERN_ERR PREFIX "Resource %d isn't an IRQ\n", resource->type);
240 case ACPI_RESOURCE_TYPE_END_TAG: 233 case ACPI_RESOURCE_TYPE_END_TAG:
241 return_ACPI_STATUS(AE_OK); 234 return AE_OK;
242 } 235 }
243 return_ACPI_STATUS(AE_CTRL_TERMINATE); 236 return AE_CTRL_TERMINATE;
244} 237}
245 238
246/* 239/*
@@ -256,10 +249,9 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
256 acpi_status status = AE_OK; 249 acpi_status status = AE_OK;
257 int irq = 0; 250 int irq = 0;
258 251
259 ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
260 252
261 if (!link || !link->handle) 253 if (!link || !link->handle)
262 return_VALUE(-EINVAL); 254 return -EINVAL;
263 255
264 link->irq.active = 0; 256 link->irq.active = 0;
265 257
@@ -268,14 +260,13 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
268 /* Query _STA, set link->device->status */ 260 /* Query _STA, set link->device->status */
269 result = acpi_bus_get_status(link->device); 261 result = acpi_bus_get_status(link->device);
270 if (result) { 262 if (result) {
271 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 263 printk(KERN_ERR PREFIX "Unable to read status\n");
272 "Unable to read status\n"));
273 goto end; 264 goto end;
274 } 265 }
275 266
276 if (!link->device->status.enabled) { 267 if (!link->device->status.enabled) {
277 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n")); 268 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n"));
278 return_VALUE(0); 269 return 0;
279 } 270 }
280 } 271 }
281 272
@@ -286,13 +277,13 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
286 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, 277 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
287 acpi_pci_link_check_current, &irq); 278 acpi_pci_link_check_current, &irq);
288 if (ACPI_FAILURE(status)) { 279 if (ACPI_FAILURE(status)) {
289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n")); 280 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS"));
290 result = -ENODEV; 281 result = -ENODEV;
291 goto end; 282 goto end;
292 } 283 }
293 284
294 if (acpi_strict && !irq) { 285 if (acpi_strict && !irq) {
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n")); 286 printk(KERN_ERR PREFIX "_CRS returned 0\n");
296 result = -ENODEV; 287 result = -ENODEV;
297 } 288 }
298 289
@@ -301,7 +292,7 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
301 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active)); 292 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
302 293
303 end: 294 end:
304 return_VALUE(result); 295 return result;
305} 296}
306 297
307static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) 298static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
@@ -314,14 +305,13 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
314 } *resource; 305 } *resource;
315 struct acpi_buffer buffer = { 0, NULL }; 306 struct acpi_buffer buffer = { 0, NULL };
316 307
317 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
318 308
319 if (!link || !irq) 309 if (!link || !irq)
320 return_VALUE(-EINVAL); 310 return -EINVAL;
321 311
322 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC); 312 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
323 if (!resource) 313 if (!resource)
324 return_VALUE(-ENOMEM); 314 return -ENOMEM;
325 315
326 memset(resource, 0, sizeof(*resource) + 1); 316 memset(resource, 0, sizeof(*resource) + 1);
327 buffer.length = sizeof(*resource) + 1; 317 buffer.length = sizeof(*resource) + 1;
@@ -362,7 +352,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
362 /* ignore resource_source, it's optional */ 352 /* ignore resource_source, it's optional */
363 break; 353 break;
364 default: 354 default:
365 printk("ACPI BUG: resource_type %d\n", link->irq.resource_type); 355 printk(KERN_ERR PREFIX "Invalid Resource_type %d\n", link->irq.resource_type);
366 result = -EINVAL; 356 result = -EINVAL;
367 goto end; 357 goto end;
368 358
@@ -374,7 +364,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
374 364
375 /* check for total failure */ 365 /* check for total failure */
376 if (ACPI_FAILURE(status)) { 366 if (ACPI_FAILURE(status)) {
377 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n")); 367 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SRS"));
378 result = -ENODEV; 368 result = -ENODEV;
379 goto end; 369 goto end;
380 } 370 }
@@ -382,14 +372,14 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
382 /* Query _STA, set device->status */ 372 /* Query _STA, set device->status */
383 result = acpi_bus_get_status(link->device); 373 result = acpi_bus_get_status(link->device);
384 if (result) { 374 if (result) {
385 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n")); 375 printk(KERN_ERR PREFIX "Unable to read status\n");
386 goto end; 376 goto end;
387 } 377 }
388 if (!link->device->status.enabled) { 378 if (!link->device->status.enabled) {
389 printk(KERN_WARNING PREFIX 379 printk(KERN_WARNING PREFIX
390 "%s [%s] disabled and referenced, BIOS bug.\n", 380 "%s [%s] disabled and referenced, BIOS bug\n",
391 acpi_device_name(link->device), 381 acpi_device_name(link->device),
392 acpi_device_bid(link->device)); 382 acpi_device_bid(link->device));
393 } 383 }
394 384
395 /* Query _CRS, set link->irq.active */ 385 /* Query _CRS, set link->irq.active */
@@ -408,9 +398,9 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
408 * assume _SRS worked and override _CRS value. 398 * assume _SRS worked and override _CRS value.
409 */ 399 */
410 printk(KERN_WARNING PREFIX 400 printk(KERN_WARNING PREFIX
411 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", 401 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
412 acpi_device_name(link->device), 402 acpi_device_name(link->device),
413 acpi_device_bid(link->device), link->irq.active, irq); 403 acpi_device_bid(link->device), link->irq.active, irq);
414 link->irq.active = irq; 404 link->irq.active = irq;
415 } 405 }
416 406
@@ -418,7 +408,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
418 408
419 end: 409 end:
420 kfree(resource); 410 kfree(resource);
421 return_VALUE(result); 411 return result;
422} 412}
423 413
424/* -------------------------------------------------------------------------- 414/* --------------------------------------------------------------------------
@@ -492,7 +482,6 @@ int __init acpi_irq_penalty_init(void)
492 struct acpi_pci_link *link = NULL; 482 struct acpi_pci_link *link = NULL;
493 int i = 0; 483 int i = 0;
494 484
495 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
496 485
497 /* 486 /*
498 * Update penalties to facilitate IRQ balancing. 487 * Update penalties to facilitate IRQ balancing.
@@ -501,8 +490,7 @@ int __init acpi_irq_penalty_init(void)
501 490
502 link = list_entry(node, struct acpi_pci_link, node); 491 link = list_entry(node, struct acpi_pci_link, node);
503 if (!link) { 492 if (!link) {
504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 493 printk(KERN_ERR PREFIX "Invalid link context\n");
505 "Invalid link context\n"));
506 continue; 494 continue;
507 } 495 }
508 496
@@ -530,7 +518,7 @@ int __init acpi_irq_penalty_init(void)
530 /* Add a penalty for the SCI */ 518 /* Add a penalty for the SCI */
531 acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING; 519 acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING;
532 520
533 return_VALUE(0); 521 return 0;
534} 522}
535 523
536static int acpi_irq_balance; /* 0: static, 1: balance */ 524static int acpi_irq_balance; /* 0: static, 1: balance */
@@ -540,13 +528,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
540 int irq; 528 int irq;
541 int i; 529 int i;
542 530
543 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
544 531
545 if (link->irq.initialized) { 532 if (link->irq.initialized) {
546 if (link->refcnt == 0) 533 if (link->refcnt == 0)
547 /* This means the link is disabled but initialized */ 534 /* This means the link is disabled but initialized */
548 acpi_pci_link_set(link, link->irq.active); 535 acpi_pci_link_set(link, link->irq.active);
549 return_VALUE(0); 536 return 0;
550 } 537 }
551 538
552 /* 539 /*
@@ -562,7 +549,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
562 if (i == link->irq.possible_count) { 549 if (i == link->irq.possible_count) {
563 if (acpi_strict) 550 if (acpi_strict)
564 printk(KERN_WARNING PREFIX "_CRS %d not found" 551 printk(KERN_WARNING PREFIX "_CRS %d not found"
565 " in _PRS\n", link->irq.active); 552 " in _PRS\n", link->irq.active);
566 link->irq.active = 0; 553 link->irq.active = 0;
567 } 554 }
568 555
@@ -589,12 +576,11 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
589 576
590 /* Attempt to enable the link device at this IRQ. */ 577 /* Attempt to enable the link device at this IRQ. */
591 if (acpi_pci_link_set(link, irq)) { 578 if (acpi_pci_link_set(link, irq)) {
592 printk(PREFIX 579 printk(KERN_ERR PREFIX "Unable to set IRQ for %s [%s]. "
593 "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" 580 "Try pci=noacpi or acpi=off\n",
594 "Try pci=noacpi or acpi=off\n", 581 acpi_device_name(link->device),
595 acpi_device_name(link->device), 582 acpi_device_bid(link->device));
596 acpi_device_bid(link->device)); 583 return -ENODEV;
597 return_VALUE(-ENODEV);
598 } else { 584 } else {
599 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; 585 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
600 printk(PREFIX "%s [%s] enabled at IRQ %d\n", 586 printk(PREFIX "%s [%s] enabled at IRQ %d\n",
@@ -604,7 +590,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
604 590
605 link->irq.initialized = 1; 591 link->irq.initialized = 1;
606 592
607 return_VALUE(0); 593 return 0;
608} 594}
609 595
610/* 596/*
@@ -622,36 +608,35 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
622 struct acpi_device *device = NULL; 608 struct acpi_device *device = NULL;
623 struct acpi_pci_link *link = NULL; 609 struct acpi_pci_link *link = NULL;
624 610
625 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
626 611
627 result = acpi_bus_get_device(handle, &device); 612 result = acpi_bus_get_device(handle, &device);
628 if (result) { 613 if (result) {
629 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); 614 printk(KERN_ERR PREFIX "Invalid link device\n");
630 return_VALUE(-1); 615 return -1;
631 } 616 }
632 617
633 link = (struct acpi_pci_link *)acpi_driver_data(device); 618 link = (struct acpi_pci_link *)acpi_driver_data(device);
634 if (!link) { 619 if (!link) {
635 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 620 printk(KERN_ERR PREFIX "Invalid link context\n");
636 return_VALUE(-1); 621 return -1;
637 } 622 }
638 623
639 /* TBD: Support multiple index (IRQ) entries per Link Device */ 624 /* TBD: Support multiple index (IRQ) entries per Link Device */
640 if (index) { 625 if (index) {
641 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index)); 626 printk(KERN_ERR PREFIX "Invalid index %d\n", index);
642 return_VALUE(-1); 627 return -1;
643 } 628 }
644 629
645 mutex_lock(&acpi_link_lock); 630 mutex_lock(&acpi_link_lock);
646 if (acpi_pci_link_allocate(link)) { 631 if (acpi_pci_link_allocate(link)) {
647 mutex_unlock(&acpi_link_lock); 632 mutex_unlock(&acpi_link_lock);
648 return_VALUE(-1); 633 return -1;
649 } 634 }
650 635
651 if (!link->irq.active) { 636 if (!link->irq.active) {
652 mutex_unlock(&acpi_link_lock); 637 mutex_unlock(&acpi_link_lock);
653 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); 638 printk(KERN_ERR PREFIX "Link active IRQ is 0!\n");
654 return_VALUE(-1); 639 return -1;
655 } 640 }
656 link->refcnt++; 641 link->refcnt++;
657 mutex_unlock(&acpi_link_lock); 642 mutex_unlock(&acpi_link_lock);
@@ -665,7 +650,7 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
665 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 650 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
666 "Link %s is referenced\n", 651 "Link %s is referenced\n",
667 acpi_device_bid(link->device))); 652 acpi_device_bid(link->device)));
668 return_VALUE(link->irq.active); 653 return (link->irq.active);
669} 654}
670 655
671/* 656/*
@@ -678,25 +663,24 @@ int acpi_pci_link_free_irq(acpi_handle handle)
678 struct acpi_pci_link *link = NULL; 663 struct acpi_pci_link *link = NULL;
679 acpi_status result; 664 acpi_status result;
680 665
681 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
682 666
683 result = acpi_bus_get_device(handle, &device); 667 result = acpi_bus_get_device(handle, &device);
684 if (result) { 668 if (result) {
685 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); 669 printk(KERN_ERR PREFIX "Invalid link device\n");
686 return_VALUE(-1); 670 return -1;
687 } 671 }
688 672
689 link = (struct acpi_pci_link *)acpi_driver_data(device); 673 link = (struct acpi_pci_link *)acpi_driver_data(device);
690 if (!link) { 674 if (!link) {
691 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 675 printk(KERN_ERR PREFIX "Invalid link context\n");
692 return_VALUE(-1); 676 return -1;
693 } 677 }
694 678
695 mutex_lock(&acpi_link_lock); 679 mutex_lock(&acpi_link_lock);
696 if (!link->irq.initialized) { 680 if (!link->irq.initialized) {
697 mutex_unlock(&acpi_link_lock); 681 mutex_unlock(&acpi_link_lock);
698 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); 682 printk(KERN_ERR PREFIX "Link isn't initialized\n");
699 return_VALUE(-1); 683 return -1;
700 } 684 }
701#ifdef FUTURE_USE 685#ifdef FUTURE_USE
702 /* 686 /*
@@ -718,7 +702,7 @@ int acpi_pci_link_free_irq(acpi_handle handle)
718 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 702 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
719 } 703 }
720 mutex_unlock(&acpi_link_lock); 704 mutex_unlock(&acpi_link_lock);
721 return_VALUE(link->irq.active); 705 return (link->irq.active);
722} 706}
723 707
724/* -------------------------------------------------------------------------- 708/* --------------------------------------------------------------------------
@@ -732,14 +716,13 @@ static int acpi_pci_link_add(struct acpi_device *device)
732 int i = 0; 716 int i = 0;
733 int found = 0; 717 int found = 0;
734 718
735 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
736 719
737 if (!device) 720 if (!device)
738 return_VALUE(-EINVAL); 721 return -EINVAL;
739 722
740 link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); 723 link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
741 if (!link) 724 if (!link)
742 return_VALUE(-ENOMEM); 725 return -ENOMEM;
743 memset(link, 0, sizeof(struct acpi_pci_link)); 726 memset(link, 0, sizeof(struct acpi_pci_link));
744 727
745 link->device = device; 728 link->device = device;
@@ -788,17 +771,16 @@ static int acpi_pci_link_add(struct acpi_device *device)
788 if (result) 771 if (result)
789 kfree(link); 772 kfree(link);
790 773
791 return_VALUE(result); 774 return result;
792} 775}
793 776
794static int acpi_pci_link_resume(struct acpi_pci_link *link) 777static int acpi_pci_link_resume(struct acpi_pci_link *link)
795{ 778{
796 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
797 779
798 if (link->refcnt && link->irq.active && link->irq.initialized) 780 if (link->refcnt && link->irq.active && link->irq.initialized)
799 return_VALUE(acpi_pci_link_set(link, link->irq.active)); 781 return (acpi_pci_link_set(link, link->irq.active));
800 else 782 else
801 return_VALUE(0); 783 return 0;
802} 784}
803 785
804/* 786/*
@@ -811,7 +793,6 @@ static int irqrouter_resume(struct sys_device *dev)
811 struct list_head *node = NULL; 793 struct list_head *node = NULL;
812 struct acpi_pci_link *link = NULL; 794 struct acpi_pci_link *link = NULL;
813 795
814 ACPI_FUNCTION_TRACE("irqrouter_resume");
815 796
816 /* Make sure SCI is enabled again (Apple firmware bug?) */ 797 /* Make sure SCI is enabled again (Apple firmware bug?) */
817 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK); 798 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK);
@@ -820,24 +801,22 @@ static int irqrouter_resume(struct sys_device *dev)
820 list_for_each(node, &acpi_link.entries) { 801 list_for_each(node, &acpi_link.entries) {
821 link = list_entry(node, struct acpi_pci_link, node); 802 link = list_entry(node, struct acpi_pci_link, node);
822 if (!link) { 803 if (!link) {
823 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 804 printk(KERN_ERR PREFIX "Invalid link context\n");
824 "Invalid link context\n"));
825 continue; 805 continue;
826 } 806 }
827 acpi_pci_link_resume(link); 807 acpi_pci_link_resume(link);
828 } 808 }
829 acpi_in_resume = 0; 809 acpi_in_resume = 0;
830 return_VALUE(0); 810 return 0;
831} 811}
832 812
833static int acpi_pci_link_remove(struct acpi_device *device, int type) 813static int acpi_pci_link_remove(struct acpi_device *device, int type)
834{ 814{
835 struct acpi_pci_link *link = NULL; 815 struct acpi_pci_link *link = NULL;
836 816
837 ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
838 817
839 if (!device || !acpi_driver_data(device)) 818 if (!device || !acpi_driver_data(device))
840 return_VALUE(-EINVAL); 819 return -EINVAL;
841 820
842 link = (struct acpi_pci_link *)acpi_driver_data(device); 821 link = (struct acpi_pci_link *)acpi_driver_data(device);
843 822
@@ -847,7 +826,7 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type)
847 826
848 kfree(link); 827 kfree(link);
849 828
850 return_VALUE(0); 829 return 0;
851} 830}
852 831
853/* 832/*
@@ -953,34 +932,32 @@ static int __init irqrouter_init_sysfs(void)
953{ 932{
954 int error; 933 int error;
955 934
956 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
957 935
958 if (acpi_disabled || acpi_noirq) 936 if (acpi_disabled || acpi_noirq)
959 return_VALUE(0); 937 return 0;
960 938
961 error = sysdev_class_register(&irqrouter_sysdev_class); 939 error = sysdev_class_register(&irqrouter_sysdev_class);
962 if (!error) 940 if (!error)
963 error = sysdev_register(&device_irqrouter); 941 error = sysdev_register(&device_irqrouter);
964 942
965 return_VALUE(error); 943 return error;
966} 944}
967 945
968device_initcall(irqrouter_init_sysfs); 946device_initcall(irqrouter_init_sysfs);
969 947
970static int __init acpi_pci_link_init(void) 948static int __init acpi_pci_link_init(void)
971{ 949{
972 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
973 950
974 if (acpi_noirq) 951 if (acpi_noirq)
975 return_VALUE(0); 952 return 0;
976 953
977 acpi_link.count = 0; 954 acpi_link.count = 0;
978 INIT_LIST_HEAD(&acpi_link.entries); 955 INIT_LIST_HEAD(&acpi_link.entries);
979 956
980 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0) 957 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
981 return_VALUE(-ENODEV); 958 return -ENODEV;
982 959
983 return_VALUE(0); 960 return 0;
984} 961}
985 962
986subsys_initcall(acpi_pci_link_init); 963subsys_initcall(acpi_pci_link_init);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 4c313eab6313..8f10442119f0 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -160,14 +160,13 @@ static int acpi_pci_root_add(struct acpi_device *device)
160 unsigned long value = 0; 160 unsigned long value = 0;
161 acpi_handle handle = NULL; 161 acpi_handle handle = NULL;
162 162
163 ACPI_FUNCTION_TRACE("acpi_pci_root_add");
164 163
165 if (!device) 164 if (!device)
166 return_VALUE(-EINVAL); 165 return -EINVAL;
167 166
168 root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 167 root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
169 if (!root) 168 if (!root)
170 return_VALUE(-ENOMEM); 169 return -ENOMEM;
171 memset(root, 0, sizeof(struct acpi_pci_root)); 170 memset(root, 0, sizeof(struct acpi_pci_root));
172 INIT_LIST_HEAD(&root->node); 171 INIT_LIST_HEAD(&root->node);
173 172
@@ -198,7 +197,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
198 root->id.segment = 0; 197 root->id.segment = 0;
199 break; 198 break;
200 default: 199 default:
201 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SEG\n")); 200 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SEG"));
202 result = -ENODEV; 201 result = -ENODEV;
203 goto end; 202 goto end;
204 } 203 }
@@ -219,7 +218,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
219 root->id.bus = 0; 218 root->id.bus = 0;
220 break; 219 break;
221 default: 220 default:
222 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BBN\n")); 221 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BBN"));
223 result = -ENODEV; 222 result = -ENODEV;
224 goto end; 223 goto end;
225 } 224 }
@@ -231,8 +230,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
231 int bus = 0; 230 int bus = 0;
232 acpi_status status; 231 acpi_status status;
233 232
234 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 233 printk(KERN_ERR PREFIX
235 "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); 234 "Wrong _BBN value, reboot"
235 " and use option 'pci=noacpi'\n");
236 236
237 status = try_get_root_bridge_busnr(root->handle, &bus); 237 status = try_get_root_bridge_busnr(root->handle, &bus);
238 if (ACPI_FAILURE(status)) 238 if (ACPI_FAILURE(status))
@@ -273,9 +273,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
273 */ 273 */
274 root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); 274 root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus);
275 if (!root->bus) { 275 if (!root->bus) {
276 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 276 printk(KERN_ERR PREFIX
277 "Bus %04x:%02x not present in PCI namespace\n", 277 "Bus %04x:%02x not present in PCI namespace\n",
278 root->id.segment, root->id.bus)); 278 root->id.segment, root->id.bus);
279 result = -ENODEV; 279 result = -ENODEV;
280 goto end; 280 goto end;
281 } 281 }
@@ -306,46 +306,43 @@ static int acpi_pci_root_add(struct acpi_device *device)
306 kfree(root); 306 kfree(root);
307 } 307 }
308 308
309 return_VALUE(result); 309 return result;
310} 310}
311 311
312static int acpi_pci_root_start(struct acpi_device *device) 312static int acpi_pci_root_start(struct acpi_device *device)
313{ 313{
314 struct acpi_pci_root *root; 314 struct acpi_pci_root *root;
315 315
316 ACPI_FUNCTION_TRACE("acpi_pci_root_start");
317 316
318 list_for_each_entry(root, &acpi_pci_roots, node) { 317 list_for_each_entry(root, &acpi_pci_roots, node) {
319 if (root->handle == device->handle) { 318 if (root->handle == device->handle) {
320 pci_bus_add_devices(root->bus); 319 pci_bus_add_devices(root->bus);
321 return_VALUE(0); 320 return 0;
322 } 321 }
323 } 322 }
324 return_VALUE(-ENODEV); 323 return -ENODEV;
325} 324}
326 325
327static int acpi_pci_root_remove(struct acpi_device *device, int type) 326static int acpi_pci_root_remove(struct acpi_device *device, int type)
328{ 327{
329 struct acpi_pci_root *root = NULL; 328 struct acpi_pci_root *root = NULL;
330 329
331 ACPI_FUNCTION_TRACE("acpi_pci_root_remove");
332 330
333 if (!device || !acpi_driver_data(device)) 331 if (!device || !acpi_driver_data(device))
334 return_VALUE(-EINVAL); 332 return -EINVAL;
335 333
336 root = (struct acpi_pci_root *)acpi_driver_data(device); 334 root = (struct acpi_pci_root *)acpi_driver_data(device);
337 335
338 kfree(root); 336 kfree(root);
339 337
340 return_VALUE(0); 338 return 0;
341} 339}
342 340
343static int __init acpi_pci_root_init(void) 341static int __init acpi_pci_root_init(void)
344{ 342{
345 ACPI_FUNCTION_TRACE("acpi_pci_root_init");
346 343
347 if (acpi_pci_disabled) 344 if (acpi_pci_disabled)
348 return_VALUE(0); 345 return 0;
349 346
350 /* DEBUG: 347 /* DEBUG:
351 acpi_dbg_layer = ACPI_PCI_COMPONENT; 348 acpi_dbg_layer = ACPI_PCI_COMPONENT;
@@ -353,9 +350,9 @@ static int __init acpi_pci_root_init(void)
353 */ 350 */
354 351
355 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) 352 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
356 return_VALUE(-ENODEV); 353 return -ENODEV;
357 354
358 return_VALUE(0); 355 return 0;
359} 356}
360 357
361subsys_initcall(acpi_pci_root_init); 358subsys_initcall(acpi_pci_root_init);
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 62a5595ed8bc..224f729f700e 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -98,23 +98,21 @@ acpi_power_get_context(acpi_handle handle,
98 int result = 0; 98 int result = 0;
99 struct acpi_device *device = NULL; 99 struct acpi_device *device = NULL;
100 100
101 ACPI_FUNCTION_TRACE("acpi_power_get_context");
102 101
103 if (!resource) 102 if (!resource)
104 return_VALUE(-ENODEV); 103 return -ENODEV;
105 104
106 result = acpi_bus_get_device(handle, &device); 105 result = acpi_bus_get_device(handle, &device);
107 if (result) { 106 if (result) {
108 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", 107 printk(KERN_WARNING PREFIX "Getting context [%p]\n", handle);
109 handle)); 108 return result;
110 return_VALUE(result);
111 } 109 }
112 110
113 *resource = (struct acpi_power_resource *)acpi_driver_data(device); 111 *resource = (struct acpi_power_resource *)acpi_driver_data(device);
114 if (!resource) 112 if (!resource)
115 return_VALUE(-ENODEV); 113 return -ENODEV;
116 114
117 return_VALUE(0); 115 return 0;
118} 116}
119 117
120static int acpi_power_get_state(struct acpi_power_resource *resource) 118static int acpi_power_get_state(struct acpi_power_resource *resource)
@@ -122,14 +120,13 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
122 acpi_status status = AE_OK; 120 acpi_status status = AE_OK;
123 unsigned long sta = 0; 121 unsigned long sta = 0;
124 122
125 ACPI_FUNCTION_TRACE("acpi_power_get_state");
126 123
127 if (!resource) 124 if (!resource)
128 return_VALUE(-EINVAL); 125 return -EINVAL;
129 126
130 status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta); 127 status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta);
131 if (ACPI_FAILURE(status)) 128 if (ACPI_FAILURE(status))
132 return_VALUE(-ENODEV); 129 return -ENODEV;
133 130
134 if (sta & 0x01) 131 if (sta & 0x01)
135 resource->state = ACPI_POWER_RESOURCE_STATE_ON; 132 resource->state = ACPI_POWER_RESOURCE_STATE_ON;
@@ -139,7 +136,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
139 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
140 resource->name, resource->state ? "on" : "off")); 137 resource->name, resource->state ? "on" : "off"));
141 138
142 return_VALUE(0); 139 return 0;
143} 140}
144 141
145static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) 142static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
@@ -148,20 +145,19 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
148 struct acpi_power_resource *resource = NULL; 145 struct acpi_power_resource *resource = NULL;
149 u32 i = 0; 146 u32 i = 0;
150 147
151 ACPI_FUNCTION_TRACE("acpi_power_get_list_state");
152 148
153 if (!list || !state) 149 if (!list || !state)
154 return_VALUE(-EINVAL); 150 return -EINVAL;
155 151
156 /* The state of the list is 'on' IFF all resources are 'on'. */ 152 /* The state of the list is 'on' IFF all resources are 'on'. */
157 153
158 for (i = 0; i < list->count; i++) { 154 for (i = 0; i < list->count; i++) {
159 result = acpi_power_get_context(list->handles[i], &resource); 155 result = acpi_power_get_context(list->handles[i], &resource);
160 if (result) 156 if (result)
161 return_VALUE(result); 157 return result;
162 result = acpi_power_get_state(resource); 158 result = acpi_power_get_state(resource);
163 if (result) 159 if (result)
164 return_VALUE(result); 160 return result;
165 161
166 *state = resource->state; 162 *state = resource->state;
167 163
@@ -172,7 +168,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
172 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", 168 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n",
173 *state ? "on" : "off")); 169 *state ? "on" : "off"));
174 170
175 return_VALUE(result); 171 return result;
176} 172}
177 173
178static int acpi_power_on(acpi_handle handle) 174static int acpi_power_on(acpi_handle handle)
@@ -182,11 +178,10 @@ static int acpi_power_on(acpi_handle handle)
182 struct acpi_device *device = NULL; 178 struct acpi_device *device = NULL;
183 struct acpi_power_resource *resource = NULL; 179 struct acpi_power_resource *resource = NULL;
184 180
185 ACPI_FUNCTION_TRACE("acpi_power_on");
186 181
187 result = acpi_power_get_context(handle, &resource); 182 result = acpi_power_get_context(handle, &resource);
188 if (result) 183 if (result)
189 return_VALUE(result); 184 return result;
190 185
191 resource->references++; 186 resource->references++;
192 187
@@ -194,29 +189,29 @@ static int acpi_power_on(acpi_handle handle)
194 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { 189 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) {
195 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", 190 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n",
196 resource->name)); 191 resource->name));
197 return_VALUE(0); 192 return 0;
198 } 193 }
199 194
200 status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL); 195 status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL);
201 if (ACPI_FAILURE(status)) 196 if (ACPI_FAILURE(status))
202 return_VALUE(-ENODEV); 197 return -ENODEV;
203 198
204 result = acpi_power_get_state(resource); 199 result = acpi_power_get_state(resource);
205 if (result) 200 if (result)
206 return_VALUE(result); 201 return result;
207 if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) 202 if (resource->state != ACPI_POWER_RESOURCE_STATE_ON)
208 return_VALUE(-ENOEXEC); 203 return -ENOEXEC;
209 204
210 /* Update the power resource's _device_ power state */ 205 /* Update the power resource's _device_ power state */
211 result = acpi_bus_get_device(resource->handle, &device); 206 result = acpi_bus_get_device(resource->handle, &device);
212 if (result) 207 if (result)
213 return_VALUE(result); 208 return result;
214 device->power.state = ACPI_STATE_D0; 209 device->power.state = ACPI_STATE_D0;
215 210
216 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", 211 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n",
217 resource->name)); 212 resource->name));
218 213
219 return_VALUE(0); 214 return 0;
220} 215}
221 216
222static int acpi_power_off_device(acpi_handle handle) 217static int acpi_power_off_device(acpi_handle handle)
@@ -226,11 +221,10 @@ static int acpi_power_off_device(acpi_handle handle)
226 struct acpi_device *device = NULL; 221 struct acpi_device *device = NULL;
227 struct acpi_power_resource *resource = NULL; 222 struct acpi_power_resource *resource = NULL;
228 223
229 ACPI_FUNCTION_TRACE("acpi_power_off_device");
230 224
231 result = acpi_power_get_context(handle, &resource); 225 result = acpi_power_get_context(handle, &resource);
232 if (result) 226 if (result)
233 return_VALUE(result); 227 return result;
234 228
235 if (resource->references) 229 if (resource->references)
236 resource->references--; 230 resource->references--;
@@ -239,35 +233,35 @@ static int acpi_power_off_device(acpi_handle handle)
239 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 233 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
240 "Resource [%s] is still in use, dereferencing\n", 234 "Resource [%s] is still in use, dereferencing\n",
241 device->pnp.bus_id)); 235 device->pnp.bus_id));
242 return_VALUE(0); 236 return 0;
243 } 237 }
244 238
245 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { 239 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
246 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", 240 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
247 device->pnp.bus_id)); 241 device->pnp.bus_id));
248 return_VALUE(0); 242 return 0;
249 } 243 }
250 244
251 status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL); 245 status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL);
252 if (ACPI_FAILURE(status)) 246 if (ACPI_FAILURE(status))
253 return_VALUE(-ENODEV); 247 return -ENODEV;
254 248
255 result = acpi_power_get_state(resource); 249 result = acpi_power_get_state(resource);
256 if (result) 250 if (result)
257 return_VALUE(result); 251 return result;
258 if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) 252 if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF)
259 return_VALUE(-ENOEXEC); 253 return -ENOEXEC;
260 254
261 /* Update the power resource's _device_ power state */ 255 /* Update the power resource's _device_ power state */
262 result = acpi_bus_get_device(resource->handle, &device); 256 result = acpi_bus_get_device(resource->handle, &device);
263 if (result) 257 if (result)
264 return_VALUE(result); 258 return result;
265 device->power.state = ACPI_STATE_D3; 259 device->power.state = ACPI_STATE_D3;
266 260
267 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", 261 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
268 resource->name)); 262 resource->name));
269 263
270 return_VALUE(0); 264 return 0;
271} 265}
272 266
273/* 267/*
@@ -283,31 +277,29 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev)
283 int i; 277 int i;
284 int ret = 0; 278 int ret = 0;
285 279
286 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power");
287 if (!dev || !dev->wakeup.flags.valid) 280 if (!dev || !dev->wakeup.flags.valid)
288 return_VALUE(-1); 281 return -1;
289 282
290 arg.integer.value = 1; 283 arg.integer.value = 1;
291 /* Open power resource */ 284 /* Open power resource */
292 for (i = 0; i < dev->wakeup.resources.count; i++) { 285 for (i = 0; i < dev->wakeup.resources.count; i++) {
293 ret = acpi_power_on(dev->wakeup.resources.handles[i]); 286 ret = acpi_power_on(dev->wakeup.resources.handles[i]);
294 if (ret) { 287 if (ret) {
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 288 printk(KERN_ERR PREFIX "Transition power state\n");
296 "Error transition power state\n"));
297 dev->wakeup.flags.valid = 0; 289 dev->wakeup.flags.valid = 0;
298 return_VALUE(-1); 290 return -1;
299 } 291 }
300 } 292 }
301 293
302 /* Execute PSW */ 294 /* Execute PSW */
303 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); 295 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
304 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 296 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
305 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); 297 printk(KERN_ERR PREFIX "Evaluate _PSW\n");
306 dev->wakeup.flags.valid = 0; 298 dev->wakeup.flags.valid = 0;
307 ret = -1; 299 ret = -1;
308 } 300 }
309 301
310 return_VALUE(ret); 302 return ret;
311} 303}
312 304
313/* 305/*
@@ -323,32 +315,30 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
323 int i; 315 int i;
324 int ret = 0; 316 int ret = 0;
325 317
326 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power");
327 318
328 if (!dev || !dev->wakeup.flags.valid) 319 if (!dev || !dev->wakeup.flags.valid)
329 return_VALUE(-1); 320 return -1;
330 321
331 arg.integer.value = 0; 322 arg.integer.value = 0;
332 /* Execute PSW */ 323 /* Execute PSW */
333 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); 324 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
334 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 325 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
335 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); 326 printk(KERN_ERR PREFIX "Evaluate _PSW\n");
336 dev->wakeup.flags.valid = 0; 327 dev->wakeup.flags.valid = 0;
337 return_VALUE(-1); 328 return -1;
338 } 329 }
339 330
340 /* Close power resource */ 331 /* Close power resource */
341 for (i = 0; i < dev->wakeup.resources.count; i++) { 332 for (i = 0; i < dev->wakeup.resources.count; i++) {
342 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]); 333 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]);
343 if (ret) { 334 if (ret) {
344 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 335 printk(KERN_ERR PREFIX "Transition power state\n");
345 "Error transition power state\n"));
346 dev->wakeup.flags.valid = 0; 336 dev->wakeup.flags.valid = 0;
347 return_VALUE(-1); 337 return -1;
348 } 338 }
349 } 339 }
350 340
351 return_VALUE(ret); 341 return ret;
352} 342}
353 343
354/* -------------------------------------------------------------------------- 344/* --------------------------------------------------------------------------
@@ -362,10 +352,9 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
362 int list_state = 0; 352 int list_state = 0;
363 int i = 0; 353 int i = 0;
364 354
365 ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state");
366 355
367 if (!device) 356 if (!device)
368 return_VALUE(-EINVAL); 357 return -EINVAL;
369 358
370 device->power.state = ACPI_STATE_UNKNOWN; 359 device->power.state = ACPI_STATE_UNKNOWN;
371 360
@@ -380,17 +369,17 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
380 369
381 result = acpi_power_get_list_state(list, &list_state); 370 result = acpi_power_get_list_state(list, &list_state);
382 if (result) 371 if (result)
383 return_VALUE(result); 372 return result;
384 373
385 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { 374 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
386 device->power.state = i; 375 device->power.state = i;
387 return_VALUE(0); 376 return 0;
388 } 377 }
389 } 378 }
390 379
391 device->power.state = ACPI_STATE_D3; 380 device->power.state = ACPI_STATE_D3;
392 381
393 return_VALUE(0); 382 return 0;
394} 383}
395 384
396int acpi_power_transition(struct acpi_device *device, int state) 385int acpi_power_transition(struct acpi_device *device, int state)
@@ -400,14 +389,13 @@ int acpi_power_transition(struct acpi_device *device, int state)
400 struct acpi_handle_list *tl = NULL; /* Target Resources */ 389 struct acpi_handle_list *tl = NULL; /* Target Resources */
401 int i = 0; 390 int i = 0;
402 391
403 ACPI_FUNCTION_TRACE("acpi_power_transition");
404 392
405 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 393 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
406 return_VALUE(-EINVAL); 394 return -EINVAL;
407 395
408 if ((device->power.state < ACPI_STATE_D0) 396 if ((device->power.state < ACPI_STATE_D0)
409 || (device->power.state > ACPI_STATE_D3)) 397 || (device->power.state > ACPI_STATE_D3))
410 return_VALUE(-ENODEV); 398 return -ENODEV;
411 399
412 cl = &device->power.states[device->power.state].resources; 400 cl = &device->power.states[device->power.state].resources;
413 tl = &device->power.states[state].resources; 401 tl = &device->power.states[state].resources;
@@ -444,11 +432,10 @@ int acpi_power_transition(struct acpi_device *device, int state)
444 device->power.state = state; 432 device->power.state = state;
445 end: 433 end:
446 if (result) 434 if (result)
447 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 435 printk(KERN_WARNING PREFIX "Transitioning device [%s] to D%d\n",
448 "Error transitioning device [%s] to D%d\n", 436 device->pnp.bus_id, state);
449 device->pnp.bus_id, state));
450 437
451 return_VALUE(result); 438 return result;
452} 439}
453 440
454/* -------------------------------------------------------------------------- 441/* --------------------------------------------------------------------------
@@ -461,7 +448,6 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
461{ 448{
462 struct acpi_power_resource *resource = NULL; 449 struct acpi_power_resource *resource = NULL;
463 450
464 ACPI_FUNCTION_TRACE("acpi_power_seq_show");
465 451
466 resource = (struct acpi_power_resource *)seq->private; 452 resource = (struct acpi_power_resource *)seq->private;
467 453
@@ -488,7 +474,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
488 resource->order, resource->references); 474 resource->order, resource->references);
489 475
490 end: 476 end:
491 return_VALUE(0); 477 return 0;
492} 478}
493 479
494static int acpi_power_open_fs(struct inode *inode, struct file *file) 480static int acpi_power_open_fs(struct inode *inode, struct file *file)
@@ -500,36 +486,32 @@ static int acpi_power_add_fs(struct acpi_device *device)
500{ 486{
501 struct proc_dir_entry *entry = NULL; 487 struct proc_dir_entry *entry = NULL;
502 488
503 ACPI_FUNCTION_TRACE("acpi_power_add_fs");
504 489
505 if (!device) 490 if (!device)
506 return_VALUE(-EINVAL); 491 return -EINVAL;
507 492
508 if (!acpi_device_dir(device)) { 493 if (!acpi_device_dir(device)) {
509 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 494 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
510 acpi_power_dir); 495 acpi_power_dir);
511 if (!acpi_device_dir(device)) 496 if (!acpi_device_dir(device))
512 return_VALUE(-ENODEV); 497 return -ENODEV;
513 } 498 }
514 499
515 /* 'status' [R] */ 500 /* 'status' [R] */
516 entry = create_proc_entry(ACPI_POWER_FILE_STATUS, 501 entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
517 S_IRUGO, acpi_device_dir(device)); 502 S_IRUGO, acpi_device_dir(device));
518 if (!entry) 503 if (!entry)
519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 504 return -EIO;
520 "Unable to create '%s' fs entry\n",
521 ACPI_POWER_FILE_STATUS));
522 else { 505 else {
523 entry->proc_fops = &acpi_power_fops; 506 entry->proc_fops = &acpi_power_fops;
524 entry->data = acpi_driver_data(device); 507 entry->data = acpi_driver_data(device);
525 } 508 }
526 509
527 return_VALUE(0); 510 return 0;
528} 511}
529 512
530static int acpi_power_remove_fs(struct acpi_device *device) 513static int acpi_power_remove_fs(struct acpi_device *device)
531{ 514{
532 ACPI_FUNCTION_TRACE("acpi_power_remove_fs");
533 515
534 if (acpi_device_dir(device)) { 516 if (acpi_device_dir(device)) {
535 remove_proc_entry(ACPI_POWER_FILE_STATUS, 517 remove_proc_entry(ACPI_POWER_FILE_STATUS,
@@ -538,7 +520,7 @@ static int acpi_power_remove_fs(struct acpi_device *device)
538 acpi_device_dir(device) = NULL; 520 acpi_device_dir(device) = NULL;
539 } 521 }
540 522
541 return_VALUE(0); 523 return 0;
542} 524}
543 525
544/* -------------------------------------------------------------------------- 526/* --------------------------------------------------------------------------
@@ -553,14 +535,13 @@ static int acpi_power_add(struct acpi_device *device)
553 union acpi_object acpi_object; 535 union acpi_object acpi_object;
554 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; 536 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
555 537
556 ACPI_FUNCTION_TRACE("acpi_power_add");
557 538
558 if (!device) 539 if (!device)
559 return_VALUE(-EINVAL); 540 return -EINVAL;
560 541
561 resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); 542 resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
562 if (!resource) 543 if (!resource)
563 return_VALUE(-ENOMEM); 544 return -ENOMEM;
564 memset(resource, 0, sizeof(struct acpi_power_resource)); 545 memset(resource, 0, sizeof(struct acpi_power_resource));
565 546
566 resource->handle = device->handle; 547 resource->handle = device->handle;
@@ -605,17 +586,16 @@ static int acpi_power_add(struct acpi_device *device)
605 if (result) 586 if (result)
606 kfree(resource); 587 kfree(resource);
607 588
608 return_VALUE(result); 589 return result;
609} 590}
610 591
611static int acpi_power_remove(struct acpi_device *device, int type) 592static int acpi_power_remove(struct acpi_device *device, int type)
612{ 593{
613 struct acpi_power_resource *resource = NULL; 594 struct acpi_power_resource *resource = NULL;
614 595
615 ACPI_FUNCTION_TRACE("acpi_power_remove");
616 596
617 if (!device || !acpi_driver_data(device)) 597 if (!device || !acpi_driver_data(device))
618 return_VALUE(-EINVAL); 598 return -EINVAL;
619 599
620 resource = (struct acpi_power_resource *)acpi_driver_data(device); 600 resource = (struct acpi_power_resource *)acpi_driver_data(device);
621 601
@@ -623,31 +603,30 @@ static int acpi_power_remove(struct acpi_device *device, int type)
623 603
624 kfree(resource); 604 kfree(resource);
625 605
626 return_VALUE(0); 606 return 0;
627} 607}
628 608
629static int __init acpi_power_init(void) 609static int __init acpi_power_init(void)
630{ 610{
631 int result = 0; 611 int result = 0;
632 612
633 ACPI_FUNCTION_TRACE("acpi_power_init");
634 613
635 if (acpi_disabled) 614 if (acpi_disabled)
636 return_VALUE(0); 615 return 0;
637 616
638 INIT_LIST_HEAD(&acpi_power_resource_list); 617 INIT_LIST_HEAD(&acpi_power_resource_list);
639 618
640 acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir); 619 acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
641 if (!acpi_power_dir) 620 if (!acpi_power_dir)
642 return_VALUE(-ENODEV); 621 return -ENODEV;
643 622
644 result = acpi_bus_register_driver(&acpi_power_driver); 623 result = acpi_bus_register_driver(&acpi_power_driver);
645 if (result < 0) { 624 if (result < 0) {
646 remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); 625 remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
647 return_VALUE(-ENODEV); 626 return -ENODEV;
648 } 627 }
649 628
650 return_VALUE(0); 629 return 0;
651} 630}
652 631
653subsys_initcall(acpi_power_init); 632subsys_initcall(acpi_power_init);
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index decaebb4cbe9..52674323b14d 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -122,10 +122,9 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
122 u8 value1 = 0; 122 u8 value1 = 0;
123 u8 value2 = 0; 123 u8 value2 = 0;
124 124
125 ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4");
126 125
127 if (!dev) 126 if (!dev)
128 return_VALUE(-EINVAL); 127 return -EINVAL;
129 128
130 /* 129 /*
131 * Note that 'dev' references the PIIX4 ACPI Controller. 130 * Note that 'dev' references the PIIX4 ACPI Controller.
@@ -218,7 +217,7 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
218 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 217 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
219 "Type-F DMA livelock erratum (C3 disabled)\n")); 218 "Type-F DMA livelock erratum (C3 disabled)\n"));
220 219
221 return_VALUE(0); 220 return 0;
222} 221}
223 222
224static int acpi_processor_errata(struct acpi_processor *pr) 223static int acpi_processor_errata(struct acpi_processor *pr)
@@ -226,10 +225,9 @@ static int acpi_processor_errata(struct acpi_processor *pr)
226 int result = 0; 225 int result = 0;
227 struct pci_dev *dev = NULL; 226 struct pci_dev *dev = NULL;
228 227
229 ACPI_FUNCTION_TRACE("acpi_processor_errata");
230 228
231 if (!pr) 229 if (!pr)
232 return_VALUE(-EINVAL); 230 return -EINVAL;
233 231
234 /* 232 /*
235 * PIIX4 233 * PIIX4
@@ -242,7 +240,7 @@ static int acpi_processor_errata(struct acpi_processor *pr)
242 pci_dev_put(dev); 240 pci_dev_put(dev);
243 } 241 }
244 242
245 return_VALUE(result); 243 return result;
246} 244}
247 245
248/* -------------------------------------------------------------------------- 246/* --------------------------------------------------------------------------
@@ -258,10 +256,9 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr)
258 struct acpi_object_list *pdc_in = pr->pdc; 256 struct acpi_object_list *pdc_in = pr->pdc;
259 acpi_status status = AE_OK; 257 acpi_status status = AE_OK;
260 258
261 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
262 259
263 if (!pdc_in) 260 if (!pdc_in)
264 return_VALUE(status); 261 return status;
265 262
266 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL); 263 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
267 264
@@ -269,7 +266,7 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr)
269 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 266 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
270 "Could not evaluate _PDC, using legacy perf. control...\n")); 267 "Could not evaluate _PDC, using legacy perf. control...\n"));
271 268
272 return_VALUE(status); 269 return status;
273} 270}
274 271
275/* -------------------------------------------------------------------------- 272/* --------------------------------------------------------------------------
@@ -282,7 +279,6 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
282{ 279{
283 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 280 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
284 281
285 ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");
286 282
287 if (!pr) 283 if (!pr)
288 goto end; 284 goto end;
@@ -301,7 +297,7 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
301 pr->flags.limit ? "yes" : "no"); 297 pr->flags.limit ? "yes" : "no");
302 298
303 end: 299 end:
304 return_VALUE(0); 300 return 0;
305} 301}
306 302
307static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) 303static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
@@ -314,13 +310,12 @@ static int acpi_processor_add_fs(struct acpi_device *device)
314{ 310{
315 struct proc_dir_entry *entry = NULL; 311 struct proc_dir_entry *entry = NULL;
316 312
317 ACPI_FUNCTION_TRACE("acpi_processor_add_fs");
318 313
319 if (!acpi_device_dir(device)) { 314 if (!acpi_device_dir(device)) {
320 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 315 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
321 acpi_processor_dir); 316 acpi_processor_dir);
322 if (!acpi_device_dir(device)) 317 if (!acpi_device_dir(device))
323 return_VALUE(-ENODEV); 318 return -ENODEV;
324 } 319 }
325 acpi_device_dir(device)->owner = THIS_MODULE; 320 acpi_device_dir(device)->owner = THIS_MODULE;
326 321
@@ -328,9 +323,7 @@ static int acpi_processor_add_fs(struct acpi_device *device)
328 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, 323 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
329 S_IRUGO, acpi_device_dir(device)); 324 S_IRUGO, acpi_device_dir(device));
330 if (!entry) 325 if (!entry)
331 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 326 return -EIO;
332 "Unable to create '%s' fs entry\n",
333 ACPI_PROCESSOR_FILE_INFO));
334 else { 327 else {
335 entry->proc_fops = &acpi_processor_info_fops; 328 entry->proc_fops = &acpi_processor_info_fops;
336 entry->data = acpi_driver_data(device); 329 entry->data = acpi_driver_data(device);
@@ -342,9 +335,7 @@ static int acpi_processor_add_fs(struct acpi_device *device)
342 S_IFREG | S_IRUGO | S_IWUSR, 335 S_IFREG | S_IRUGO | S_IWUSR,
343 acpi_device_dir(device)); 336 acpi_device_dir(device));
344 if (!entry) 337 if (!entry)
345 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 338 return -EIO;
346 "Unable to create '%s' fs entry\n",
347 ACPI_PROCESSOR_FILE_THROTTLING));
348 else { 339 else {
349 entry->proc_fops = &acpi_processor_throttling_fops; 340 entry->proc_fops = &acpi_processor_throttling_fops;
350 entry->data = acpi_driver_data(device); 341 entry->data = acpi_driver_data(device);
@@ -356,21 +347,18 @@ static int acpi_processor_add_fs(struct acpi_device *device)
356 S_IFREG | S_IRUGO | S_IWUSR, 347 S_IFREG | S_IRUGO | S_IWUSR,
357 acpi_device_dir(device)); 348 acpi_device_dir(device));
358 if (!entry) 349 if (!entry)
359 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 350 return -EIO;
360 "Unable to create '%s' fs entry\n",
361 ACPI_PROCESSOR_FILE_LIMIT));
362 else { 351 else {
363 entry->proc_fops = &acpi_processor_limit_fops; 352 entry->proc_fops = &acpi_processor_limit_fops;
364 entry->data = acpi_driver_data(device); 353 entry->data = acpi_driver_data(device);
365 entry->owner = THIS_MODULE; 354 entry->owner = THIS_MODULE;
366 } 355 }
367 356
368 return_VALUE(0); 357 return 0;
369} 358}
370 359
371static int acpi_processor_remove_fs(struct acpi_device *device) 360static int acpi_processor_remove_fs(struct acpi_device *device)
372{ 361{
373 ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
374 362
375 if (acpi_device_dir(device)) { 363 if (acpi_device_dir(device)) {
376 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, 364 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
@@ -383,7 +371,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device)
383 acpi_device_dir(device) = NULL; 371 acpi_device_dir(device) = NULL;
384 } 372 }
385 373
386 return_VALUE(0); 374 return 0;
387} 375}
388 376
389/* Use the acpiid in MADT to map cpus in case of SMP */ 377/* Use the acpiid in MADT to map cpus in case of SMP */
@@ -430,10 +418,9 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
430 int cpu_index; 418 int cpu_index;
431 static int cpu0_initialized; 419 static int cpu0_initialized;
432 420
433 ACPI_FUNCTION_TRACE("acpi_processor_get_info");
434 421
435 if (!pr) 422 if (!pr)
436 return_VALUE(-EINVAL); 423 return -EINVAL;
437 424
438 if (num_online_cpus() > 1) 425 if (num_online_cpus() > 1)
439 errata.smp = TRUE; 426 errata.smp = TRUE;
@@ -459,9 +446,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
459 */ 446 */
460 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 447 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
461 if (ACPI_FAILURE(status)) { 448 if (ACPI_FAILURE(status)) {
462 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 449 printk(KERN_ERR PREFIX "Evaluating processor object\n");
463 "Error evaluating processor object\n")); 450 return -ENODEV;
464 return_VALUE(-ENODEV);
465 } 451 }
466 452
467 /* 453 /*
@@ -490,10 +476,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
490 if (cpu_index == -1) { 476 if (cpu_index == -1) {
491 if (ACPI_FAILURE 477 if (ACPI_FAILURE
492 (acpi_processor_hotadd_init(pr->handle, &pr->id))) { 478 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
493 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 479 printk(KERN_ERR PREFIX
494 "Error getting cpuindex for acpiid 0x%x\n", 480 "Getting cpuindex for acpiid 0x%x\n",
495 pr->acpi_id)); 481 pr->acpi_id);
496 return_VALUE(-ENODEV); 482 return -ENODEV;
497 } 483 }
498 } 484 }
499 485
@@ -503,8 +489,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
503 if (!object.processor.pblk_address) 489 if (!object.processor.pblk_address)
504 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); 490 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
505 else if (object.processor.pblk_length != 6) 491 else if (object.processor.pblk_length != 6)
506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", 492 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
507 object.processor.pblk_length)); 493 object.processor.pblk_length);
508 else { 494 else {
509 pr->throttling.address = object.processor.pblk_address; 495 pr->throttling.address = object.processor.pblk_address;
510 pr->throttling.duty_offset = acpi_fadt.duty_offset; 496 pr->throttling.duty_offset = acpi_fadt.duty_offset;
@@ -528,7 +514,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
528 acpi_processor_get_throttling_info(pr); 514 acpi_processor_get_throttling_info(pr);
529 acpi_processor_get_limit_info(pr); 515 acpi_processor_get_limit_info(pr);
530 516
531 return_VALUE(0); 517 return 0;
532} 518}
533 519
534static void *processor_device_array[NR_CPUS]; 520static void *processor_device_array[NR_CPUS];
@@ -539,14 +525,13 @@ static int acpi_processor_start(struct acpi_device *device)
539 acpi_status status = AE_OK; 525 acpi_status status = AE_OK;
540 struct acpi_processor *pr; 526 struct acpi_processor *pr;
541 527
542 ACPI_FUNCTION_TRACE("acpi_processor_start");
543 528
544 pr = acpi_driver_data(device); 529 pr = acpi_driver_data(device);
545 530
546 result = acpi_processor_get_info(pr); 531 result = acpi_processor_get_info(pr);
547 if (result) { 532 if (result) {
548 /* Processor is physically not present */ 533 /* Processor is physically not present */
549 return_VALUE(0); 534 return 0;
550 } 535 }
551 536
552 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); 537 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
@@ -560,7 +545,7 @@ static int acpi_processor_start(struct acpi_device *device)
560 processor_device_array[pr->id] != (void *)device) { 545 processor_device_array[pr->id] != (void *)device) {
561 printk(KERN_WARNING "BIOS reported wrong ACPI id" 546 printk(KERN_WARNING "BIOS reported wrong ACPI id"
562 "for the processor\n"); 547 "for the processor\n");
563 return_VALUE(-ENODEV); 548 return -ENODEV;
564 } 549 }
565 processor_device_array[pr->id] = (void *)device; 550 processor_device_array[pr->id] = (void *)device;
566 551
@@ -572,10 +557,6 @@ static int acpi_processor_start(struct acpi_device *device)
572 557
573 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 558 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
574 acpi_processor_notify, pr); 559 acpi_processor_notify, pr);
575 if (ACPI_FAILURE(status)) {
576 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
577 "Error installing device notify handler\n"));
578 }
579 560
580 /* _PDC call should be done before doing anything else (if reqd.). */ 561 /* _PDC call should be done before doing anything else (if reqd.). */
581 arch_acpi_processor_init_pdc(pr); 562 arch_acpi_processor_init_pdc(pr);
@@ -592,7 +573,7 @@ static int acpi_processor_start(struct acpi_device *device)
592 573
593 end: 574 end:
594 575
595 return_VALUE(result); 576 return result;
596} 577}
597 578
598static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) 579static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
@@ -600,13 +581,12 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
600 struct acpi_processor *pr = (struct acpi_processor *)data; 581 struct acpi_processor *pr = (struct acpi_processor *)data;
601 struct acpi_device *device = NULL; 582 struct acpi_device *device = NULL;
602 583
603 ACPI_FUNCTION_TRACE("acpi_processor_notify");
604 584
605 if (!pr) 585 if (!pr)
606 return_VOID; 586 return;
607 587
608 if (acpi_bus_get_device(pr->handle, &device)) 588 if (acpi_bus_get_device(pr->handle, &device))
609 return_VOID; 589 return;
610 590
611 switch (event) { 591 switch (event) {
612 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 592 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
@@ -624,21 +604,20 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
624 break; 604 break;
625 } 605 }
626 606
627 return_VOID; 607 return;
628} 608}
629 609
630static int acpi_processor_add(struct acpi_device *device) 610static int acpi_processor_add(struct acpi_device *device)
631{ 611{
632 struct acpi_processor *pr = NULL; 612 struct acpi_processor *pr = NULL;
633 613
634 ACPI_FUNCTION_TRACE("acpi_processor_add");
635 614
636 if (!device) 615 if (!device)
637 return_VALUE(-EINVAL); 616 return -EINVAL;
638 617
639 pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL); 618 pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL);
640 if (!pr) 619 if (!pr)
641 return_VALUE(-ENOMEM); 620 return -ENOMEM;
642 memset(pr, 0, sizeof(struct acpi_processor)); 621 memset(pr, 0, sizeof(struct acpi_processor));
643 622
644 pr->handle = device->handle; 623 pr->handle = device->handle;
@@ -646,7 +625,7 @@ static int acpi_processor_add(struct acpi_device *device)
646 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); 625 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
647 acpi_driver_data(device) = pr; 626 acpi_driver_data(device) = pr;
648 627
649 return_VALUE(0); 628 return 0;
650} 629}
651 630
652static int acpi_processor_remove(struct acpi_device *device, int type) 631static int acpi_processor_remove(struct acpi_device *device, int type)
@@ -654,31 +633,26 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
654 acpi_status status = AE_OK; 633 acpi_status status = AE_OK;
655 struct acpi_processor *pr = NULL; 634 struct acpi_processor *pr = NULL;
656 635
657 ACPI_FUNCTION_TRACE("acpi_processor_remove");
658 636
659 if (!device || !acpi_driver_data(device)) 637 if (!device || !acpi_driver_data(device))
660 return_VALUE(-EINVAL); 638 return -EINVAL;
661 639
662 pr = (struct acpi_processor *)acpi_driver_data(device); 640 pr = (struct acpi_processor *)acpi_driver_data(device);
663 641
664 if (pr->id >= NR_CPUS) { 642 if (pr->id >= NR_CPUS) {
665 kfree(pr); 643 kfree(pr);
666 return_VALUE(0); 644 return 0;
667 } 645 }
668 646
669 if (type == ACPI_BUS_REMOVAL_EJECT) { 647 if (type == ACPI_BUS_REMOVAL_EJECT) {
670 if (acpi_processor_handle_eject(pr)) 648 if (acpi_processor_handle_eject(pr))
671 return_VALUE(-EINVAL); 649 return -EINVAL;
672 } 650 }
673 651
674 acpi_processor_power_exit(pr, device); 652 acpi_processor_power_exit(pr, device);
675 653
676 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 654 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
677 acpi_processor_notify); 655 acpi_processor_notify);
678 if (ACPI_FAILURE(status)) {
679 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
680 "Error removing notify handler\n"));
681 }
682 656
683 acpi_processor_remove_fs(device); 657 acpi_processor_remove_fs(device);
684 658
@@ -686,7 +660,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
686 660
687 kfree(pr); 661 kfree(pr);
688 662
689 return_VALUE(0); 663 return 0;
690} 664}
691 665
692#ifdef CONFIG_ACPI_HOTPLUG_CPU 666#ifdef CONFIG_ACPI_HOTPLUG_CPU
@@ -701,15 +675,13 @@ static int is_processor_present(acpi_handle handle)
701 acpi_status status; 675 acpi_status status;
702 unsigned long sta = 0; 676 unsigned long sta = 0;
703 677
704 ACPI_FUNCTION_TRACE("is_processor_present");
705 678
706 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 679 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
707 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { 680 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) {
708 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 681 ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present"));
709 "Processor Device is not present\n")); 682 return 0;
710 return_VALUE(0);
711 } 683 }
712 return_VALUE(1); 684 return 1;
713} 685}
714 686
715static 687static
@@ -719,30 +691,29 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
719 struct acpi_device *pdev; 691 struct acpi_device *pdev;
720 struct acpi_processor *pr; 692 struct acpi_processor *pr;
721 693
722 ACPI_FUNCTION_TRACE("acpi_processor_device_add");
723 694
724 if (acpi_get_parent(handle, &phandle)) { 695 if (acpi_get_parent(handle, &phandle)) {
725 return_VALUE(-ENODEV); 696 return -ENODEV;
726 } 697 }
727 698
728 if (acpi_bus_get_device(phandle, &pdev)) { 699 if (acpi_bus_get_device(phandle, &pdev)) {
729 return_VALUE(-ENODEV); 700 return -ENODEV;
730 } 701 }
731 702
732 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { 703 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
733 return_VALUE(-ENODEV); 704 return -ENODEV;
734 } 705 }
735 706
736 acpi_bus_start(*device); 707 acpi_bus_start(*device);
737 708
738 pr = acpi_driver_data(*device); 709 pr = acpi_driver_data(*device);
739 if (!pr) 710 if (!pr)
740 return_VALUE(-ENODEV); 711 return -ENODEV;
741 712
742 if ((pr->id >= 0) && (pr->id < NR_CPUS)) { 713 if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
743 kobject_uevent(&(*device)->kobj, KOBJ_ONLINE); 714 kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
744 } 715 }
745 return_VALUE(0); 716 return 0;
746} 717}
747 718
748static void 719static void
@@ -752,7 +723,6 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
752 struct acpi_device *device = NULL; 723 struct acpi_device *device = NULL;
753 int result; 724 int result;
754 725
755 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify");
756 726
757 switch (event) { 727 switch (event) {
758 case ACPI_NOTIFY_BUS_CHECK: 728 case ACPI_NOTIFY_BUS_CHECK:
@@ -767,15 +737,14 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
767 if (acpi_bus_get_device(handle, &device)) { 737 if (acpi_bus_get_device(handle, &device)) {
768 result = acpi_processor_device_add(handle, &device); 738 result = acpi_processor_device_add(handle, &device);
769 if (result) 739 if (result)
770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 740 printk(KERN_ERR PREFIX
771 "Unable to add the device\n")); 741 "Unable to add the device\n");
772 break; 742 break;
773 } 743 }
774 744
775 pr = acpi_driver_data(device); 745 pr = acpi_driver_data(device);
776 if (!pr) { 746 if (!pr) {
777 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 747 printk(KERN_ERR PREFIX "Driver data is NULL\n");
778 "Driver data is NULL\n"));
779 break; 748 break;
780 } 749 }
781 750
@@ -788,9 +757,8 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
788 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { 757 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
789 kobject_uevent(&device->kobj, KOBJ_ONLINE); 758 kobject_uevent(&device->kobj, KOBJ_ONLINE);
790 } else { 759 } else {
791 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 760 printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
792 "Device [%s] failed to start\n", 761 acpi_device_bid(device));
793 acpi_device_bid(device)));
794 } 762 }
795 break; 763 break;
796 case ACPI_NOTIFY_EJECT_REQUEST: 764 case ACPI_NOTIFY_EJECT_REQUEST:
@@ -798,15 +766,15 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
798 "received ACPI_NOTIFY_EJECT_REQUEST\n")); 766 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
799 767
800 if (acpi_bus_get_device(handle, &device)) { 768 if (acpi_bus_get_device(handle, &device)) {
801 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 769 printk(KERN_ERR PREFIX
802 "Device don't exist, dropping EJECT\n")); 770 "Device don't exist, dropping EJECT\n");
803 break; 771 break;
804 } 772 }
805 pr = acpi_driver_data(device); 773 pr = acpi_driver_data(device);
806 if (!pr) { 774 if (!pr) {
807 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 775 printk(KERN_ERR PREFIX
808 "Driver data is NULL, dropping EJECT\n")); 776 "Driver data is NULL, dropping EJECT\n");
809 return_VOID; 777 return;
810 } 778 }
811 779
812 if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) 780 if ((pr->id < NR_CPUS) && (cpu_present(pr->id)))
@@ -818,7 +786,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
818 break; 786 break;
819 } 787 }
820 788
821 return_VOID; 789 return;
822} 790}
823 791
824static acpi_status 792static acpi_status
@@ -857,21 +825,20 @@ processor_walk_namespace_cb(acpi_handle handle,
857 825
858static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) 826static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
859{ 827{
860 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init");
861 828
862 if (!is_processor_present(handle)) { 829 if (!is_processor_present(handle)) {
863 return_VALUE(AE_ERROR); 830 return AE_ERROR;
864 } 831 }
865 832
866 if (acpi_map_lsapic(handle, p_cpu)) 833 if (acpi_map_lsapic(handle, p_cpu))
867 return_VALUE(AE_ERROR); 834 return AE_ERROR;
868 835
869 if (arch_register_cpu(*p_cpu)) { 836 if (arch_register_cpu(*p_cpu)) {
870 acpi_unmap_lsapic(*p_cpu); 837 acpi_unmap_lsapic(*p_cpu);
871 return_VALUE(AE_ERROR); 838 return AE_ERROR;
872 } 839 }
873 840
874 return_VALUE(AE_OK); 841 return AE_OK;
875} 842}
876 843
877static int acpi_processor_handle_eject(struct acpi_processor *pr) 844static int acpi_processor_handle_eject(struct acpi_processor *pr)
@@ -928,20 +895,19 @@ static int __init acpi_processor_init(void)
928{ 895{
929 int result = 0; 896 int result = 0;
930 897
931 ACPI_FUNCTION_TRACE("acpi_processor_init");
932 898
933 memset(&processors, 0, sizeof(processors)); 899 memset(&processors, 0, sizeof(processors));
934 memset(&errata, 0, sizeof(errata)); 900 memset(&errata, 0, sizeof(errata));
935 901
936 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 902 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
937 if (!acpi_processor_dir) 903 if (!acpi_processor_dir)
938 return_VALUE(0); 904 return 0;
939 acpi_processor_dir->owner = THIS_MODULE; 905 acpi_processor_dir->owner = THIS_MODULE;
940 906
941 result = acpi_bus_register_driver(&acpi_processor_driver); 907 result = acpi_bus_register_driver(&acpi_processor_driver);
942 if (result < 0) { 908 if (result < 0) {
943 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 909 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
944 return_VALUE(0); 910 return 0;
945 } 911 }
946 912
947 acpi_processor_install_hotplug_notify(); 913 acpi_processor_install_hotplug_notify();
@@ -950,12 +916,11 @@ static int __init acpi_processor_init(void)
950 916
951 acpi_processor_ppc_init(); 917 acpi_processor_ppc_init();
952 918
953 return_VALUE(0); 919 return 0;
954} 920}
955 921
956static void __exit acpi_processor_exit(void) 922static void __exit acpi_processor_exit(void)
957{ 923{
958 ACPI_FUNCTION_TRACE("acpi_processor_exit");
959 924
960 acpi_processor_ppc_exit(); 925 acpi_processor_ppc_exit();
961 926
@@ -967,7 +932,7 @@ static void __exit acpi_processor_exit(void)
967 932
968 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 933 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
969 934
970 return_VOID; 935 return;
971} 936}
972 937
973module_init(acpi_processor_init); 938module_init(acpi_processor_init);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 8a74bf3efd8e..e439eb77d283 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> 6 * Copyright (C) 2004, 2005 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support 8 * - Added processor hotplug support
9 * Copyright (C) 2005 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 9 * Copyright (C) 2005 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
@@ -99,6 +99,9 @@ static int set_max_cstate(struct dmi_system_id *id)
99static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = { 99static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
100 { set_max_cstate, "IBM ThinkPad R40e", { 100 { set_max_cstate, "IBM ThinkPad R40e", {
101 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), 101 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
102 DMI_MATCH(DMI_BIOS_VERSION,"1SET70WW")}, (void *)1},
103 { set_max_cstate, "IBM ThinkPad R40e", {
104 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
102 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1}, 105 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1},
103 { set_max_cstate, "IBM ThinkPad R40e", { 106 { set_max_cstate, "IBM ThinkPad R40e", {
104 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), 107 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
@@ -261,21 +264,15 @@ static void acpi_processor_idle(void)
261 u32 bm_status = 0; 264 u32 bm_status = 0;
262 unsigned long diff = jiffies - pr->power.bm_check_timestamp; 265 unsigned long diff = jiffies - pr->power.bm_check_timestamp;
263 266
264 if (diff > 32) 267 if (diff > 31)
265 diff = 32; 268 diff = 31;
266 269
267 while (diff) { 270 pr->power.bm_activity <<= diff;
268 /* if we didn't get called, assume there was busmaster activity */
269 diff--;
270 if (diff)
271 pr->power.bm_activity |= 0x1;
272 pr->power.bm_activity <<= 1;
273 }
274 271
275 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, 272 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS,
276 &bm_status, ACPI_MTX_DO_NOT_LOCK); 273 &bm_status, ACPI_MTX_DO_NOT_LOCK);
277 if (bm_status) { 274 if (bm_status) {
278 pr->power.bm_activity++; 275 pr->power.bm_activity |= 0x1;
279 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 276 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS,
280 1, ACPI_MTX_DO_NOT_LOCK); 277 1, ACPI_MTX_DO_NOT_LOCK);
281 } 278 }
@@ -287,16 +284,16 @@ static void acpi_processor_idle(void)
287 else if (errata.piix4.bmisx) { 284 else if (errata.piix4.bmisx) {
288 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) 285 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01)
289 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) 286 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
290 pr->power.bm_activity++; 287 pr->power.bm_activity |= 0x1;
291 } 288 }
292 289
293 pr->power.bm_check_timestamp = jiffies; 290 pr->power.bm_check_timestamp = jiffies;
294 291
295 /* 292 /*
296 * Apply bus mastering demotion policy. Automatically demote 293 * If bus mastering is or was active this jiffy, demote
297 * to avoid a faulty transition. Note that the processor 294 * to avoid a faulty transition. Note that the processor
298 * won't enter a low-power state during this call (to this 295 * won't enter a low-power state during this call (to this
299 * funciton) but should upon the next. 296 * function) but should upon the next.
300 * 297 *
301 * TBD: A better policy might be to fallback to the demotion 298 * TBD: A better policy might be to fallback to the demotion
302 * state (use it for this quantum only) istead of 299 * state (use it for this quantum only) istead of
@@ -304,7 +301,8 @@ static void acpi_processor_idle(void)
304 * qualification. This may, however, introduce DMA 301 * qualification. This may, however, introduce DMA
305 * issues (e.g. floppy DMA transfer overrun/underrun). 302 * issues (e.g. floppy DMA transfer overrun/underrun).
306 */ 303 */
307 if (pr->power.bm_activity & cx->demotion.threshold.bm) { 304 if ((pr->power.bm_activity & 0x1) &&
305 cx->demotion.threshold.bm) {
308 local_irq_enable(); 306 local_irq_enable();
309 next_state = cx->demotion.state; 307 next_state = cx->demotion.state;
310 goto end; 308 goto end;
@@ -322,8 +320,6 @@ static void acpi_processor_idle(void)
322 cx = &pr->power.states[ACPI_STATE_C1]; 320 cx = &pr->power.states[ACPI_STATE_C1];
323#endif 321#endif
324 322
325 cx->usage++;
326
327 /* 323 /*
328 * Sleep: 324 * Sleep:
329 * ------ 325 * ------
@@ -365,7 +361,9 @@ static void acpi_processor_idle(void)
365 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 361 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
366 /* Invoke C2 */ 362 /* Invoke C2 */
367 inb(cx->address); 363 inb(cx->address);
368 /* Dummy op - must do something useless after P_LVL2 read */ 364 /* Dummy wait op - must do something useless after P_LVL2 read
365 because chipsets cannot guarantee that STPCLK# signal
366 gets asserted in time to freeze execution properly. */
369 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 367 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
370 /* Get end time (ticks) */ 368 /* Get end time (ticks) */
371 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 369 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
@@ -403,7 +401,7 @@ static void acpi_processor_idle(void)
403 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 401 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
404 /* Invoke C3 */ 402 /* Invoke C3 */
405 inb(cx->address); 403 inb(cx->address);
406 /* Dummy op - must do something useless after P_LVL3 read */ 404 /* Dummy wait op (see above) */
407 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 405 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
408 /* Get end time (ticks) */ 406 /* Get end time (ticks) */
409 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 407 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
@@ -430,6 +428,9 @@ static void acpi_processor_idle(void)
430 local_irq_enable(); 428 local_irq_enable();
431 return; 429 return;
432 } 430 }
431 cx->usage++;
432 if ((cx->type != ACPI_STATE_C1) && (sleep_ticks > 0))
433 cx->time += sleep_ticks;
433 434
434 next_state = pr->power.state; 435 next_state = pr->power.state;
435 436
@@ -517,10 +518,9 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
517 struct acpi_processor_cx *higher = NULL; 518 struct acpi_processor_cx *higher = NULL;
518 struct acpi_processor_cx *cx; 519 struct acpi_processor_cx *cx;
519 520
520 ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy");
521 521
522 if (!pr) 522 if (!pr)
523 return_VALUE(-EINVAL); 523 return -EINVAL;
524 524
525 /* 525 /*
526 * This function sets the default Cx state policy (OS idle handler). 526 * This function sets the default Cx state policy (OS idle handler).
@@ -544,7 +544,7 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
544 } 544 }
545 545
546 if (!state_is_set) 546 if (!state_is_set)
547 return_VALUE(-ENODEV); 547 return -ENODEV;
548 548
549 /* demotion */ 549 /* demotion */
550 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 550 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
@@ -583,18 +583,17 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
583 higher = cx; 583 higher = cx;
584 } 584 }
585 585
586 return_VALUE(0); 586 return 0;
587} 587}
588 588
589static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) 589static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
590{ 590{
591 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt");
592 591
593 if (!pr) 592 if (!pr)
594 return_VALUE(-EINVAL); 593 return -EINVAL;
595 594
596 if (!pr->pblk) 595 if (!pr->pblk)
597 return_VALUE(-ENODEV); 596 return -ENODEV;
598 597
599 /* if info is obtained from pblk/fadt, type equals state */ 598 /* if info is obtained from pblk/fadt, type equals state */
600 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2; 599 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
@@ -606,7 +605,7 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
606 * an SMP system. 605 * an SMP system.
607 */ 606 */
608 if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up) 607 if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up)
609 return_VALUE(-ENODEV); 608 return -ENODEV;
610#endif 609#endif
611 610
612 /* determine C2 and C3 address from pblk */ 611 /* determine C2 and C3 address from pblk */
@@ -622,12 +621,11 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
622 pr->power.states[ACPI_STATE_C2].address, 621 pr->power.states[ACPI_STATE_C2].address,
623 pr->power.states[ACPI_STATE_C3].address)); 622 pr->power.states[ACPI_STATE_C3].address));
624 623
625 return_VALUE(0); 624 return 0;
626} 625}
627 626
628static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) 627static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
629{ 628{
630 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
631 629
632 /* Zero initialize all the C-states info. */ 630 /* Zero initialize all the C-states info. */
633 memset(pr->power.states, 0, sizeof(pr->power.states)); 631 memset(pr->power.states, 0, sizeof(pr->power.states));
@@ -640,7 +638,7 @@ static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
640 pr->power.states[ACPI_STATE_C0].valid = 1; 638 pr->power.states[ACPI_STATE_C0].valid = 1;
641 pr->power.states[ACPI_STATE_C1].valid = 1; 639 pr->power.states[ACPI_STATE_C1].valid = 1;
642 640
643 return_VALUE(0); 641 return 0;
644} 642}
645 643
646static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) 644static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
@@ -652,10 +650,9 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
652 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 650 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
653 union acpi_object *cst; 651 union acpi_object *cst;
654 652
655 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst");
656 653
657 if (nocst) 654 if (nocst)
658 return_VALUE(-ENODEV); 655 return -ENODEV;
659 656
660 current_count = 1; 657 current_count = 1;
661 658
@@ -667,15 +664,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
667 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 664 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
668 if (ACPI_FAILURE(status)) { 665 if (ACPI_FAILURE(status)) {
669 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n")); 666 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n"));
670 return_VALUE(-ENODEV); 667 return -ENODEV;
671 } 668 }
672 669
673 cst = (union acpi_object *)buffer.pointer; 670 cst = (union acpi_object *)buffer.pointer;
674 671
675 /* There must be at least 2 elements */ 672 /* There must be at least 2 elements */
676 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { 673 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) {
677 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 674 printk(KERN_ERR PREFIX "not enough elements in _CST\n");
678 "not enough elements in _CST\n"));
679 status = -EFAULT; 675 status = -EFAULT;
680 goto end; 676 goto end;
681 } 677 }
@@ -684,8 +680,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
684 680
685 /* Validate number of power states. */ 681 /* Validate number of power states. */
686 if (count < 1 || count != cst->package.count - 1) { 682 if (count < 1 || count != cst->package.count - 1) {
687 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 683 printk(KERN_ERR PREFIX "count given by _CST is not valid\n");
688 "count given by _CST is not valid\n"));
689 status = -EFAULT; 684 status = -EFAULT;
690 goto end; 685 goto end;
691 } 686 }
@@ -775,15 +770,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
775 end: 770 end:
776 acpi_os_free(buffer.pointer); 771 acpi_os_free(buffer.pointer);
777 772
778 return_VALUE(status); 773 return status;
779} 774}
780 775
781static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) 776static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
782{ 777{
783 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2");
784 778
785 if (!cx->address) 779 if (!cx->address)
786 return_VOID; 780 return;
787 781
788 /* 782 /*
789 * C2 latency must be less than or equal to 100 783 * C2 latency must be less than or equal to 100
@@ -792,7 +786,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
792 else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) { 786 else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) {
793 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 787 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
794 "latency too large [%d]\n", cx->latency)); 788 "latency too large [%d]\n", cx->latency));
795 return_VOID; 789 return;
796 } 790 }
797 791
798 /* 792 /*
@@ -802,7 +796,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
802 cx->valid = 1; 796 cx->valid = 1;
803 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); 797 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
804 798
805 return_VOID; 799 return;
806} 800}
807 801
808static void acpi_processor_power_verify_c3(struct acpi_processor *pr, 802static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
@@ -810,10 +804,9 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
810{ 804{
811 static int bm_check_flag; 805 static int bm_check_flag;
812 806
813 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3");
814 807
815 if (!cx->address) 808 if (!cx->address)
816 return_VOID; 809 return;
817 810
818 /* 811 /*
819 * C3 latency must be less than or equal to 1000 812 * C3 latency must be less than or equal to 1000
@@ -822,7 +815,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
822 else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) { 815 else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) {
823 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 816 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
824 "latency too large [%d]\n", cx->latency)); 817 "latency too large [%d]\n", cx->latency));
825 return_VOID; 818 return;
826 } 819 }
827 820
828 /* 821 /*
@@ -835,7 +828,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
835 else if (errata.piix4.fdma) { 828 else if (errata.piix4.fdma) {
836 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 829 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
837 "C3 not supported on PIIX4 with Type-F DMA\n")); 830 "C3 not supported on PIIX4 with Type-F DMA\n"));
838 return_VOID; 831 return;
839 } 832 }
840 833
841 /* All the logic here assumes flags.bm_check is same across all CPUs */ 834 /* All the logic here assumes flags.bm_check is same across all CPUs */
@@ -852,7 +845,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
852 if (!pr->flags.bm_control) { 845 if (!pr->flags.bm_control) {
853 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 846 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
854 "C3 support requires bus mastering control\n")); 847 "C3 support requires bus mastering control\n"));
855 return_VOID; 848 return;
856 } 849 }
857 } else { 850 } else {
858 /* 851 /*
@@ -863,7 +856,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
863 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 856 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
864 "Cache invalidation should work properly" 857 "Cache invalidation should work properly"
865 " for C3 to be enabled on SMP systems\n")); 858 " for C3 to be enabled on SMP systems\n"));
866 return_VOID; 859 return;
867 } 860 }
868 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 861 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD,
869 0, ACPI_MTX_DO_NOT_LOCK); 862 0, ACPI_MTX_DO_NOT_LOCK);
@@ -878,7 +871,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
878 cx->valid = 1; 871 cx->valid = 1;
879 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); 872 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
880 873
881 return_VOID; 874 return;
882} 875}
883 876
884static int acpi_processor_power_verify(struct acpi_processor *pr) 877static int acpi_processor_power_verify(struct acpi_processor *pr)
@@ -937,7 +930,6 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
937 unsigned int i; 930 unsigned int i;
938 int result; 931 int result;
939 932
940 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info");
941 933
942 /* NOTE: the idle thread may not be running while calling 934 /* NOTE: the idle thread may not be running while calling
943 * this function */ 935 * this function */
@@ -960,7 +952,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
960 */ 952 */
961 result = acpi_processor_set_power_policy(pr); 953 result = acpi_processor_set_power_policy(pr);
962 if (result) 954 if (result)
963 return_VALUE(result); 955 return result;
964 956
965 /* 957 /*
966 * if one state of type C2 or C3 is available, mark this 958 * if one state of type C2 or C3 is available, mark this
@@ -974,24 +966,23 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
974 } 966 }
975 } 967 }
976 968
977 return_VALUE(0); 969 return 0;
978} 970}
979 971
980int acpi_processor_cst_has_changed(struct acpi_processor *pr) 972int acpi_processor_cst_has_changed(struct acpi_processor *pr)
981{ 973{
982 int result = 0; 974 int result = 0;
983 975
984 ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed");
985 976
986 if (!pr) 977 if (!pr)
987 return_VALUE(-EINVAL); 978 return -EINVAL;
988 979
989 if (nocst) { 980 if (nocst) {
990 return_VALUE(-ENODEV); 981 return -ENODEV;
991 } 982 }
992 983
993 if (!pr->flags.power_setup_done) 984 if (!pr->flags.power_setup_done)
994 return_VALUE(-ENODEV); 985 return -ENODEV;
995 986
996 /* Fall back to the default idle loop */ 987 /* Fall back to the default idle loop */
997 pm_idle = pm_idle_save; 988 pm_idle = pm_idle_save;
@@ -1002,7 +993,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1002 if ((pr->flags.power == 1) && (pr->flags.power_setup_done)) 993 if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
1003 pm_idle = acpi_processor_idle; 994 pm_idle = acpi_processor_idle;
1004 995
1005 return_VALUE(result); 996 return result;
1006} 997}
1007 998
1008/* proc interface */ 999/* proc interface */
@@ -1012,7 +1003,6 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
1012 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 1003 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
1013 unsigned int i; 1004 unsigned int i;
1014 1005
1015 ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show");
1016 1006
1017 if (!pr) 1007 if (!pr)
1018 goto end; 1008 goto end;
@@ -1064,13 +1054,14 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
1064 else 1054 else
1065 seq_puts(seq, "demotion[--] "); 1055 seq_puts(seq, "demotion[--] ");
1066 1056
1067 seq_printf(seq, "latency[%03d] usage[%08d]\n", 1057 seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n",
1068 pr->power.states[i].latency, 1058 pr->power.states[i].latency,
1069 pr->power.states[i].usage); 1059 pr->power.states[i].usage,
1060 pr->power.states[i].time);
1070 } 1061 }
1071 1062
1072 end: 1063 end:
1073 return_VALUE(0); 1064 return 0;
1074} 1065}
1075 1066
1076static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) 1067static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
@@ -1094,7 +1085,6 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1094 struct proc_dir_entry *entry = NULL; 1085 struct proc_dir_entry *entry = NULL;
1095 unsigned int i; 1086 unsigned int i;
1096 1087
1097 ACPI_FUNCTION_TRACE("acpi_processor_power_init");
1098 1088
1099 if (!first_run) { 1089 if (!first_run) {
1100 dmi_check_system(processor_power_dmi_table); 1090 dmi_check_system(processor_power_dmi_table);
@@ -1106,14 +1096,14 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1106 } 1096 }
1107 1097
1108 if (!pr) 1098 if (!pr)
1109 return_VALUE(-EINVAL); 1099 return -EINVAL;
1110 1100
1111 if (acpi_fadt.cst_cnt && !nocst) { 1101 if (acpi_fadt.cst_cnt && !nocst) {
1112 status = 1102 status =
1113 acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); 1103 acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
1114 if (ACPI_FAILURE(status)) { 1104 if (ACPI_FAILURE(status)) {
1115 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1105 ACPI_EXCEPTION((AE_INFO, status,
1116 "Notifying BIOS of _CST ability failed\n")); 1106 "Notifying BIOS of _CST ability failed"));
1117 } 1107 }
1118 } 1108 }
1119 1109
@@ -1142,9 +1132,7 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1142 entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, 1132 entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER,
1143 S_IRUGO, acpi_device_dir(device)); 1133 S_IRUGO, acpi_device_dir(device));
1144 if (!entry) 1134 if (!entry)
1145 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1135 return -EIO;
1146 "Unable to create '%s' fs entry\n",
1147 ACPI_PROCESSOR_FILE_POWER));
1148 else { 1136 else {
1149 entry->proc_fops = &acpi_processor_power_fops; 1137 entry->proc_fops = &acpi_processor_power_fops;
1150 entry->data = acpi_driver_data(device); 1138 entry->data = acpi_driver_data(device);
@@ -1153,13 +1141,12 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1153 1141
1154 pr->flags.power_setup_done = 1; 1142 pr->flags.power_setup_done = 1;
1155 1143
1156 return_VALUE(0); 1144 return 0;
1157} 1145}
1158 1146
1159int acpi_processor_power_exit(struct acpi_processor *pr, 1147int acpi_processor_power_exit(struct acpi_processor *pr,
1160 struct acpi_device *device) 1148 struct acpi_device *device)
1161{ 1149{
1162 ACPI_FUNCTION_TRACE("acpi_processor_power_exit");
1163 1150
1164 pr->flags.power_setup_done = 0; 1151 pr->flags.power_setup_done = 0;
1165 1152
@@ -1179,5 +1166,5 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1179 cpu_idle_wait(); 1166 cpu_idle_wait();
1180 } 1167 }
1181 1168
1182 return_VALUE(0); 1169 return 0;
1183} 1170}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 41aaaba74b19..14a00e5a8f6a 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -108,10 +108,9 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
108 acpi_status status = 0; 108 acpi_status status = 0;
109 unsigned long ppc = 0; 109 unsigned long ppc = 0;
110 110
111 ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit");
112 111
113 if (!pr) 112 if (!pr)
114 return_VALUE(-EINVAL); 113 return -EINVAL;
115 114
116 /* 115 /*
117 * _PPC indicates the maximum state currently supported by the platform 116 * _PPC indicates the maximum state currently supported by the platform
@@ -123,13 +122,13 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
123 acpi_processor_ppc_status |= PPC_IN_USE; 122 acpi_processor_ppc_status |= PPC_IN_USE;
124 123
125 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 124 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n")); 125 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
127 return_VALUE(-ENODEV); 126 return -ENODEV;
128 } 127 }
129 128
130 pr->performance_platform_limit = (int)ppc; 129 pr->performance_platform_limit = (int)ppc;
131 130
132 return_VALUE(0); 131 return 0;
133} 132}
134 133
135int acpi_processor_ppc_has_changed(struct acpi_processor *pr) 134int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
@@ -168,18 +167,17 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
168 union acpi_object *pct = NULL; 167 union acpi_object *pct = NULL;
169 union acpi_object obj = { 0 }; 168 union acpi_object obj = { 0 };
170 169
171 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control");
172 170
173 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); 171 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
174 if (ACPI_FAILURE(status)) { 172 if (ACPI_FAILURE(status)) {
175 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n")); 173 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT"));
176 return_VALUE(-ENODEV); 174 return -ENODEV;
177 } 175 }
178 176
179 pct = (union acpi_object *)buffer.pointer; 177 pct = (union acpi_object *)buffer.pointer;
180 if (!pct || (pct->type != ACPI_TYPE_PACKAGE) 178 if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
181 || (pct->package.count != 2)) { 179 || (pct->package.count != 2)) {
182 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n")); 180 printk(KERN_ERR PREFIX "Invalid _PCT data\n");
183 result = -EFAULT; 181 result = -EFAULT;
184 goto end; 182 goto end;
185 } 183 }
@@ -193,8 +191,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
193 if ((obj.type != ACPI_TYPE_BUFFER) 191 if ((obj.type != ACPI_TYPE_BUFFER)
194 || (obj.buffer.length < sizeof(struct acpi_pct_register)) 192 || (obj.buffer.length < sizeof(struct acpi_pct_register))
195 || (obj.buffer.pointer == NULL)) { 193 || (obj.buffer.pointer == NULL)) {
196 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 194 printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
197 "Invalid _PCT data (control_register)\n"));
198 result = -EFAULT; 195 result = -EFAULT;
199 goto end; 196 goto end;
200 } 197 }
@@ -210,8 +207,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
210 if ((obj.type != ACPI_TYPE_BUFFER) 207 if ((obj.type != ACPI_TYPE_BUFFER)
211 || (obj.buffer.length < sizeof(struct acpi_pct_register)) 208 || (obj.buffer.length < sizeof(struct acpi_pct_register))
212 || (obj.buffer.pointer == NULL)) { 209 || (obj.buffer.pointer == NULL)) {
213 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 210 printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
214 "Invalid _PCT data (status_register)\n"));
215 result = -EFAULT; 211 result = -EFAULT;
216 goto end; 212 goto end;
217 } 213 }
@@ -222,7 +218,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
222 end: 218 end:
223 acpi_os_free(buffer.pointer); 219 acpi_os_free(buffer.pointer);
224 220
225 return_VALUE(result); 221 return result;
226} 222}
227 223
228static int acpi_processor_get_performance_states(struct acpi_processor *pr) 224static int acpi_processor_get_performance_states(struct acpi_processor *pr)
@@ -235,17 +231,16 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
235 union acpi_object *pss = NULL; 231 union acpi_object *pss = NULL;
236 int i; 232 int i;
237 233
238 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
239 234
240 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); 235 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
241 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
242 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n")); 237 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS"));
243 return_VALUE(-ENODEV); 238 return -ENODEV;
244 } 239 }
245 240
246 pss = (union acpi_object *)buffer.pointer; 241 pss = (union acpi_object *)buffer.pointer;
247 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { 242 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
248 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); 243 printk(KERN_ERR PREFIX "Invalid _PSS data\n");
249 result = -EFAULT; 244 result = -EFAULT;
250 goto end; 245 goto end;
251 } 246 }
@@ -274,8 +269,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
274 status = acpi_extract_package(&(pss->package.elements[i]), 269 status = acpi_extract_package(&(pss->package.elements[i]),
275 &format, &state); 270 &format, &state);
276 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 272 ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data"));
278 "Invalid _PSS data\n"));
279 result = -EFAULT; 273 result = -EFAULT;
280 kfree(pr->performance->states); 274 kfree(pr->performance->states);
281 goto end; 275 goto end;
@@ -291,8 +285,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
291 (u32) px->control, (u32) px->status)); 285 (u32) px->control, (u32) px->status));
292 286
293 if (!px->core_frequency) { 287 if (!px->core_frequency) {
294 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 288 printk(KERN_ERR PREFIX
295 "Invalid _PSS data: freq is zero\n")); 289 "Invalid _PSS data: freq is zero\n");
296 result = -EFAULT; 290 result = -EFAULT;
297 kfree(pr->performance->states); 291 kfree(pr->performance->states);
298 goto end; 292 goto end;
@@ -302,7 +296,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
302 end: 296 end:
303 acpi_os_free(buffer.pointer); 297 acpi_os_free(buffer.pointer);
304 298
305 return_VALUE(result); 299 return result;
306} 300}
307 301
308static int acpi_processor_get_performance_info(struct acpi_processor *pr) 302static int acpi_processor_get_performance_info(struct acpi_processor *pr)
@@ -311,31 +305,30 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
311 acpi_status status = AE_OK; 305 acpi_status status = AE_OK;
312 acpi_handle handle = NULL; 306 acpi_handle handle = NULL;
313 307
314 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info");
315 308
316 if (!pr || !pr->performance || !pr->handle) 309 if (!pr || !pr->performance || !pr->handle)
317 return_VALUE(-EINVAL); 310 return -EINVAL;
318 311
319 status = acpi_get_handle(pr->handle, "_PCT", &handle); 312 status = acpi_get_handle(pr->handle, "_PCT", &handle);
320 if (ACPI_FAILURE(status)) { 313 if (ACPI_FAILURE(status)) {
321 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 314 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
322 "ACPI-based processor performance control unavailable\n")); 315 "ACPI-based processor performance control unavailable\n"));
323 return_VALUE(-ENODEV); 316 return -ENODEV;
324 } 317 }
325 318
326 result = acpi_processor_get_performance_control(pr); 319 result = acpi_processor_get_performance_control(pr);
327 if (result) 320 if (result)
328 return_VALUE(result); 321 return result;
329 322
330 result = acpi_processor_get_performance_states(pr); 323 result = acpi_processor_get_performance_states(pr);
331 if (result) 324 if (result)
332 return_VALUE(result); 325 return result;
333 326
334 result = acpi_processor_get_platform_limit(pr); 327 result = acpi_processor_get_platform_limit(pr);
335 if (result) 328 if (result)
336 return_VALUE(result); 329 return result;
337 330
338 return_VALUE(0); 331 return 0;
339} 332}
340 333
341int acpi_processor_notify_smm(struct module *calling_module) 334int acpi_processor_notify_smm(struct module *calling_module)
@@ -343,13 +336,12 @@ int acpi_processor_notify_smm(struct module *calling_module)
343 acpi_status status; 336 acpi_status status;
344 static int is_done = 0; 337 static int is_done = 0;
345 338
346 ACPI_FUNCTION_TRACE("acpi_processor_notify_smm");
347 339
348 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 340 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
349 return_VALUE(-EBUSY); 341 return -EBUSY;
350 342
351 if (!try_module_get(calling_module)) 343 if (!try_module_get(calling_module))
352 return_VALUE(-EINVAL); 344 return -EINVAL;
353 345
354 /* is_done is set to negative if an error occured, 346 /* is_done is set to negative if an error occured,
355 * and to postitive if _no_ error occured, but SMM 347 * and to postitive if _no_ error occured, but SMM
@@ -358,10 +350,10 @@ int acpi_processor_notify_smm(struct module *calling_module)
358 */ 350 */
359 if (is_done > 0) { 351 if (is_done > 0) {
360 module_put(calling_module); 352 module_put(calling_module);
361 return_VALUE(0); 353 return 0;
362 } else if (is_done < 0) { 354 } else if (is_done < 0) {
363 module_put(calling_module); 355 module_put(calling_module);
364 return_VALUE(is_done); 356 return is_done;
365 } 357 }
366 358
367 is_done = -EIO; 359 is_done = -EIO;
@@ -370,7 +362,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
370 if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) { 362 if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) {
371 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n")); 363 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n"));
372 module_put(calling_module); 364 module_put(calling_module);
373 return_VALUE(0); 365 return 0;
374 } 366 }
375 367
376 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 368 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -387,12 +379,12 @@ int acpi_processor_notify_smm(struct module *calling_module)
387 status = acpi_os_write_port(acpi_fadt.smi_cmd, 379 status = acpi_os_write_port(acpi_fadt.smi_cmd,
388 (u32) acpi_fadt.pstate_cnt, 8); 380 (u32) acpi_fadt.pstate_cnt, 8);
389 if (ACPI_FAILURE(status)) { 381 if (ACPI_FAILURE(status)) {
390 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 382 ACPI_EXCEPTION((AE_INFO, status,
391 "Failed to write pstate_cnt [0x%x] to " 383 "Failed to write pstate_cnt [0x%x] to "
392 "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, 384 "smi_cmd [0x%x]", acpi_fadt.pstate_cnt,
393 acpi_fadt.smi_cmd)); 385 acpi_fadt.smi_cmd));
394 module_put(calling_module); 386 module_put(calling_module);
395 return_VALUE(status); 387 return status;
396 } 388 }
397 389
398 /* Success. If there's no _PPC, we need to fear nothing, so 390 /* Success. If there's no _PPC, we need to fear nothing, so
@@ -402,7 +394,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
402 if (!(acpi_processor_ppc_status & PPC_IN_USE)) 394 if (!(acpi_processor_ppc_status & PPC_IN_USE))
403 module_put(calling_module); 395 module_put(calling_module);
404 396
405 return_VALUE(0); 397 return 0;
406} 398}
407 399
408EXPORT_SYMBOL(acpi_processor_notify_smm); 400EXPORT_SYMBOL(acpi_processor_notify_smm);
@@ -423,7 +415,6 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
423 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 415 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
424 int i; 416 int i;
425 417
426 ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
427 418
428 if (!pr) 419 if (!pr)
429 goto end; 420 goto end;
@@ -447,7 +438,7 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
447 (u32) pr->performance->states[i].transition_latency); 438 (u32) pr->performance->states[i].transition_latency);
448 439
449 end: 440 end:
450 return_VALUE(0); 441 return 0;
451} 442}
452 443
453static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) 444static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
@@ -469,23 +460,22 @@ acpi_processor_write_performance(struct file *file,
469 unsigned int new_state = 0; 460 unsigned int new_state = 0;
470 struct cpufreq_policy policy; 461 struct cpufreq_policy policy;
471 462
472 ACPI_FUNCTION_TRACE("acpi_processor_write_performance");
473 463
474 if (!pr || (count > sizeof(state_string) - 1)) 464 if (!pr || (count > sizeof(state_string) - 1))
475 return_VALUE(-EINVAL); 465 return -EINVAL;
476 466
477 perf = pr->performance; 467 perf = pr->performance;
478 if (!perf) 468 if (!perf)
479 return_VALUE(-EINVAL); 469 return -EINVAL;
480 470
481 if (copy_from_user(state_string, buffer, count)) 471 if (copy_from_user(state_string, buffer, count))
482 return_VALUE(-EFAULT); 472 return -EFAULT;
483 473
484 state_string[count] = '\0'; 474 state_string[count] = '\0';
485 new_state = simple_strtoul(state_string, NULL, 0); 475 new_state = simple_strtoul(state_string, NULL, 0);
486 476
487 if (new_state >= perf->state_count) 477 if (new_state >= perf->state_count)
488 return_VALUE(-EINVAL); 478 return -EINVAL;
489 479
490 cpufreq_get_policy(&policy, pr->id); 480 cpufreq_get_policy(&policy, pr->id);
491 481
@@ -495,9 +485,9 @@ acpi_processor_write_performance(struct file *file,
495 485
496 result = cpufreq_set_policy(&policy); 486 result = cpufreq_set_policy(&policy);
497 if (result) 487 if (result)
498 return_VALUE(result); 488 return result;
499 489
500 return_VALUE(count); 490 return count;
501} 491}
502 492
503static void acpi_cpufreq_add_file(struct acpi_processor *pr) 493static void acpi_cpufreq_add_file(struct acpi_processor *pr)
@@ -505,42 +495,36 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
505 struct proc_dir_entry *entry = NULL; 495 struct proc_dir_entry *entry = NULL;
506 struct acpi_device *device = NULL; 496 struct acpi_device *device = NULL;
507 497
508 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
509 498
510 if (acpi_bus_get_device(pr->handle, &device)) 499 if (acpi_bus_get_device(pr->handle, &device))
511 return_VOID; 500 return;
512 501
513 /* add file 'performance' [R/W] */ 502 /* add file 'performance' [R/W] */
514 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 503 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
515 S_IFREG | S_IRUGO | S_IWUSR, 504 S_IFREG | S_IRUGO | S_IWUSR,
516 acpi_device_dir(device)); 505 acpi_device_dir(device));
517 if (!entry) 506 if (entry){
518 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
519 "Unable to create '%s' fs entry\n",
520 ACPI_PROCESSOR_FILE_PERFORMANCE));
521 else {
522 acpi_processor_perf_fops.write = acpi_processor_write_performance; 507 acpi_processor_perf_fops.write = acpi_processor_write_performance;
523 entry->proc_fops = &acpi_processor_perf_fops; 508 entry->proc_fops = &acpi_processor_perf_fops;
524 entry->data = acpi_driver_data(device); 509 entry->data = acpi_driver_data(device);
525 entry->owner = THIS_MODULE; 510 entry->owner = THIS_MODULE;
526 } 511 }
527 return_VOID; 512 return;
528} 513}
529 514
530static void acpi_cpufreq_remove_file(struct acpi_processor *pr) 515static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
531{ 516{
532 struct acpi_device *device = NULL; 517 struct acpi_device *device = NULL;
533 518
534 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
535 519
536 if (acpi_bus_get_device(pr->handle, &device)) 520 if (acpi_bus_get_device(pr->handle, &device))
537 return_VOID; 521 return;
538 522
539 /* remove file 'performance' */ 523 /* remove file 'performance' */
540 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 524 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
541 acpi_device_dir(device)); 525 acpi_device_dir(device));
542 526
543 return_VOID; 527 return;
544} 528}
545 529
546#else 530#else
@@ -698,12 +682,12 @@ int acpi_processor_preregister_performance(
698 /* Validate the Domain info */ 682 /* Validate the Domain info */
699 count_target = pdomain->num_processors; 683 count_target = pdomain->num_processors;
700 count = 1; 684 count = 1;
701 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL || 685 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
702 pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) {
703 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; 686 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
704 } else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY) { 687 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL)
688 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_HW;
689 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
705 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY; 690 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY;
706 }
707 691
708 for_each_possible_cpu(j) { 692 for_each_possible_cpu(j) {
709 if (i == j) 693 if (i == j)
@@ -784,22 +768,21 @@ acpi_processor_register_performance(struct acpi_processor_performance
784{ 768{
785 struct acpi_processor *pr; 769 struct acpi_processor *pr;
786 770
787 ACPI_FUNCTION_TRACE("acpi_processor_register_performance");
788 771
789 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 772 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
790 return_VALUE(-EINVAL); 773 return -EINVAL;
791 774
792 mutex_lock(&performance_mutex); 775 mutex_lock(&performance_mutex);
793 776
794 pr = processors[cpu]; 777 pr = processors[cpu];
795 if (!pr) { 778 if (!pr) {
796 mutex_unlock(&performance_mutex); 779 mutex_unlock(&performance_mutex);
797 return_VALUE(-ENODEV); 780 return -ENODEV;
798 } 781 }
799 782
800 if (pr->performance) { 783 if (pr->performance) {
801 mutex_unlock(&performance_mutex); 784 mutex_unlock(&performance_mutex);
802 return_VALUE(-EBUSY); 785 return -EBUSY;
803 } 786 }
804 787
805 WARN_ON(!performance); 788 WARN_ON(!performance);
@@ -809,13 +792,13 @@ acpi_processor_register_performance(struct acpi_processor_performance
809 if (acpi_processor_get_performance_info(pr)) { 792 if (acpi_processor_get_performance_info(pr)) {
810 pr->performance = NULL; 793 pr->performance = NULL;
811 mutex_unlock(&performance_mutex); 794 mutex_unlock(&performance_mutex);
812 return_VALUE(-EIO); 795 return -EIO;
813 } 796 }
814 797
815 acpi_cpufreq_add_file(pr); 798 acpi_cpufreq_add_file(pr);
816 799
817 mutex_unlock(&performance_mutex); 800 mutex_unlock(&performance_mutex);
818 return_VALUE(0); 801 return 0;
819} 802}
820 803
821EXPORT_SYMBOL(acpi_processor_register_performance); 804EXPORT_SYMBOL(acpi_processor_register_performance);
@@ -826,14 +809,13 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
826{ 809{
827 struct acpi_processor *pr; 810 struct acpi_processor *pr;
828 811
829 ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
830 812
831 mutex_lock(&performance_mutex); 813 mutex_lock(&performance_mutex);
832 814
833 pr = processors[cpu]; 815 pr = processors[cpu];
834 if (!pr) { 816 if (!pr) {
835 mutex_unlock(&performance_mutex); 817 mutex_unlock(&performance_mutex);
836 return_VOID; 818 return;
837 } 819 }
838 820
839 if (pr->performance) 821 if (pr->performance)
@@ -844,7 +826,7 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
844 826
845 mutex_unlock(&performance_mutex); 827 mutex_unlock(&performance_mutex);
846 828
847 return_VOID; 829 return;
848} 830}
849 831
850EXPORT_SYMBOL(acpi_processor_unregister_performance); 832EXPORT_SYMBOL(acpi_processor_unregister_performance);
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index f99ad05cd6a2..ef5e0f6efdba 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -54,13 +54,12 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
54 u16 px = 0; 54 u16 px = 0;
55 u16 tx = 0; 55 u16 tx = 0;
56 56
57 ACPI_FUNCTION_TRACE("acpi_processor_apply_limit");
58 57
59 if (!pr) 58 if (!pr)
60 return_VALUE(-EINVAL); 59 return -EINVAL;
61 60
62 if (!pr->flags.limit) 61 if (!pr->flags.limit)
63 return_VALUE(-ENODEV); 62 return -ENODEV;
64 63
65 if (pr->flags.throttling) { 64 if (pr->flags.throttling) {
66 if (pr->limit.user.tx > tx) 65 if (pr->limit.user.tx > tx)
@@ -82,9 +81,9 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
82 81
83 end: 82 end:
84 if (result) 83 if (result)
85 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); 84 printk(KERN_ERR PREFIX "Unable to set limit\n");
86 85
87 return_VALUE(result); 86 return result;
88} 87}
89 88
90#ifdef CONFIG_CPU_FREQ 89#ifdef CONFIG_CPU_FREQ
@@ -200,19 +199,18 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
200 struct acpi_device *device = NULL; 199 struct acpi_device *device = NULL;
201 int tx = 0, max_tx_px = 0; 200 int tx = 0, max_tx_px = 0;
202 201
203 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
204 202
205 if ((type < ACPI_PROCESSOR_LIMIT_NONE) 203 if ((type < ACPI_PROCESSOR_LIMIT_NONE)
206 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT)) 204 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT))
207 return_VALUE(-EINVAL); 205 return -EINVAL;
208 206
209 result = acpi_bus_get_device(handle, &device); 207 result = acpi_bus_get_device(handle, &device);
210 if (result) 208 if (result)
211 return_VALUE(result); 209 return result;
212 210
213 pr = (struct acpi_processor *)acpi_driver_data(device); 211 pr = (struct acpi_processor *)acpi_driver_data(device);
214 if (!pr) 212 if (!pr)
215 return_VALUE(-ENODEV); 213 return -ENODEV;
216 214
217 /* Thermal limits are always relative to the current Px/Tx state. */ 215 /* Thermal limits are always relative to the current Px/Tx state. */
218 if (pr->flags.throttling) 216 if (pr->flags.throttling)
@@ -289,30 +287,28 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
289 287
290 result = acpi_processor_apply_limit(pr); 288 result = acpi_processor_apply_limit(pr);
291 if (result) 289 if (result)
292 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 290 printk(KERN_ERR PREFIX "Unable to set thermal limit\n");
293 "Unable to set thermal limit\n"));
294 291
295 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n", 292 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",
296 pr->limit.thermal.px, pr->limit.thermal.tx)); 293 pr->limit.thermal.px, pr->limit.thermal.tx));
297 } else 294 } else
298 result = 0; 295 result = 0;
299 if (max_tx_px) 296 if (max_tx_px)
300 return_VALUE(1); 297 return 1;
301 else 298 else
302 return_VALUE(result); 299 return result;
303} 300}
304 301
305int acpi_processor_get_limit_info(struct acpi_processor *pr) 302int acpi_processor_get_limit_info(struct acpi_processor *pr)
306{ 303{
307 ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info");
308 304
309 if (!pr) 305 if (!pr)
310 return_VALUE(-EINVAL); 306 return -EINVAL;
311 307
312 if (pr->flags.throttling) 308 if (pr->flags.throttling)
313 pr->flags.limit = 1; 309 pr->flags.limit = 1;
314 310
315 return_VALUE(0); 311 return 0;
316} 312}
317 313
318/* /proc interface */ 314/* /proc interface */
@@ -321,7 +317,6 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
321{ 317{
322 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 318 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
323 319
324 ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show");
325 320
326 if (!pr) 321 if (!pr)
327 goto end; 322 goto end;
@@ -339,7 +334,7 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
339 pr->limit.thermal.px, pr->limit.thermal.tx); 334 pr->limit.thermal.px, pr->limit.thermal.tx);
340 335
341 end: 336 end:
342 return_VALUE(0); 337 return 0;
343} 338}
344 339
345static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) 340static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
@@ -359,36 +354,33 @@ static ssize_t acpi_processor_write_limit(struct file * file,
359 int px = 0; 354 int px = 0;
360 int tx = 0; 355 int tx = 0;
361 356
362 ACPI_FUNCTION_TRACE("acpi_processor_write_limit");
363 357
364 if (!pr || (count > sizeof(limit_string) - 1)) { 358 if (!pr || (count > sizeof(limit_string) - 1)) {
365 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n")); 359 return -EINVAL;
366 return_VALUE(-EINVAL);
367 } 360 }
368 361
369 if (copy_from_user(limit_string, buffer, count)) { 362 if (copy_from_user(limit_string, buffer, count)) {
370 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); 363 return -EFAULT;
371 return_VALUE(-EFAULT);
372 } 364 }
373 365
374 limit_string[count] = '\0'; 366 limit_string[count] = '\0';
375 367
376 if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) { 368 if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) {
377 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); 369 printk(KERN_ERR PREFIX "Invalid data format\n");
378 return_VALUE(-EINVAL); 370 return -EINVAL;
379 } 371 }
380 372
381 if (pr->flags.throttling) { 373 if (pr->flags.throttling) {
382 if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) { 374 if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) {
383 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid tx\n")); 375 printk(KERN_ERR PREFIX "Invalid tx\n");
384 return_VALUE(-EINVAL); 376 return -EINVAL;
385 } 377 }
386 pr->limit.user.tx = tx; 378 pr->limit.user.tx = tx;
387 } 379 }
388 380
389 result = acpi_processor_apply_limit(pr); 381 result = acpi_processor_apply_limit(pr);
390 382
391 return_VALUE(count); 383 return count;
392} 384}
393 385
394struct file_operations acpi_processor_limit_fops = { 386struct file_operations acpi_processor_limit_fops = {
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index b966549ec000..d044ec519db0 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -55,13 +55,12 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
55 u32 duty_mask = 0; 55 u32 duty_mask = 0;
56 u32 duty_value = 0; 56 u32 duty_value = 0;
57 57
58 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling");
59 58
60 if (!pr) 59 if (!pr)
61 return_VALUE(-EINVAL); 60 return -EINVAL;
62 61
63 if (!pr->flags.throttling) 62 if (!pr->flags.throttling)
64 return_VALUE(-ENODEV); 63 return -ENODEV;
65 64
66 pr->throttling.state = 0; 65 pr->throttling.state = 0;
67 66
@@ -93,7 +92,7 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
93 "Throttling state is T%d (%d%% throttling applied)\n", 92 "Throttling state is T%d (%d%% throttling applied)\n",
94 state, pr->throttling.states[state].performance)); 93 state, pr->throttling.states[state].performance));
95 94
96 return_VALUE(0); 95 return 0;
97} 96}
98 97
99int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 98int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
@@ -102,19 +101,18 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
102 u32 duty_mask = 0; 101 u32 duty_mask = 0;
103 u32 duty_value = 0; 102 u32 duty_value = 0;
104 103
105 ACPI_FUNCTION_TRACE("acpi_processor_set_throttling");
106 104
107 if (!pr) 105 if (!pr)
108 return_VALUE(-EINVAL); 106 return -EINVAL;
109 107
110 if ((state < 0) || (state > (pr->throttling.state_count - 1))) 108 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
111 return_VALUE(-EINVAL); 109 return -EINVAL;
112 110
113 if (!pr->flags.throttling) 111 if (!pr->flags.throttling)
114 return_VALUE(-ENODEV); 112 return -ENODEV;
115 113
116 if (state == pr->throttling.state) 114 if (state == pr->throttling.state)
117 return_VALUE(0); 115 return 0;
118 116
119 /* 117 /*
120 * Calculate the duty_value and duty_mask. 118 * Calculate the duty_value and duty_mask.
@@ -165,7 +163,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
165 (pr->throttling.states[state].performance ? pr-> 163 (pr->throttling.states[state].performance ? pr->
166 throttling.states[state].performance / 10 : 0))); 164 throttling.states[state].performance / 10 : 0)));
167 165
168 return_VALUE(0); 166 return 0;
169} 167}
170 168
171int acpi_processor_get_throttling_info(struct acpi_processor *pr) 169int acpi_processor_get_throttling_info(struct acpi_processor *pr)
@@ -174,7 +172,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
174 int step = 0; 172 int step = 0;
175 int i = 0; 173 int i = 0;
176 174
177 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info");
178 175
179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 176 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
180 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 177 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -183,21 +180,21 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
183 pr->throttling.duty_width)); 180 pr->throttling.duty_width));
184 181
185 if (!pr) 182 if (!pr)
186 return_VALUE(-EINVAL); 183 return -EINVAL;
187 184
188 /* TBD: Support ACPI 2.0 objects */ 185 /* TBD: Support ACPI 2.0 objects */
189 186
190 if (!pr->throttling.address) { 187 if (!pr->throttling.address) {
191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); 188 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
192 return_VALUE(0); 189 return 0;
193 } else if (!pr->throttling.duty_width) { 190 } else if (!pr->throttling.duty_width) {
194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); 191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
195 return_VALUE(0); 192 return 0;
196 } 193 }
197 /* TBD: Support duty_cycle values that span bit 4. */ 194 /* TBD: Support duty_cycle values that span bit 4. */
198 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { 195 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
199 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n")); 196 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
200 return_VALUE(0); 197 return 0;
201 } 198 }
202 199
203 /* 200 /*
@@ -208,7 +205,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
208 if (errata.piix4.throttle) { 205 if (errata.piix4.throttle) {
209 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 206 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
210 "Throttling not supported on PIIX4 A- or B-step\n")); 207 "Throttling not supported on PIIX4 A- or B-step\n"));
211 return_VALUE(0); 208 return 0;
212 } 209 }
213 210
214 pr->throttling.state_count = 1 << acpi_fadt.duty_width; 211 pr->throttling.state_count = 1 << acpi_fadt.duty_width;
@@ -254,7 +251,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
254 if (result) 251 if (result)
255 pr->flags.throttling = 0; 252 pr->flags.throttling = 0;
256 253
257 return_VALUE(result); 254 return result;
258} 255}
259 256
260/* proc interface */ 257/* proc interface */
@@ -266,7 +263,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
266 int i = 0; 263 int i = 0;
267 int result = 0; 264 int result = 0;
268 265
269 ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show");
270 266
271 if (!pr) 267 if (!pr)
272 goto end; 268 goto end;
@@ -296,7 +292,7 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
296 throttling.states[i].performance / 10 : 0)); 292 throttling.states[i].performance / 10 : 0));
297 293
298 end: 294 end:
299 return_VALUE(0); 295 return 0;
300} 296}
301 297
302static int acpi_processor_throttling_open_fs(struct inode *inode, 298static int acpi_processor_throttling_open_fs(struct inode *inode,
@@ -315,13 +311,12 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
315 struct acpi_processor *pr = (struct acpi_processor *)m->private; 311 struct acpi_processor *pr = (struct acpi_processor *)m->private;
316 char state_string[12] = { '\0' }; 312 char state_string[12] = { '\0' };
317 313
318 ACPI_FUNCTION_TRACE("acpi_processor_write_throttling");
319 314
320 if (!pr || (count > sizeof(state_string) - 1)) 315 if (!pr || (count > sizeof(state_string) - 1))
321 return_VALUE(-EINVAL); 316 return -EINVAL;
322 317
323 if (copy_from_user(state_string, buffer, count)) 318 if (copy_from_user(state_string, buffer, count))
324 return_VALUE(-EFAULT); 319 return -EFAULT;
325 320
326 state_string[count] = '\0'; 321 state_string[count] = '\0';
327 322
@@ -329,9 +324,9 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
329 simple_strtoul(state_string, 324 simple_strtoul(state_string,
330 NULL, 0)); 325 NULL, 0));
331 if (result) 326 if (result)
332 return_VALUE(result); 327 return result;
333 328
334 return_VALUE(count); 329 return count;
335} 330}
336 331
337struct file_operations acpi_processor_throttling_fops = { 332struct file_operations acpi_processor_throttling_fops = {
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f8316a05ede7..401e723e6c66 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -162,11 +162,10 @@ static void acpi_device_unregister(struct acpi_device *device, int type)
162 162
163void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) 163void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
164{ 164{
165 ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
166 165
167 /* TBD */ 166 /* TBD */
168 167
169 return_VOID; 168 return;
170} 169}
171 170
172static int acpi_bus_get_power_flags(struct acpi_device *device) 171static int acpi_bus_get_power_flags(struct acpi_device *device)
@@ -175,7 +174,6 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
175 acpi_handle handle = NULL; 174 acpi_handle handle = NULL;
176 u32 i = 0; 175 u32 i = 0;
177 176
178 ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
179 177
180 /* 178 /*
181 * Power Management Flags 179 * Power Management Flags
@@ -228,7 +226,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
228 226
229 device->power.state = ACPI_STATE_UNKNOWN; 227 device->power.state = ACPI_STATE_UNKNOWN;
230 228
231 return_VALUE(0); 229 return 0;
232} 230}
233 231
234int acpi_match_ids(struct acpi_device *device, char *ids) 232int acpi_match_ids(struct acpi_device *device, char *ids)
@@ -306,20 +304,18 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
306 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 304 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
307 union acpi_object *package = NULL; 305 union acpi_object *package = NULL;
308 306
309 ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags");
310 307
311 /* _PRW */ 308 /* _PRW */
312 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer); 309 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
313 if (ACPI_FAILURE(status)) { 310 if (ACPI_FAILURE(status)) {
314 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n")); 311 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW"));
315 goto end; 312 goto end;
316 } 313 }
317 314
318 package = (union acpi_object *)buffer.pointer; 315 package = (union acpi_object *)buffer.pointer;
319 status = acpi_bus_extract_wakeup_device_power_package(device, package); 316 status = acpi_bus_extract_wakeup_device_power_package(device, package);
320 if (ACPI_FAILURE(status)) { 317 if (ACPI_FAILURE(status)) {
321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 318 ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package"));
322 "Error extracting _PRW package\n"));
323 goto end; 319 goto end;
324 } 320 }
325 321
@@ -333,7 +329,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
333 end: 329 end:
334 if (ACPI_FAILURE(status)) 330 if (ACPI_FAILURE(status))
335 device->flags.wake_capable = 0; 331 device->flags.wake_capable = 0;
336 return_VALUE(0); 332 return 0;
337} 333}
338 334
339/* -------------------------------------------------------------------------- 335/* --------------------------------------------------------------------------
@@ -489,19 +485,18 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
489{ 485{
490 int result = 0; 486 int result = 0;
491 487
492 ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
493 488
494 if (!device || !driver) 489 if (!device || !driver)
495 return_VALUE(-EINVAL); 490 return -EINVAL;
496 491
497 if (!driver->ops.add) 492 if (!driver->ops.add)
498 return_VALUE(-ENOSYS); 493 return -ENOSYS;
499 494
500 result = driver->ops.add(device); 495 result = driver->ops.add(device);
501 if (result) { 496 if (result) {
502 device->driver = NULL; 497 device->driver = NULL;
503 acpi_driver_data(device) = NULL; 498 acpi_driver_data(device) = NULL;
504 return_VALUE(result); 499 return result;
505 } 500 }
506 501
507 device->driver = driver; 502 device->driver = driver;
@@ -513,7 +508,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
513 508
514 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 509 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
515 "Driver successfully bound to device\n")); 510 "Driver successfully bound to device\n"));
516 return_VALUE(0); 511 return 0;
517} 512}
518 513
519static int acpi_start_single_object(struct acpi_device *device) 514static int acpi_start_single_object(struct acpi_device *device)
@@ -521,10 +516,9 @@ static int acpi_start_single_object(struct acpi_device *device)
521 int result = 0; 516 int result = 0;
522 struct acpi_driver *driver; 517 struct acpi_driver *driver;
523 518
524 ACPI_FUNCTION_TRACE("acpi_start_single_object");
525 519
526 if (!(driver = device->driver)) 520 if (!(driver = device->driver))
527 return_VALUE(0); 521 return 0;
528 522
529 if (driver->ops.start) { 523 if (driver->ops.start) {
530 result = driver->ops.start(device); 524 result = driver->ops.start(device);
@@ -532,14 +526,13 @@ static int acpi_start_single_object(struct acpi_device *device)
532 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); 526 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
533 } 527 }
534 528
535 return_VALUE(result); 529 return result;
536} 530}
537 531
538static void acpi_driver_attach(struct acpi_driver *drv) 532static void acpi_driver_attach(struct acpi_driver *drv)
539{ 533{
540 struct list_head *node, *next; 534 struct list_head *node, *next;
541 535
542 ACPI_FUNCTION_TRACE("acpi_driver_attach");
543 536
544 spin_lock(&acpi_device_lock); 537 spin_lock(&acpi_device_lock);
545 list_for_each_safe(node, next, &acpi_device_list) { 538 list_for_each_safe(node, next, &acpi_device_list) {
@@ -568,7 +561,6 @@ static void acpi_driver_detach(struct acpi_driver *drv)
568{ 561{
569 struct list_head *node, *next; 562 struct list_head *node, *next;
570 563
571 ACPI_FUNCTION_TRACE("acpi_driver_detach");
572 564
573 spin_lock(&acpi_device_lock); 565 spin_lock(&acpi_device_lock);
574 list_for_each_safe(node, next, &acpi_device_list) { 566 list_for_each_safe(node, next, &acpi_device_list) {
@@ -598,17 +590,16 @@ static void acpi_driver_detach(struct acpi_driver *drv)
598 */ 590 */
599int acpi_bus_register_driver(struct acpi_driver *driver) 591int acpi_bus_register_driver(struct acpi_driver *driver)
600{ 592{
601 ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
602 593
603 if (acpi_disabled) 594 if (acpi_disabled)
604 return_VALUE(-ENODEV); 595 return -ENODEV;
605 596
606 spin_lock(&acpi_device_lock); 597 spin_lock(&acpi_device_lock);
607 list_add_tail(&driver->node, &acpi_bus_drivers); 598 list_add_tail(&driver->node, &acpi_bus_drivers);
608 spin_unlock(&acpi_device_lock); 599 spin_unlock(&acpi_device_lock);
609 acpi_driver_attach(driver); 600 acpi_driver_attach(driver);
610 601
611 return_VALUE(0); 602 return 0;
612} 603}
613 604
614EXPORT_SYMBOL(acpi_bus_register_driver); 605EXPORT_SYMBOL(acpi_bus_register_driver);
@@ -646,7 +637,6 @@ static int acpi_bus_find_driver(struct acpi_device *device)
646 int result = 0; 637 int result = 0;
647 struct list_head *node, *next; 638 struct list_head *node, *next;
648 639
649 ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
650 640
651 spin_lock(&acpi_device_lock); 641 spin_lock(&acpi_device_lock);
652 list_for_each_safe(node, next, &acpi_bus_drivers) { 642 list_for_each_safe(node, next, &acpi_bus_drivers) {
@@ -666,19 +656,41 @@ static int acpi_bus_find_driver(struct acpi_device *device)
666 spin_unlock(&acpi_device_lock); 656 spin_unlock(&acpi_device_lock);
667 657
668 Done: 658 Done:
669 return_VALUE(result); 659 return result;
670} 660}
671 661
672/* -------------------------------------------------------------------------- 662/* --------------------------------------------------------------------------
673 Device Enumeration 663 Device Enumeration
674 -------------------------------------------------------------------------- */ 664 -------------------------------------------------------------------------- */
675 665
666acpi_status
667acpi_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}
686EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
687
688
676static int acpi_bus_get_flags(struct acpi_device *device) 689static int acpi_bus_get_flags(struct acpi_device *device)
677{ 690{
678 acpi_status status = AE_OK; 691 acpi_status status = AE_OK;
679 acpi_handle temp = NULL; 692 acpi_handle temp = NULL;
680 693
681 ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
682 694
683 /* Presence of _STA indicates 'dynamic_status' */ 695 /* Presence of _STA indicates 'dynamic_status' */
684 status = acpi_get_handle(device->handle, "_STA", &temp); 696 status = acpi_get_handle(device->handle, "_STA", &temp);
@@ -724,7 +736,7 @@ static int acpi_bus_get_flags(struct acpi_device *device)
724 736
725 /* TBD: Peformance management */ 737 /* TBD: Peformance management */
726 738
727 return_VALUE(0); 739 return 0;
728} 740}
729 741
730static void acpi_device_get_busid(struct acpi_device *device, 742static void acpi_device_get_busid(struct acpi_device *device,
@@ -918,10 +930,9 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
918 int result = 0; 930 int result = 0;
919 struct acpi_driver *driver; 931 struct acpi_driver *driver;
920 932
921 ACPI_FUNCTION_TRACE("acpi_bus_remove");
922 933
923 if (!dev) 934 if (!dev)
924 return_VALUE(-EINVAL); 935 return -EINVAL;
925 936
926 driver = dev->driver; 937 driver = dev->driver;
927 938
@@ -930,12 +941,12 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
930 if (driver->ops.stop) { 941 if (driver->ops.stop) {
931 result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT); 942 result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT);
932 if (result) 943 if (result)
933 return_VALUE(result); 944 return result;
934 } 945 }
935 946
936 result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT); 947 result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT);
937 if (result) { 948 if (result) {
938 return_VALUE(result); 949 return result;
939 } 950 }
940 951
941 atomic_dec(&dev->driver->references); 952 atomic_dec(&dev->driver->references);
@@ -944,7 +955,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
944 } 955 }
945 956
946 if (!rmdevice) 957 if (!rmdevice)
947 return_VALUE(0); 958 return 0;
948 959
949 if (dev->flags.bus_address) { 960 if (dev->flags.bus_address) {
950 if ((dev->parent) && (dev->parent->ops.unbind)) 961 if ((dev->parent) && (dev->parent->ops.unbind))
@@ -953,7 +964,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
953 964
954 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); 965 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
955 966
956 return_VALUE(0); 967 return 0;
957} 968}
958 969
959static int 970static int
@@ -963,15 +974,14 @@ acpi_add_single_object(struct acpi_device **child,
963 int result = 0; 974 int result = 0;
964 struct acpi_device *device = NULL; 975 struct acpi_device *device = NULL;
965 976
966 ACPI_FUNCTION_TRACE("acpi_add_single_object");
967 977
968 if (!child) 978 if (!child)
969 return_VALUE(-EINVAL); 979 return -EINVAL;
970 980
971 device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL); 981 device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
972 if (!device) { 982 if (!device) {
973 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); 983 printk(KERN_ERR PREFIX "Memory allocation error\n");
974 return_VALUE(-ENOMEM); 984 return -ENOMEM;
975 } 985 }
976 memset(device, 0, sizeof(struct acpi_device)); 986 memset(device, 0, sizeof(struct acpi_device));
977 987
@@ -1096,7 +1106,7 @@ acpi_add_single_object(struct acpi_device **child,
1096 kfree(device); 1106 kfree(device);
1097 } 1107 }
1098 1108
1099 return_VALUE(result); 1109 return result;
1100} 1110}
1101 1111
1102static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) 1112static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
@@ -1109,10 +1119,9 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1109 acpi_object_type type = 0; 1119 acpi_object_type type = 0;
1110 u32 level = 1; 1120 u32 level = 1;
1111 1121
1112 ACPI_FUNCTION_TRACE("acpi_bus_scan");
1113 1122
1114 if (!start) 1123 if (!start)
1115 return_VALUE(-EINVAL); 1124 return -EINVAL;
1116 1125
1117 parent = start; 1126 parent = start;
1118 phandle = start->handle; 1127 phandle = start->handle;
@@ -1209,7 +1218,7 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1209 } 1218 }
1210 } 1219 }
1211 1220
1212 return_VALUE(0); 1221 return 0;
1213} 1222}
1214 1223
1215int 1224int
@@ -1219,7 +1228,6 @@ acpi_bus_add(struct acpi_device **child,
1219 int result; 1228 int result;
1220 struct acpi_bus_ops ops; 1229 struct acpi_bus_ops ops;
1221 1230
1222 ACPI_FUNCTION_TRACE("acpi_bus_add");
1223 1231
1224 result = acpi_add_single_object(child, parent, handle, type); 1232 result = acpi_add_single_object(child, parent, handle, type);
1225 if (!result) { 1233 if (!result) {
@@ -1227,7 +1235,7 @@ acpi_bus_add(struct acpi_device **child,
1227 ops.acpi_op_add = 1; 1235 ops.acpi_op_add = 1;
1228 result = acpi_bus_scan(*child, &ops); 1236 result = acpi_bus_scan(*child, &ops);
1229 } 1237 }
1230 return_VALUE(result); 1238 return result;
1231} 1239}
1232 1240
1233EXPORT_SYMBOL(acpi_bus_add); 1241EXPORT_SYMBOL(acpi_bus_add);
@@ -1237,10 +1245,9 @@ int acpi_bus_start(struct acpi_device *device)
1237 int result; 1245 int result;
1238 struct acpi_bus_ops ops; 1246 struct acpi_bus_ops ops;
1239 1247
1240 ACPI_FUNCTION_TRACE("acpi_bus_start");
1241 1248
1242 if (!device) 1249 if (!device)
1243 return_VALUE(-EINVAL); 1250 return -EINVAL;
1244 1251
1245 result = acpi_start_single_object(device); 1252 result = acpi_start_single_object(device);
1246 if (!result) { 1253 if (!result) {
@@ -1248,7 +1255,7 @@ int acpi_bus_start(struct acpi_device *device)
1248 ops.acpi_op_start = 1; 1255 ops.acpi_op_start = 1;
1249 result = acpi_bus_scan(device, &ops); 1256 result = acpi_bus_scan(device, &ops);
1250 } 1257 }
1251 return_VALUE(result); 1258 return result;
1252} 1259}
1253 1260
1254EXPORT_SYMBOL(acpi_bus_start); 1261EXPORT_SYMBOL(acpi_bus_start);
@@ -1314,10 +1321,9 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1314 int result = 0; 1321 int result = 0;
1315 struct acpi_device *device = NULL; 1322 struct acpi_device *device = NULL;
1316 1323
1317 ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
1318 1324
1319 if (!root) 1325 if (!root)
1320 return_VALUE(-ENODEV); 1326 return -ENODEV;
1321 1327
1322 /* 1328 /*
1323 * Enumerate all fixed-feature devices. 1329 * Enumerate all fixed-feature devices.
@@ -1338,7 +1344,7 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1338 result = acpi_start_single_object(device); 1344 result = acpi_start_single_object(device);
1339 } 1345 }
1340 1346
1341 return_VALUE(result); 1347 return result;
1342} 1348}
1343 1349
1344 1350
@@ -1440,10 +1446,9 @@ static int __init acpi_scan_init(void)
1440 int result; 1446 int result;
1441 struct acpi_bus_ops ops; 1447 struct acpi_bus_ops ops;
1442 1448
1443 ACPI_FUNCTION_TRACE("acpi_scan_init");
1444 1449
1445 if (acpi_disabled) 1450 if (acpi_disabled)
1446 return_VALUE(0); 1451 return 0;
1447 1452
1448 kset_register(&acpi_namespace_kset); 1453 kset_register(&acpi_namespace_kset);
1449 1454
@@ -1488,7 +1493,7 @@ static int __init acpi_scan_init(void)
1488 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1493 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
1489 1494
1490 Done: 1495 Done:
1491 return_VALUE(result); 1496 return result;
1492} 1497}
1493 1498
1494subsys_initcall(acpi_scan_init); 1499subsys_initcall(acpi_scan_init);
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index a934ac42178d..c90bd2f70b3f 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -47,10 +47,9 @@ extern struct fadt_descriptor acpi_fadt;
47 47
48static int acpi_system_read_info(struct seq_file *seq, void *offset) 48static int acpi_system_read_info(struct seq_file *seq, void *offset)
49{ 49{
50 ACPI_FUNCTION_TRACE("acpi_system_read_info");
51 50
52 seq_printf(seq, "version: %x\n", ACPI_CA_VERSION); 51 seq_printf(seq, "version: %x\n", ACPI_CA_VERSION);
53 return_VALUE(0); 52 return 0;
54} 53}
55 54
56static int acpi_system_info_open_fs(struct inode *inode, struct file *file) 55static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
@@ -80,17 +79,16 @@ acpi_system_read_dsdt(struct file *file,
80 struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL }; 79 struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
81 ssize_t res; 80 ssize_t res;
82 81
83 ACPI_FUNCTION_TRACE("acpi_system_read_dsdt");
84 82
85 status = acpi_get_table(ACPI_TABLE_ID_DSDT, 1, &dsdt); 83 status = acpi_get_table(ACPI_TABLE_ID_DSDT, 1, &dsdt);
86 if (ACPI_FAILURE(status)) 84 if (ACPI_FAILURE(status))
87 return_VALUE(-ENODEV); 85 return -ENODEV;
88 86
89 res = simple_read_from_buffer(buffer, count, ppos, 87 res = simple_read_from_buffer(buffer, count, ppos,
90 dsdt.pointer, dsdt.length); 88 dsdt.pointer, dsdt.length);
91 acpi_os_free(dsdt.pointer); 89 acpi_os_free(dsdt.pointer);
92 90
93 return_VALUE(res); 91 return res;
94} 92}
95 93
96static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, 94static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
@@ -108,17 +106,16 @@ acpi_system_read_fadt(struct file *file,
108 struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL }; 106 struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL };
109 ssize_t res; 107 ssize_t res;
110 108
111 ACPI_FUNCTION_TRACE("acpi_system_read_fadt");
112 109
113 status = acpi_get_table(ACPI_TABLE_ID_FADT, 1, &fadt); 110 status = acpi_get_table(ACPI_TABLE_ID_FADT, 1, &fadt);
114 if (ACPI_FAILURE(status)) 111 if (ACPI_FAILURE(status))
115 return_VALUE(-ENODEV); 112 return -ENODEV;
116 113
117 res = simple_read_from_buffer(buffer, count, ppos, 114 res = simple_read_from_buffer(buffer, count, ppos,
118 fadt.pointer, fadt.length); 115 fadt.pointer, fadt.length);
119 acpi_os_free(fadt.pointer); 116 acpi_os_free(fadt.pointer);
120 117
121 return_VALUE(res); 118 return res;
122} 119}
123 120
124static int __init acpi_system_init(void) 121static int __init acpi_system_init(void)
@@ -127,10 +124,9 @@ static int __init acpi_system_init(void)
127 int error = 0; 124 int error = 0;
128 char *name; 125 char *name;
129 126
130 ACPI_FUNCTION_TRACE("acpi_system_init");
131 127
132 if (acpi_disabled) 128 if (acpi_disabled)
133 return_VALUE(0); 129 return 0;
134 130
135 /* 'info' [R] */ 131 /* 'info' [R] */
136 name = ACPI_SYSTEM_FILE_INFO; 132 name = ACPI_SYSTEM_FILE_INFO;
@@ -158,12 +154,9 @@ static int __init acpi_system_init(void)
158 goto Error; 154 goto Error;
159 155
160 Done: 156 Done:
161 return_VALUE(error); 157 return error;
162 158
163 Error: 159 Error:
164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
165 "Unable to create '%s' proc fs entry\n", name));
166
167 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); 160 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
168 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); 161 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
169 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); 162 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index e7fe3a14fdaf..c855f4446b5f 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -222,51 +222,48 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
222{ 222{
223 acpi_status status = AE_OK; 223 acpi_status status = AE_OK;
224 224
225 ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature");
226 225
227 if (!tz) 226 if (!tz)
228 return_VALUE(-EINVAL); 227 return -EINVAL;
229 228
230 tz->last_temperature = tz->temperature; 229 tz->last_temperature = tz->temperature;
231 230
232 status = 231 status =
233 acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); 232 acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature);
234 if (ACPI_FAILURE(status)) 233 if (ACPI_FAILURE(status))
235 return_VALUE(-ENODEV); 234 return -ENODEV;
236 235
237 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", 236 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
238 tz->temperature)); 237 tz->temperature));
239 238
240 return_VALUE(0); 239 return 0;
241} 240}
242 241
243static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) 242static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
244{ 243{
245 acpi_status status = AE_OK; 244 acpi_status status = AE_OK;
246 245
247 ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency");
248 246
249 if (!tz) 247 if (!tz)
250 return_VALUE(-EINVAL); 248 return -EINVAL;
251 249
252 status = 250 status =
253 acpi_evaluate_integer(tz->handle, "_TZP", NULL, 251 acpi_evaluate_integer(tz->handle, "_TZP", NULL,
254 &tz->polling_frequency); 252 &tz->polling_frequency);
255 if (ACPI_FAILURE(status)) 253 if (ACPI_FAILURE(status))
256 return_VALUE(-ENODEV); 254 return -ENODEV;
257 255
258 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", 256 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
259 tz->polling_frequency)); 257 tz->polling_frequency));
260 258
261 return_VALUE(0); 259 return 0;
262} 260}
263 261
264static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) 262static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
265{ 263{
266 ACPI_FUNCTION_TRACE("acpi_thermal_set_polling");
267 264
268 if (!tz) 265 if (!tz)
269 return_VALUE(-EINVAL); 266 return -EINVAL;
270 267
271 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ 268 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */
272 269
@@ -274,7 +271,7 @@ static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
274 "Polling frequency set to %lu seconds\n", 271 "Polling frequency set to %lu seconds\n",
275 tz->polling_frequency)); 272 tz->polling_frequency));
276 273
277 return_VALUE(0); 274 return 0;
278} 275}
279 276
280static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) 277static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
@@ -284,29 +281,28 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
284 struct acpi_object_list arg_list = { 1, &arg0 }; 281 struct acpi_object_list arg_list = { 1, &arg0 };
285 acpi_handle handle = NULL; 282 acpi_handle handle = NULL;
286 283
287 ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode");
288 284
289 if (!tz) 285 if (!tz)
290 return_VALUE(-EINVAL); 286 return -EINVAL;
291 287
292 status = acpi_get_handle(tz->handle, "_SCP", &handle); 288 status = acpi_get_handle(tz->handle, "_SCP", &handle);
293 if (ACPI_FAILURE(status)) { 289 if (ACPI_FAILURE(status)) {
294 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); 290 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
295 return_VALUE(-ENODEV); 291 return -ENODEV;
296 } 292 }
297 293
298 arg0.integer.value = mode; 294 arg0.integer.value = mode;
299 295
300 status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); 296 status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
301 if (ACPI_FAILURE(status)) 297 if (ACPI_FAILURE(status))
302 return_VALUE(-ENODEV); 298 return -ENODEV;
303 299
304 tz->cooling_mode = mode; 300 tz->cooling_mode = mode;
305 301
306 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", 302 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n",
307 mode ? "passive" : "active")); 303 mode ? "passive" : "active"));
308 304
309 return_VALUE(0); 305 return 0;
310} 306}
311 307
312static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) 308static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
@@ -314,10 +310,9 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
314 acpi_status status = AE_OK; 310 acpi_status status = AE_OK;
315 int i = 0; 311 int i = 0;
316 312
317 ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points");
318 313
319 if (!tz) 314 if (!tz)
320 return_VALUE(-EINVAL); 315 return -EINVAL;
321 316
322 /* Critical Shutdown (required) */ 317 /* Critical Shutdown (required) */
323 318
@@ -325,8 +320,8 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
325 &tz->trips.critical.temperature); 320 &tz->trips.critical.temperature);
326 if (ACPI_FAILURE(status)) { 321 if (ACPI_FAILURE(status)) {
327 tz->trips.critical.flags.valid = 0; 322 tz->trips.critical.flags.valid = 0;
328 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n")); 323 ACPI_EXCEPTION((AE_INFO, status, "No critical threshold"));
329 return_VALUE(-ENODEV); 324 return -ENODEV;
330 } else { 325 } else {
331 tz->trips.critical.flags.valid = 1; 326 tz->trips.critical.flags.valid = 1;
332 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 327 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -384,8 +379,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
384 tz->trips.passive.flags.valid = 0; 379 tz->trips.passive.flags.valid = 0;
385 380
386 if (!tz->trips.passive.flags.valid) 381 if (!tz->trips.passive.flags.valid)
387 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 382 printk(KERN_WARNING PREFIX "Invalid passive threshold\n");
388 "Invalid passive threshold\n"));
389 else 383 else
390 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 384 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
391 "Found passive threshold [%lu]\n", 385 "Found passive threshold [%lu]\n",
@@ -414,29 +408,27 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
414 "Found active threshold [%d]:[%lu]\n", 408 "Found active threshold [%d]:[%lu]\n",
415 i, tz->trips.active[i].temperature)); 409 i, tz->trips.active[i].temperature));
416 } else 410 } else
417 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 411 ACPI_EXCEPTION((AE_INFO, status,
418 "Invalid active threshold [%d]\n", 412 "Invalid active threshold [%d]", i));
419 i));
420 } 413 }
421 414
422 return_VALUE(0); 415 return 0;
423} 416}
424 417
425static int acpi_thermal_get_devices(struct acpi_thermal *tz) 418static int acpi_thermal_get_devices(struct acpi_thermal *tz)
426{ 419{
427 acpi_status status = AE_OK; 420 acpi_status status = AE_OK;
428 421
429 ACPI_FUNCTION_TRACE("acpi_thermal_get_devices");
430 422
431 if (!tz) 423 if (!tz)
432 return_VALUE(-EINVAL); 424 return -EINVAL;
433 425
434 status = 426 status =
435 acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); 427 acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices);
436 if (ACPI_FAILURE(status)) 428 if (ACPI_FAILURE(status))
437 return_VALUE(-ENODEV); 429 return -ENODEV;
438 430
439 return_VALUE(0); 431 return 0;
440} 432}
441 433
442static int acpi_thermal_call_usermode(char *path) 434static int acpi_thermal_call_usermode(char *path)
@@ -444,10 +436,9 @@ static int acpi_thermal_call_usermode(char *path)
444 char *argv[2] = { NULL, NULL }; 436 char *argv[2] = { NULL, NULL };
445 char *envp[3] = { NULL, NULL, NULL }; 437 char *envp[3] = { NULL, NULL, NULL };
446 438
447 ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode");
448 439
449 if (!path) 440 if (!path)
450 return_VALUE(-EINVAL); 441 return -EINVAL;
451 442
452 argv[0] = path; 443 argv[0] = path;
453 444
@@ -457,7 +448,7 @@ static int acpi_thermal_call_usermode(char *path)
457 448
458 call_usermodehelper(argv[0], argv, envp, 0); 449 call_usermodehelper(argv[0], argv, envp, 0);
459 450
460 return_VALUE(0); 451 return 0;
461} 452}
462 453
463static int acpi_thermal_critical(struct acpi_thermal *tz) 454static int acpi_thermal_critical(struct acpi_thermal *tz)
@@ -465,20 +456,19 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
465 int result = 0; 456 int result = 0;
466 struct acpi_device *device = NULL; 457 struct acpi_device *device = NULL;
467 458
468 ACPI_FUNCTION_TRACE("acpi_thermal_critical");
469 459
470 if (!tz || !tz->trips.critical.flags.valid) 460 if (!tz || !tz->trips.critical.flags.valid)
471 return_VALUE(-EINVAL); 461 return -EINVAL;
472 462
473 if (tz->temperature >= tz->trips.critical.temperature) { 463 if (tz->temperature >= tz->trips.critical.temperature) {
474 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n")); 464 printk(KERN_WARNING PREFIX "Critical trip point\n");
475 tz->trips.critical.flags.enabled = 1; 465 tz->trips.critical.flags.enabled = 1;
476 } else if (tz->trips.critical.flags.enabled) 466 } else if (tz->trips.critical.flags.enabled)
477 tz->trips.critical.flags.enabled = 0; 467 tz->trips.critical.flags.enabled = 0;
478 468
479 result = acpi_bus_get_device(tz->handle, &device); 469 result = acpi_bus_get_device(tz->handle, &device);
480 if (result) 470 if (result)
481 return_VALUE(result); 471 return result;
482 472
483 printk(KERN_EMERG 473 printk(KERN_EMERG
484 "Critical temperature reached (%ld C), shutting down.\n", 474 "Critical temperature reached (%ld C), shutting down.\n",
@@ -488,7 +478,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
488 478
489 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); 479 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
490 480
491 return_VALUE(0); 481 return 0;
492} 482}
493 483
494static int acpi_thermal_hot(struct acpi_thermal *tz) 484static int acpi_thermal_hot(struct acpi_thermal *tz)
@@ -496,27 +486,26 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
496 int result = 0; 486 int result = 0;
497 struct acpi_device *device = NULL; 487 struct acpi_device *device = NULL;
498 488
499 ACPI_FUNCTION_TRACE("acpi_thermal_hot");
500 489
501 if (!tz || !tz->trips.hot.flags.valid) 490 if (!tz || !tz->trips.hot.flags.valid)
502 return_VALUE(-EINVAL); 491 return -EINVAL;
503 492
504 if (tz->temperature >= tz->trips.hot.temperature) { 493 if (tz->temperature >= tz->trips.hot.temperature) {
505 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n")); 494 printk(KERN_WARNING PREFIX "Hot trip point\n");
506 tz->trips.hot.flags.enabled = 1; 495 tz->trips.hot.flags.enabled = 1;
507 } else if (tz->trips.hot.flags.enabled) 496 } else if (tz->trips.hot.flags.enabled)
508 tz->trips.hot.flags.enabled = 0; 497 tz->trips.hot.flags.enabled = 0;
509 498
510 result = acpi_bus_get_device(tz->handle, &device); 499 result = acpi_bus_get_device(tz->handle, &device);
511 if (result) 500 if (result)
512 return_VALUE(result); 501 return result;
513 502
514 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, 503 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT,
515 tz->trips.hot.flags.enabled); 504 tz->trips.hot.flags.enabled);
516 505
517 /* TBD: Call user-mode "sleep(S4)" function */ 506 /* TBD: Call user-mode "sleep(S4)" function */
518 507
519 return_VALUE(0); 508 return 0;
520} 509}
521 510
522static void acpi_thermal_passive(struct acpi_thermal *tz) 511static void acpi_thermal_passive(struct acpi_thermal *tz)
@@ -526,7 +515,6 @@ static void acpi_thermal_passive(struct acpi_thermal *tz)
526 int trend = 0; 515 int trend = 0;
527 int i = 0; 516 int i = 0;
528 517
529 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
530 518
531 if (!tz || !tz->trips.passive.flags.valid) 519 if (!tz || !tz->trips.passive.flags.valid)
532 return; 520 return;
@@ -615,7 +603,6 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
615 int j = 0; 603 int j = 0;
616 unsigned long maxtemp = 0; 604 unsigned long maxtemp = 0;
617 605
618 ACPI_FUNCTION_TRACE("acpi_thermal_active");
619 606
620 if (!tz) 607 if (!tz)
621 return; 608 return;
@@ -642,10 +629,10 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
642 handles[j], 629 handles[j],
643 ACPI_STATE_D0); 630 ACPI_STATE_D0);
644 if (result) { 631 if (result) {
645 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 632 printk(KERN_WARNING PREFIX
646 "Unable to turn cooling device [%p] 'on'\n", 633 "Unable to turn cooling device [%p] 'on'\n",
647 active->devices. 634 active->devices.
648 handles[j])); 635 handles[j]);
649 continue; 636 continue;
650 } 637 }
651 active->flags.enabled = 1; 638 active->flags.enabled = 1;
@@ -667,9 +654,9 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
667 result = acpi_bus_set_power(active->devices.handles[j], 654 result = acpi_bus_set_power(active->devices.handles[j],
668 ACPI_STATE_D3); 655 ACPI_STATE_D3);
669 if (result) { 656 if (result) {
670 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 657 printk(KERN_WARNING PREFIX
671 "Unable to turn cooling device [%p] 'off'\n", 658 "Unable to turn cooling device [%p] 'off'\n",
672 active->devices.handles[j])); 659 active->devices.handles[j]);
673 continue; 660 continue;
674 } 661 }
675 active->flags.enabled = 0; 662 active->flags.enabled = 0;
@@ -697,18 +684,17 @@ static void acpi_thermal_check(void *data)
697 int i = 0; 684 int i = 0;
698 struct acpi_thermal_state state; 685 struct acpi_thermal_state state;
699 686
700 ACPI_FUNCTION_TRACE("acpi_thermal_check");
701 687
702 if (!tz) { 688 if (!tz) {
703 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); 689 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
704 return_VOID; 690 return;
705 } 691 }
706 692
707 state = tz->state; 693 state = tz->state;
708 694
709 result = acpi_thermal_get_temperature(tz); 695 result = acpi_thermal_get_temperature(tz);
710 if (result) 696 if (result)
711 return_VOID; 697 return;
712 698
713 memset(&tz->state, 0, sizeof(tz->state)); 699 memset(&tz->state, 0, sizeof(tz->state));
714 700
@@ -797,7 +783,7 @@ static void acpi_thermal_check(void *data)
797 } 783 }
798 } 784 }
799 785
800 return_VOID; 786 return;
801} 787}
802 788
803/* -------------------------------------------------------------------------- 789/* --------------------------------------------------------------------------
@@ -810,7 +796,6 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
810{ 796{
811 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 797 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
812 798
813 ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show");
814 799
815 if (!tz) 800 if (!tz)
816 goto end; 801 goto end;
@@ -833,7 +818,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
833 } 818 }
834 819
835 end: 820 end:
836 return_VALUE(0); 821 return 0;
837} 822}
838 823
839static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) 824static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
@@ -846,7 +831,6 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
846 int result = 0; 831 int result = 0;
847 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 832 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
848 833
849 ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show");
850 834
851 if (!tz) 835 if (!tz)
852 goto end; 836 goto end;
@@ -859,7 +843,7 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
859 KELVIN_TO_CELSIUS(tz->temperature)); 843 KELVIN_TO_CELSIUS(tz->temperature));
860 844
861 end: 845 end:
862 return_VALUE(0); 846 return 0;
863} 847}
864 848
865static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) 849static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
@@ -873,7 +857,6 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
873 int i = 0; 857 int i = 0;
874 int j = 0; 858 int j = 0;
875 859
876 ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show");
877 860
878 if (!tz) 861 if (!tz)
879 goto end; 862 goto end;
@@ -913,7 +896,7 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
913 } 896 }
914 897
915 end: 898 end:
916 return_VALUE(0); 899 return 0;
917} 900}
918 901
919static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) 902static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
@@ -934,28 +917,25 @@ acpi_thermal_write_trip_points(struct file *file,
934 int *active; 917 int *active;
935 int i = 0; 918 int i = 0;
936 919
937 ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points");
938 920
939 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); 921 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
940 if (!limit_string) 922 if (!limit_string)
941 return_VALUE(-ENOMEM); 923 return -ENOMEM;
942 924
943 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); 925 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
944 926
945 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); 927 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
946 if (!active) { 928 if (!active) {
947 kfree(limit_string); 929 kfree(limit_string);
948 return_VALUE(-ENOMEM); 930 return -ENOMEM;
949 } 931 }
950 932
951 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { 933 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
952 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
953 count = -EINVAL; 934 count = -EINVAL;
954 goto end; 935 goto end;
955 } 936 }
956 937
957 if (copy_from_user(limit_string, buffer, count)) { 938 if (copy_from_user(limit_string, buffer, count)) {
958 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
959 count = -EFAULT; 939 count = -EFAULT;
960 goto end; 940 goto end;
961 } 941 }
@@ -968,7 +948,6 @@ acpi_thermal_write_trip_points(struct file *file,
968 &active[5], &active[6], &active[7], &active[8], 948 &active[5], &active[6], &active[7], &active[8],
969 &active[9]); 949 &active[9]);
970 if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { 950 if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) {
971 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
972 count = -EINVAL; 951 count = -EINVAL;
973 goto end; 952 goto end;
974 } 953 }
@@ -985,14 +964,13 @@ acpi_thermal_write_trip_points(struct file *file,
985 end: 964 end:
986 kfree(active); 965 kfree(active);
987 kfree(limit_string); 966 kfree(limit_string);
988 return_VALUE(count); 967 return count;
989} 968}
990 969
991static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) 970static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
992{ 971{
993 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 972 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
994 973
995 ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show");
996 974
997 if (!tz) 975 if (!tz)
998 goto end; 976 goto end;
@@ -1008,7 +986,7 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
1008 tz->cooling_mode ? "passive" : "active"); 986 tz->cooling_mode ? "passive" : "active");
1009 987
1010 end: 988 end:
1011 return_VALUE(0); 989 return 0;
1012} 990}
1013 991
1014static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) 992static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
@@ -1027,16 +1005,15 @@ acpi_thermal_write_cooling_mode(struct file *file,
1027 int result = 0; 1005 int result = 0;
1028 char mode_string[12] = { '\0' }; 1006 char mode_string[12] = { '\0' };
1029 1007
1030 ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode");
1031 1008
1032 if (!tz || (count > sizeof(mode_string) - 1)) 1009 if (!tz || (count > sizeof(mode_string) - 1))
1033 return_VALUE(-EINVAL); 1010 return -EINVAL;
1034 1011
1035 if (!tz->flags.cooling_mode) 1012 if (!tz->flags.cooling_mode)
1036 return_VALUE(-ENODEV); 1013 return -ENODEV;
1037 1014
1038 if (copy_from_user(mode_string, buffer, count)) 1015 if (copy_from_user(mode_string, buffer, count))
1039 return_VALUE(-EFAULT); 1016 return -EFAULT;
1040 1017
1041 mode_string[count] = '\0'; 1018 mode_string[count] = '\0';
1042 1019
@@ -1044,18 +1021,17 @@ acpi_thermal_write_cooling_mode(struct file *file,
1044 simple_strtoul(mode_string, NULL, 1021 simple_strtoul(mode_string, NULL,
1045 0)); 1022 0));
1046 if (result) 1023 if (result)
1047 return_VALUE(result); 1024 return result;
1048 1025
1049 acpi_thermal_check(tz); 1026 acpi_thermal_check(tz);
1050 1027
1051 return_VALUE(count); 1028 return count;
1052} 1029}
1053 1030
1054static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) 1031static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1055{ 1032{
1056 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 1033 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
1057 1034
1058 ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show");
1059 1035
1060 if (!tz) 1036 if (!tz)
1061 goto end; 1037 goto end;
@@ -1069,7 +1045,7 @@ static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1069 (tz->polling_frequency / 10)); 1045 (tz->polling_frequency / 10));
1070 1046
1071 end: 1047 end:
1072 return_VALUE(0); 1048 return 0;
1073} 1049}
1074 1050
1075static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) 1051static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
@@ -1089,13 +1065,12 @@ acpi_thermal_write_polling(struct file *file,
1089 char polling_string[12] = { '\0' }; 1065 char polling_string[12] = { '\0' };
1090 int seconds = 0; 1066 int seconds = 0;
1091 1067
1092 ACPI_FUNCTION_TRACE("acpi_thermal_write_polling");
1093 1068
1094 if (!tz || (count > sizeof(polling_string) - 1)) 1069 if (!tz || (count > sizeof(polling_string) - 1))
1095 return_VALUE(-EINVAL); 1070 return -EINVAL;
1096 1071
1097 if (copy_from_user(polling_string, buffer, count)) 1072 if (copy_from_user(polling_string, buffer, count))
1098 return_VALUE(-EFAULT); 1073 return -EFAULT;
1099 1074
1100 polling_string[count] = '\0'; 1075 polling_string[count] = '\0';
1101 1076
@@ -1103,24 +1078,23 @@ acpi_thermal_write_polling(struct file *file,
1103 1078
1104 result = acpi_thermal_set_polling(tz, seconds); 1079 result = acpi_thermal_set_polling(tz, seconds);
1105 if (result) 1080 if (result)
1106 return_VALUE(result); 1081 return result;
1107 1082
1108 acpi_thermal_check(tz); 1083 acpi_thermal_check(tz);
1109 1084
1110 return_VALUE(count); 1085 return count;
1111} 1086}
1112 1087
1113static int acpi_thermal_add_fs(struct acpi_device *device) 1088static int acpi_thermal_add_fs(struct acpi_device *device)
1114{ 1089{
1115 struct proc_dir_entry *entry = NULL; 1090 struct proc_dir_entry *entry = NULL;
1116 1091
1117 ACPI_FUNCTION_TRACE("acpi_thermal_add_fs");
1118 1092
1119 if (!acpi_device_dir(device)) { 1093 if (!acpi_device_dir(device)) {
1120 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1094 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1121 acpi_thermal_dir); 1095 acpi_thermal_dir);
1122 if (!acpi_device_dir(device)) 1096 if (!acpi_device_dir(device))
1123 return_VALUE(-ENODEV); 1097 return -ENODEV;
1124 acpi_device_dir(device)->owner = THIS_MODULE; 1098 acpi_device_dir(device)->owner = THIS_MODULE;
1125 } 1099 }
1126 1100
@@ -1128,9 +1102,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1128 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, 1102 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
1129 S_IRUGO, acpi_device_dir(device)); 1103 S_IRUGO, acpi_device_dir(device));
1130 if (!entry) 1104 if (!entry)
1131 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1105 return -ENODEV;
1132 "Unable to create '%s' fs entry\n",
1133 ACPI_THERMAL_FILE_STATE));
1134 else { 1106 else {
1135 entry->proc_fops = &acpi_thermal_state_fops; 1107 entry->proc_fops = &acpi_thermal_state_fops;
1136 entry->data = acpi_driver_data(device); 1108 entry->data = acpi_driver_data(device);
@@ -1141,9 +1113,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1141 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, 1113 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
1142 S_IRUGO, acpi_device_dir(device)); 1114 S_IRUGO, acpi_device_dir(device));
1143 if (!entry) 1115 if (!entry)
1144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1116 return -ENODEV;
1145 "Unable to create '%s' fs entry\n",
1146 ACPI_THERMAL_FILE_TEMPERATURE));
1147 else { 1117 else {
1148 entry->proc_fops = &acpi_thermal_temp_fops; 1118 entry->proc_fops = &acpi_thermal_temp_fops;
1149 entry->data = acpi_driver_data(device); 1119 entry->data = acpi_driver_data(device);
@@ -1155,9 +1125,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1155 S_IFREG | S_IRUGO | S_IWUSR, 1125 S_IFREG | S_IRUGO | S_IWUSR,
1156 acpi_device_dir(device)); 1126 acpi_device_dir(device));
1157 if (!entry) 1127 if (!entry)
1158 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1128 return -ENODEV;
1159 "Unable to create '%s' fs entry\n",
1160 ACPI_THERMAL_FILE_TRIP_POINTS));
1161 else { 1129 else {
1162 entry->proc_fops = &acpi_thermal_trip_fops; 1130 entry->proc_fops = &acpi_thermal_trip_fops;
1163 entry->data = acpi_driver_data(device); 1131 entry->data = acpi_driver_data(device);
@@ -1169,9 +1137,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1169 S_IFREG | S_IRUGO | S_IWUSR, 1137 S_IFREG | S_IRUGO | S_IWUSR,
1170 acpi_device_dir(device)); 1138 acpi_device_dir(device));
1171 if (!entry) 1139 if (!entry)
1172 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1140 return -ENODEV;
1173 "Unable to create '%s' fs entry\n",
1174 ACPI_THERMAL_FILE_COOLING_MODE));
1175 else { 1141 else {
1176 entry->proc_fops = &acpi_thermal_cooling_fops; 1142 entry->proc_fops = &acpi_thermal_cooling_fops;
1177 entry->data = acpi_driver_data(device); 1143 entry->data = acpi_driver_data(device);
@@ -1183,21 +1149,18 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1183 S_IFREG | S_IRUGO | S_IWUSR, 1149 S_IFREG | S_IRUGO | S_IWUSR,
1184 acpi_device_dir(device)); 1150 acpi_device_dir(device));
1185 if (!entry) 1151 if (!entry)
1186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1152 return -ENODEV;
1187 "Unable to create '%s' fs entry\n",
1188 ACPI_THERMAL_FILE_POLLING_FREQ));
1189 else { 1153 else {
1190 entry->proc_fops = &acpi_thermal_polling_fops; 1154 entry->proc_fops = &acpi_thermal_polling_fops;
1191 entry->data = acpi_driver_data(device); 1155 entry->data = acpi_driver_data(device);
1192 entry->owner = THIS_MODULE; 1156 entry->owner = THIS_MODULE;
1193 } 1157 }
1194 1158
1195 return_VALUE(0); 1159 return 0;
1196} 1160}
1197 1161
1198static int acpi_thermal_remove_fs(struct acpi_device *device) 1162static int acpi_thermal_remove_fs(struct acpi_device *device)
1199{ 1163{
1200 ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs");
1201 1164
1202 if (acpi_device_dir(device)) { 1165 if (acpi_device_dir(device)) {
1203 remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, 1166 remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
@@ -1214,7 +1177,7 @@ static int acpi_thermal_remove_fs(struct acpi_device *device)
1214 acpi_device_dir(device) = NULL; 1177 acpi_device_dir(device) = NULL;
1215 } 1178 }
1216 1179
1217 return_VALUE(0); 1180 return 0;
1218} 1181}
1219 1182
1220/* -------------------------------------------------------------------------- 1183/* --------------------------------------------------------------------------
@@ -1226,13 +1189,12 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1226 struct acpi_thermal *tz = (struct acpi_thermal *)data; 1189 struct acpi_thermal *tz = (struct acpi_thermal *)data;
1227 struct acpi_device *device = NULL; 1190 struct acpi_device *device = NULL;
1228 1191
1229 ACPI_FUNCTION_TRACE("acpi_thermal_notify");
1230 1192
1231 if (!tz) 1193 if (!tz)
1232 return_VOID; 1194 return;
1233 1195
1234 if (acpi_bus_get_device(tz->handle, &device)) 1196 if (acpi_bus_get_device(tz->handle, &device))
1235 return_VOID; 1197 return;
1236 1198
1237 switch (event) { 1199 switch (event) {
1238 case ACPI_THERMAL_NOTIFY_TEMPERATURE: 1200 case ACPI_THERMAL_NOTIFY_TEMPERATURE:
@@ -1254,27 +1216,26 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1254 break; 1216 break;
1255 } 1217 }
1256 1218
1257 return_VOID; 1219 return;
1258} 1220}
1259 1221
1260static int acpi_thermal_get_info(struct acpi_thermal *tz) 1222static int acpi_thermal_get_info(struct acpi_thermal *tz)
1261{ 1223{
1262 int result = 0; 1224 int result = 0;
1263 1225
1264 ACPI_FUNCTION_TRACE("acpi_thermal_get_info");
1265 1226
1266 if (!tz) 1227 if (!tz)
1267 return_VALUE(-EINVAL); 1228 return -EINVAL;
1268 1229
1269 /* Get temperature [_TMP] (required) */ 1230 /* Get temperature [_TMP] (required) */
1270 result = acpi_thermal_get_temperature(tz); 1231 result = acpi_thermal_get_temperature(tz);
1271 if (result) 1232 if (result)
1272 return_VALUE(result); 1233 return result;
1273 1234
1274 /* Get trip points [_CRT, _PSV, etc.] (required) */ 1235 /* Get trip points [_CRT, _PSV, etc.] (required) */
1275 result = acpi_thermal_get_trip_points(tz); 1236 result = acpi_thermal_get_trip_points(tz);
1276 if (result) 1237 if (result)
1277 return_VALUE(result); 1238 return result;
1278 1239
1279 /* Set the cooling mode [_SCP] to active cooling (default) */ 1240 /* Set the cooling mode [_SCP] to active cooling (default) */
1280 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); 1241 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
@@ -1314,7 +1275,7 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
1314 if (!result) 1275 if (!result)
1315 tz->flags.devices = 1; 1276 tz->flags.devices = 1;
1316 1277
1317 return_VALUE(0); 1278 return 0;
1318} 1279}
1319 1280
1320static int acpi_thermal_add(struct acpi_device *device) 1281static int acpi_thermal_add(struct acpi_device *device)
@@ -1323,14 +1284,13 @@ static int acpi_thermal_add(struct acpi_device *device)
1323 acpi_status status = AE_OK; 1284 acpi_status status = AE_OK;
1324 struct acpi_thermal *tz = NULL; 1285 struct acpi_thermal *tz = NULL;
1325 1286
1326 ACPI_FUNCTION_TRACE("acpi_thermal_add");
1327 1287
1328 if (!device) 1288 if (!device)
1329 return_VALUE(-EINVAL); 1289 return -EINVAL;
1330 1290
1331 tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL); 1291 tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
1332 if (!tz) 1292 if (!tz)
1333 return_VALUE(-ENOMEM); 1293 return -ENOMEM;
1334 memset(tz, 0, sizeof(struct acpi_thermal)); 1294 memset(tz, 0, sizeof(struct acpi_thermal));
1335 1295
1336 tz->handle = device->handle; 1296 tz->handle = device->handle;
@@ -1355,8 +1315,6 @@ static int acpi_thermal_add(struct acpi_device *device)
1355 ACPI_DEVICE_NOTIFY, 1315 ACPI_DEVICE_NOTIFY,
1356 acpi_thermal_notify, tz); 1316 acpi_thermal_notify, tz);
1357 if (ACPI_FAILURE(status)) { 1317 if (ACPI_FAILURE(status)) {
1358 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1359 "Error installing notify handler\n"));
1360 result = -ENODEV; 1318 result = -ENODEV;
1361 goto end; 1319 goto end;
1362 } 1320 }
@@ -1371,7 +1329,7 @@ static int acpi_thermal_add(struct acpi_device *device)
1371 kfree(tz); 1329 kfree(tz);
1372 } 1330 }
1373 1331
1374 return_VALUE(result); 1332 return result;
1375} 1333}
1376 1334
1377static int acpi_thermal_remove(struct acpi_device *device, int type) 1335static int acpi_thermal_remove(struct acpi_device *device, int type)
@@ -1379,10 +1337,9 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1379 acpi_status status = AE_OK; 1337 acpi_status status = AE_OK;
1380 struct acpi_thermal *tz = NULL; 1338 struct acpi_thermal *tz = NULL;
1381 1339
1382 ACPI_FUNCTION_TRACE("acpi_thermal_remove");
1383 1340
1384 if (!device || !acpi_driver_data(device)) 1341 if (!device || !acpi_driver_data(device))
1385 return_VALUE(-EINVAL); 1342 return -EINVAL;
1386 1343
1387 tz = (struct acpi_thermal *)acpi_driver_data(device); 1344 tz = (struct acpi_thermal *)acpi_driver_data(device);
1388 1345
@@ -1398,9 +1355,6 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1398 status = acpi_remove_notify_handler(tz->handle, 1355 status = acpi_remove_notify_handler(tz->handle,
1399 ACPI_DEVICE_NOTIFY, 1356 ACPI_DEVICE_NOTIFY,
1400 acpi_thermal_notify); 1357 acpi_thermal_notify);
1401 if (ACPI_FAILURE(status))
1402 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1403 "Error removing notify handler\n"));
1404 1358
1405 /* Terminate policy */ 1359 /* Terminate policy */
1406 if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { 1360 if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) {
@@ -1416,7 +1370,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1416 acpi_thermal_remove_fs(device); 1370 acpi_thermal_remove_fs(device);
1417 1371
1418 kfree(tz); 1372 kfree(tz);
1419 return_VALUE(0); 1373 return 0;
1420} 1374}
1421 1375
1422static int acpi_thermal_resume(struct acpi_device *device, int state) 1376static int acpi_thermal_resume(struct acpi_device *device, int state)
@@ -1424,7 +1378,7 @@ static int acpi_thermal_resume(struct acpi_device *device, int state)
1424 struct acpi_thermal *tz = NULL; 1378 struct acpi_thermal *tz = NULL;
1425 1379
1426 if (!device || !acpi_driver_data(device)) 1380 if (!device || !acpi_driver_data(device))
1427 return_VALUE(-EINVAL); 1381 return -EINVAL;
1428 1382
1429 tz = (struct acpi_thermal *)acpi_driver_data(device); 1383 tz = (struct acpi_thermal *)acpi_driver_data(device);
1430 1384
@@ -1437,31 +1391,29 @@ static int __init acpi_thermal_init(void)
1437{ 1391{
1438 int result = 0; 1392 int result = 0;
1439 1393
1440 ACPI_FUNCTION_TRACE("acpi_thermal_init");
1441 1394
1442 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); 1395 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
1443 if (!acpi_thermal_dir) 1396 if (!acpi_thermal_dir)
1444 return_VALUE(-ENODEV); 1397 return -ENODEV;
1445 acpi_thermal_dir->owner = THIS_MODULE; 1398 acpi_thermal_dir->owner = THIS_MODULE;
1446 1399
1447 result = acpi_bus_register_driver(&acpi_thermal_driver); 1400 result = acpi_bus_register_driver(&acpi_thermal_driver);
1448 if (result < 0) { 1401 if (result < 0) {
1449 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1402 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1450 return_VALUE(-ENODEV); 1403 return -ENODEV;
1451 } 1404 }
1452 1405
1453 return_VALUE(0); 1406 return 0;
1454} 1407}
1455 1408
1456static void __exit acpi_thermal_exit(void) 1409static void __exit acpi_thermal_exit(void)
1457{ 1410{
1458 ACPI_FUNCTION_TRACE("acpi_thermal_exit");
1459 1411
1460 acpi_bus_unregister_driver(&acpi_thermal_driver); 1412 acpi_bus_unregister_driver(&acpi_thermal_driver);
1461 1413
1462 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1414 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1463 1415
1464 return_VOID; 1416 return;
1465} 1417}
1466 1418
1467module_init(acpi_thermal_init); 1419module_init(acpi_thermal_init);
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 67b9f325c6fa..38ebe1c54330 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -155,21 +155,30 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
155 case ACPI_TYPE_MUTEX: 155 case ACPI_TYPE_MUTEX:
156 156
157 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 157 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
158 "***** Mutex %p, Semaphore %p\n", 158 "***** Mutex %p, OS Mutex %p\n",
159 object, object->mutex.semaphore)); 159 object, object->mutex.os_mutex));
160 160
161 acpi_ex_unlink_mutex(object); 161 if (object->mutex.os_mutex != ACPI_GLOBAL_LOCK) {
162 (void)acpi_os_delete_semaphore(object->mutex.semaphore); 162 acpi_ex_unlink_mutex(object);
163 acpi_os_delete_mutex(object->mutex.os_mutex);
164 } else {
165 /* Global Lock "mutex" is actually a counting semaphore */
166
167 (void)
168 acpi_os_delete_semaphore
169 (acpi_gbl_global_lock_semaphore);
170 acpi_gbl_global_lock_semaphore = NULL;
171 }
163 break; 172 break;
164 173
165 case ACPI_TYPE_EVENT: 174 case ACPI_TYPE_EVENT:
166 175
167 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 176 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
168 "***** Event %p, Semaphore %p\n", 177 "***** Event %p, OS Semaphore %p\n",
169 object, object->event.semaphore)); 178 object, object->event.os_semaphore));
170 179
171 (void)acpi_os_delete_semaphore(object->event.semaphore); 180 (void)acpi_os_delete_semaphore(object->event.os_semaphore);
172 object->event.semaphore = NULL; 181 object->event.os_semaphore = NULL;
173 break; 182 break;
174 183
175 case ACPI_TYPE_METHOD: 184 case ACPI_TYPE_METHOD:
@@ -177,12 +186,13 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
177 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 186 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
178 "***** Method %p\n", object)); 187 "***** Method %p\n", object));
179 188
180 /* Delete the method semaphore if it exists */ 189 /* Delete the method mutex if it exists */
181 190
182 if (object->method.semaphore) { 191 if (object->method.mutex) {
183 (void)acpi_os_delete_semaphore(object->method. 192 acpi_os_delete_mutex(object->method.mutex->mutex.
184 semaphore); 193 os_mutex);
185 object->method.semaphore = NULL; 194 acpi_ut_delete_object_desc(object->method.mutex);
195 object->method.mutex = NULL;
186 } 196 }
187 break; 197 break;
188 198
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index e5999c65c0b8..014030af8b50 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -794,6 +794,7 @@ void acpi_ut_init_globals(void)
794 794
795 /* Global Lock support */ 795 /* Global Lock support */
796 796
797 acpi_gbl_global_lock_semaphore = NULL;
797 acpi_gbl_global_lock_acquired = FALSE; 798 acpi_gbl_global_lock_acquired = FALSE;
798 acpi_gbl_global_lock_thread_count = 0; 799 acpi_gbl_global_lock_thread_count = 0;
799 acpi_gbl_global_lock_handle = 0; 800 acpi_gbl_global_lock_handle = 0;
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 5c75d35ad1cd..33268310c738 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -41,6 +41,8 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/module.h>
45
44#include <acpi/acpi.h> 46#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
46 48
@@ -962,6 +964,7 @@ acpi_ut_exception(char *module_name,
962 acpi_os_vprintf(format, args); 964 acpi_os_vprintf(format, args);
963 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); 965 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
964} 966}
967EXPORT_SYMBOL(acpi_ut_exception);
965 968
966void ACPI_INTERNAL_VAR_XFACE 969void ACPI_INTERNAL_VAR_XFACE
967acpi_ut_warning(char *module_name, u32 line_number, char *format, ...) 970acpi_ut_warning(char *module_name, u32 line_number, char *format, ...)
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index 25eb34369afa..dfc8f30ca892 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -82,12 +82,9 @@ acpi_status acpi_ut_mutex_initialize(void)
82 82
83 /* Create the spinlocks for use at interrupt level */ 83 /* Create the spinlocks for use at interrupt level */
84 84
85 status = acpi_os_create_lock(&acpi_gbl_gpe_lock); 85 spin_lock_init(acpi_gbl_gpe_lock);
86 if (ACPI_FAILURE(status)) { 86 spin_lock_init(acpi_gbl_hardware_lock);
87 return_ACPI_STATUS(status);
88 }
89 87
90 status = acpi_os_create_lock(&acpi_gbl_hardware_lock);
91 return_ACPI_STATUS(status); 88 return_ACPI_STATUS(status);
92} 89}
93 90
@@ -146,9 +143,8 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146 } 143 }
147 144
148 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 145 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
149 status = acpi_os_create_semaphore(1, 1, 146 status =
150 &acpi_gbl_mutex_info 147 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);
151 [mutex_id].mutex);
152 acpi_gbl_mutex_info[mutex_id].thread_id = 148 acpi_gbl_mutex_info[mutex_id].thread_id =
153 ACPI_MUTEX_NOT_ACQUIRED; 149 ACPI_MUTEX_NOT_ACQUIRED;
154 acpi_gbl_mutex_info[mutex_id].use_count = 0; 150 acpi_gbl_mutex_info[mutex_id].use_count = 0;
@@ -171,7 +167,6 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
171 167
172static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) 168static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
173{ 169{
174 acpi_status status;
175 170
176 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id); 171 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);
177 172
@@ -179,12 +174,12 @@ static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
179 return_ACPI_STATUS(AE_BAD_PARAMETER); 174 return_ACPI_STATUS(AE_BAD_PARAMETER);
180 } 175 }
181 176
182 status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex); 177 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
183 178
184 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 179 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
185 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 180 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
186 181
187 return_ACPI_STATUS(status); 182 return_ACPI_STATUS(AE_OK);
188} 183}
189 184
190/******************************************************************************* 185/*******************************************************************************
@@ -251,8 +246,8 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
251 "Thread %X attempting to acquire Mutex [%s]\n", 246 "Thread %X attempting to acquire Mutex [%s]\n",
252 this_thread_id, acpi_ut_get_mutex_name(mutex_id))); 247 this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
253 248
254 status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 249 status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
255 1, ACPI_WAIT_FOREVER); 250 ACPI_WAIT_FOREVER);
256 if (ACPI_SUCCESS(status)) { 251 if (ACPI_SUCCESS(status)) {
257 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 252 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
258 "Thread %X acquired Mutex [%s]\n", 253 "Thread %X acquired Mutex [%s]\n",
@@ -284,7 +279,6 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
284 279
285acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) 280acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
286{ 281{
287 acpi_status status;
288 acpi_thread_id this_thread_id; 282 acpi_thread_id this_thread_id;
289 283
290 ACPI_FUNCTION_NAME(ut_release_mutex); 284 ACPI_FUNCTION_NAME(ut_release_mutex);
@@ -340,19 +334,6 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
340 334
341 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 335 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
342 336
343 status = 337 acpi_os_release_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
344 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); 338 return (AE_OK);
345
346 if (ACPI_FAILURE(status)) {
347 ACPI_EXCEPTION((AE_INFO, status,
348 "Thread %X could not release Mutex [%X]",
349 this_thread_id, mutex_id));
350 } else {
351 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
352 "Thread %X released Mutex [%s]\n",
353 this_thread_id,
354 acpi_ut_get_mutex_name(mutex_id)));
355 }
356
357 return (status);
358} 339}
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 6b516852ac12..1930e1a75b22 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -58,31 +58,29 @@ acpi_extract_package(union acpi_object *package,
58 u8 *head = NULL; 58 u8 *head = NULL;
59 u8 *tail = NULL; 59 u8 *tail = NULL;
60 60
61 ACPI_FUNCTION_TRACE("acpi_extract_package");
62 61
63 if (!package || (package->type != ACPI_TYPE_PACKAGE) 62 if (!package || (package->type != ACPI_TYPE_PACKAGE)
64 || (package->package.count < 1)) { 63 || (package->package.count < 1)) {
65 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 64 printk(KERN_WARNING PREFIX "Invalid package argument\n");
66 "Invalid 'package' argument\n")); 65 return AE_BAD_PARAMETER;
67 return_ACPI_STATUS(AE_BAD_PARAMETER);
68 } 66 }
69 67
70 if (!format || !format->pointer || (format->length < 1)) { 68 if (!format || !format->pointer || (format->length < 1)) {
71 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); 69 printk(KERN_WARNING PREFIX "Invalid format argument\n");
72 return_ACPI_STATUS(AE_BAD_PARAMETER); 70 return AE_BAD_PARAMETER;
73 } 71 }
74 72
75 if (!buffer) { 73 if (!buffer) {
76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); 74 printk(KERN_WARNING PREFIX "Invalid buffer argument\n");
77 return_ACPI_STATUS(AE_BAD_PARAMETER); 75 return AE_BAD_PARAMETER;
78 } 76 }
79 77
80 format_count = (format->length / sizeof(char)) - 1; 78 format_count = (format->length / sizeof(char)) - 1;
81 if (format_count > package->package.count) { 79 if (format_count > package->package.count) {
82 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 80 printk(KERN_WARNING PREFIX "Format specifies more objects [%d]"
83 "Format specifies more objects [%d] than exist in package [%d].", 81 " than exist in package [%d].\n",
84 format_count, package->package.count)); 82 format_count, package->package.count);
85 return_ACPI_STATUS(AE_BAD_DATA); 83 return AE_BAD_DATA;
86 } 84 }
87 85
88 format_string = (char *)format->pointer; 86 format_string = (char *)format->pointer;
@@ -95,7 +93,7 @@ acpi_extract_package(union acpi_object *package,
95 union acpi_object *element = &(package->package.elements[i]); 93 union acpi_object *element = &(package->package.elements[i]);
96 94
97 if (!element) { 95 if (!element) {
98 return_ACPI_STATUS(AE_BAD_DATA); 96 return AE_BAD_DATA;
99 } 97 }
100 98
101 switch (element->type) { 99 switch (element->type) {
@@ -113,10 +111,11 @@ acpi_extract_package(union acpi_object *package,
113 tail_offset += sizeof(char *); 111 tail_offset += sizeof(char *);
114 break; 112 break;
115 default: 113 default:
116 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 114 printk(KERN_WARNING PREFIX "Invalid package element"
117 "Invalid package element [%d]: got number, expecing [%c].\n", 115 " [%d]: got number, expecing"
118 i, format_string[i])); 116 " [%c]\n",
119 return_ACPI_STATUS(AE_BAD_DATA); 117 i, format_string[i]);
118 return AE_BAD_DATA;
120 break; 119 break;
121 } 120 }
122 break; 121 break;
@@ -138,10 +137,11 @@ acpi_extract_package(union acpi_object *package,
138 tail_offset += sizeof(u8 *); 137 tail_offset += sizeof(u8 *);
139 break; 138 break;
140 default: 139 default:
141 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 140 printk(KERN_WARNING PREFIX "Invalid package element"
142 "Invalid package element [%d] got string/buffer, expecing [%c].\n", 141 " [%d] got string/buffer,"
143 i, format_string[i])); 142 " expecing [%c]\n",
144 return_ACPI_STATUS(AE_BAD_DATA); 143 i, format_string[i]);
144 return AE_BAD_DATA;
145 break; 145 break;
146 } 146 }
147 break; 147 break;
@@ -152,7 +152,7 @@ acpi_extract_package(union acpi_object *package,
152 "Found unsupported element at index=%d\n", 152 "Found unsupported element at index=%d\n",
153 i)); 153 i));
154 /* TBD: handle nested packages... */ 154 /* TBD: handle nested packages... */
155 return_ACPI_STATUS(AE_SUPPORT); 155 return AE_SUPPORT;
156 break; 156 break;
157 } 157 }
158 } 158 }
@@ -162,9 +162,9 @@ acpi_extract_package(union acpi_object *package,
162 */ 162 */
163 if (buffer->length < size_required) { 163 if (buffer->length < size_required) {
164 buffer->length = size_required; 164 buffer->length = size_required;
165 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 165 return AE_BUFFER_OVERFLOW;
166 } else if (buffer->length != size_required || !buffer->pointer) { 166 } else if (buffer->length != size_required || !buffer->pointer) {
167 return_ACPI_STATUS(AE_BAD_PARAMETER); 167 return AE_BAD_PARAMETER;
168 } 168 }
169 169
170 head = buffer->pointer; 170 head = buffer->pointer;
@@ -179,7 +179,7 @@ acpi_extract_package(union acpi_object *package,
179 union acpi_object *element = &(package->package.elements[i]); 179 union acpi_object *element = &(package->package.elements[i]);
180 180
181 if (!element) { 181 if (!element) {
182 return_ACPI_STATUS(AE_BAD_DATA); 182 return AE_BAD_DATA;
183 } 183 }
184 184
185 switch (element->type) { 185 switch (element->type) {
@@ -244,7 +244,7 @@ acpi_extract_package(union acpi_object *package,
244 } 244 }
245 } 245 }
246 246
247 return_ACPI_STATUS(AE_OK); 247 return AE_OK;
248} 248}
249 249
250EXPORT_SYMBOL(acpi_extract_package); 250EXPORT_SYMBOL(acpi_extract_package);
@@ -258,14 +258,13 @@ acpi_evaluate_integer(acpi_handle handle,
258 union acpi_object *element; 258 union acpi_object *element;
259 struct acpi_buffer buffer = { 0, NULL }; 259 struct acpi_buffer buffer = { 0, NULL };
260 260
261 ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
262 261
263 if (!data) 262 if (!data)
264 return_ACPI_STATUS(AE_BAD_PARAMETER); 263 return AE_BAD_PARAMETER;
265 264
266 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 265 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
267 if (!element) 266 if (!element)
268 return_ACPI_STATUS(AE_NO_MEMORY); 267 return AE_NO_MEMORY;
269 268
270 memset(element, 0, sizeof(union acpi_object)); 269 memset(element, 0, sizeof(union acpi_object));
271 buffer.length = sizeof(union acpi_object); 270 buffer.length = sizeof(union acpi_object);
@@ -274,13 +273,13 @@ acpi_evaluate_integer(acpi_handle handle,
274 if (ACPI_FAILURE(status)) { 273 if (ACPI_FAILURE(status)) {
275 acpi_util_eval_error(handle, pathname, status); 274 acpi_util_eval_error(handle, pathname, status);
276 kfree(element); 275 kfree(element);
277 return_ACPI_STATUS(status); 276 return status;
278 } 277 }
279 278
280 if (element->type != ACPI_TYPE_INTEGER) { 279 if (element->type != ACPI_TYPE_INTEGER) {
281 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 280 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
282 kfree(element); 281 kfree(element);
283 return_ACPI_STATUS(AE_BAD_DATA); 282 return AE_BAD_DATA;
284 } 283 }
285 284
286 *data = element->integer.value; 285 *data = element->integer.value;
@@ -288,7 +287,7 @@ acpi_evaluate_integer(acpi_handle handle,
288 287
289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); 288 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
290 289
291 return_ACPI_STATUS(AE_OK); 290 return AE_OK;
292} 291}
293 292
294EXPORT_SYMBOL(acpi_evaluate_integer); 293EXPORT_SYMBOL(acpi_evaluate_integer);
@@ -303,15 +302,14 @@ acpi_evaluate_string(acpi_handle handle,
303 acpi_object *element = NULL; 302 acpi_object *element = NULL;
304 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 303 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
305 304
306 ACPI_FUNCTION_TRACE("acpi_evaluate_string");
307 305
308 if (!data) 306 if (!data)
309 return_ACPI_STATUS(AE_BAD_PARAMETER); 307 return AE_BAD_PARAMETER;
310 308
311 status = acpi_evaluate_object(handle, pathname, arguments, &buffer); 309 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
312 if (ACPI_FAILURE(status)) { 310 if (ACPI_FAILURE(status)) {
313 acpi_util_eval_error(handle, pathname, status); 311 acpi_util_eval_error(handle, pathname, status);
314 return_ACPI_STATUS(status); 312 return status;
315 } 313 }
316 314
317 element = (acpi_object *) buffer.pointer; 315 element = (acpi_object *) buffer.pointer;
@@ -320,13 +318,13 @@ acpi_evaluate_string(acpi_handle handle,
320 || (element->type != ACPI_TYPE_BUFFER) 318 || (element->type != ACPI_TYPE_BUFFER)
321 || !element->string.length) { 319 || !element->string.length) {
322 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 320 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
323 return_ACPI_STATUS(AE_BAD_DATA); 321 return AE_BAD_DATA;
324 } 322 }
325 323
326 *data = kmalloc(element->string.length + 1, GFP_KERNEL); 324 *data = kmalloc(element->string.length + 1, GFP_KERNEL);
327 if (!data) { 325 if (!data) {
328 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); 326 printk(KERN_ERR PREFIX "Memory allocation\n");
329 return_VALUE(-ENOMEM); 327 return -ENOMEM;
330 } 328 }
331 memset(*data, 0, element->string.length + 1); 329 memset(*data, 0, element->string.length + 1);
332 330
@@ -336,7 +334,7 @@ acpi_evaluate_string(acpi_handle handle,
336 334
337 acpi_os_free(buffer.pointer); 335 acpi_os_free(buffer.pointer);
338 336
339 return_ACPI_STATUS(AE_OK); 337 return AE_OK;
340} 338}
341#endif 339#endif
342 340
@@ -352,10 +350,9 @@ acpi_evaluate_reference(acpi_handle handle,
352 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 350 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
353 u32 i = 0; 351 u32 i = 0;
354 352
355 ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
356 353
357 if (!list) { 354 if (!list) {
358 return_ACPI_STATUS(AE_BAD_PARAMETER); 355 return AE_BAD_PARAMETER;
359 } 356 }
360 357
361 /* Evaluate object. */ 358 /* Evaluate object. */
@@ -367,32 +364,29 @@ acpi_evaluate_reference(acpi_handle handle,
367 package = (union acpi_object *)buffer.pointer; 364 package = (union acpi_object *)buffer.pointer;
368 365
369 if ((buffer.length == 0) || !package) { 366 if ((buffer.length == 0) || !package) {
370 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 367 printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n",
371 "No return object (len %X ptr %p)\n", 368 (unsigned)buffer.length, package);
372 (unsigned)buffer.length, package));
373 status = AE_BAD_DATA; 369 status = AE_BAD_DATA;
374 acpi_util_eval_error(handle, pathname, status); 370 acpi_util_eval_error(handle, pathname, status);
375 goto end; 371 goto end;
376 } 372 }
377 if (package->type != ACPI_TYPE_PACKAGE) { 373 if (package->type != ACPI_TYPE_PACKAGE) {
378 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 374 printk(KERN_ERR PREFIX "Expecting a [Package], found type %X\n",
379 "Expecting a [Package], found type %X\n", 375 package->type);
380 package->type));
381 status = AE_BAD_DATA; 376 status = AE_BAD_DATA;
382 acpi_util_eval_error(handle, pathname, status); 377 acpi_util_eval_error(handle, pathname, status);
383 goto end; 378 goto end;
384 } 379 }
385 if (!package->package.count) { 380 if (!package->package.count) {
386 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 381 printk(KERN_ERR PREFIX "[Package] has zero elements (%p)\n",
387 "[Package] has zero elements (%p)\n", 382 package);
388 package));
389 status = AE_BAD_DATA; 383 status = AE_BAD_DATA;
390 acpi_util_eval_error(handle, pathname, status); 384 acpi_util_eval_error(handle, pathname, status);
391 goto end; 385 goto end;
392 } 386 }
393 387
394 if (package->package.count > ACPI_MAX_HANDLES) { 388 if (package->package.count > ACPI_MAX_HANDLES) {
395 return_ACPI_STATUS(AE_NO_MEMORY); 389 return AE_NO_MEMORY;
396 } 390 }
397 list->count = package->package.count; 391 list->count = package->package.count;
398 392
@@ -404,9 +398,9 @@ acpi_evaluate_reference(acpi_handle handle,
404 398
405 if (element->type != ACPI_TYPE_ANY) { 399 if (element->type != ACPI_TYPE_ANY) {
406 status = AE_BAD_DATA; 400 status = AE_BAD_DATA;
407 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 401 printk(KERN_ERR PREFIX
408 "Expecting a [Reference] package element, found type %X\n", 402 "Expecting a [Reference] package element, found type %X\n",
409 element->type)); 403 element->type);
410 acpi_util_eval_error(handle, pathname, status); 404 acpi_util_eval_error(handle, pathname, status);
411 break; 405 break;
412 } 406 }
@@ -426,7 +420,7 @@ acpi_evaluate_reference(acpi_handle handle,
426 420
427 acpi_os_free(buffer.pointer); 421 acpi_os_free(buffer.pointer);
428 422
429 return_ACPI_STATUS(status); 423 return status;
430} 424}
431 425
432EXPORT_SYMBOL(acpi_evaluate_reference); 426EXPORT_SYMBOL(acpi_evaluate_reference);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index e7e9a693953a..9feb633087a9 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -272,10 +272,9 @@ static int
272acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) 272acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
273{ 273{
274 int status; 274 int status;
275 ACPI_FUNCTION_TRACE("acpi_video_device_query");
276 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state); 275 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
277 276
278 return_VALUE(status); 277 return status;
279} 278}
280 279
281static int 280static int
@@ -284,11 +283,10 @@ acpi_video_device_get_state(struct acpi_video_device *device,
284{ 283{
285 int status; 284 int status;
286 285
287 ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
288 286
289 status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state); 287 status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
290 288
291 return_VALUE(status); 289 return status;
292} 290}
293 291
294static int 292static int
@@ -299,12 +297,11 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state)
299 struct acpi_object_list args = { 1, &arg0 }; 297 struct acpi_object_list args = { 1, &arg0 };
300 unsigned long ret; 298 unsigned long ret;
301 299
302 ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
303 300
304 arg0.integer.value = state; 301 arg0.integer.value = state;
305 status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret); 302 status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret);
306 303
307 return_VALUE(status); 304 return status;
308} 305}
309 306
310static int 307static int
@@ -315,28 +312,27 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
315 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 312 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
316 union acpi_object *obj; 313 union acpi_object *obj;
317 314
318 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
319 315
320 *levels = NULL; 316 *levels = NULL;
321 317
322 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); 318 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
323 if (!ACPI_SUCCESS(status)) 319 if (!ACPI_SUCCESS(status))
324 return_VALUE(status); 320 return status;
325 obj = (union acpi_object *)buffer.pointer; 321 obj = (union acpi_object *)buffer.pointer;
326 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { 322 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
327 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n")); 323 printk(KERN_ERR PREFIX "Invalid _BCL data\n");
328 status = -EFAULT; 324 status = -EFAULT;
329 goto err; 325 goto err;
330 } 326 }
331 327
332 *levels = obj; 328 *levels = obj;
333 329
334 return_VALUE(0); 330 return 0;
335 331
336 err: 332 err:
337 kfree(buffer.pointer); 333 kfree(buffer.pointer);
338 334
339 return_VALUE(status); 335 return status;
340} 336}
341 337
342static int 338static int
@@ -346,13 +342,12 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
346 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 342 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
347 struct acpi_object_list args = { 1, &arg0 }; 343 struct acpi_object_list args = { 1, &arg0 };
348 344
349 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
350 345
351 arg0.integer.value = level; 346 arg0.integer.value = level;
352 status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL); 347 status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
353 348
354 printk(KERN_DEBUG "set_level status: %x\n", status); 349 printk(KERN_DEBUG "set_level status: %x\n", status);
355 return_VALUE(status); 350 return status;
356} 351}
357 352
358static int 353static int
@@ -360,11 +355,10 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
360 unsigned long *level) 355 unsigned long *level)
361{ 356{
362 int status; 357 int status;
363 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
364 358
365 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); 359 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
366 360
367 return_VALUE(status); 361 return status;
368} 362}
369 363
370static int 364static int
@@ -377,34 +371,33 @@ acpi_video_device_EDID(struct acpi_video_device *device,
377 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 371 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
378 struct acpi_object_list args = { 1, &arg0 }; 372 struct acpi_object_list args = { 1, &arg0 };
379 373
380 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
381 374
382 *edid = NULL; 375 *edid = NULL;
383 376
384 if (!device) 377 if (!device)
385 return_VALUE(-ENODEV); 378 return -ENODEV;
386 if (length == 128) 379 if (length == 128)
387 arg0.integer.value = 1; 380 arg0.integer.value = 1;
388 else if (length == 256) 381 else if (length == 256)
389 arg0.integer.value = 2; 382 arg0.integer.value = 2;
390 else 383 else
391 return_VALUE(-EINVAL); 384 return -EINVAL;
392 385
393 status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer); 386 status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
394 if (ACPI_FAILURE(status)) 387 if (ACPI_FAILURE(status))
395 return_VALUE(-ENODEV); 388 return -ENODEV;
396 389
397 obj = (union acpi_object *)buffer.pointer; 390 obj = (union acpi_object *)buffer.pointer;
398 391
399 if (obj && obj->type == ACPI_TYPE_BUFFER) 392 if (obj && obj->type == ACPI_TYPE_BUFFER)
400 *edid = obj; 393 *edid = obj;
401 else { 394 else {
402 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n")); 395 printk(KERN_ERR PREFIX "Invalid _DDC data\n");
403 status = -EFAULT; 396 status = -EFAULT;
404 kfree(obj); 397 kfree(obj);
405 } 398 }
406 399
407 return_VALUE(status); 400 return status;
408} 401}
409 402
410/* bus */ 403/* bus */
@@ -417,7 +410,6 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
417 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 410 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
418 struct acpi_object_list args = { 1, &arg0 }; 411 struct acpi_object_list args = { 1, &arg0 };
419 412
420 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
421 413
422 arg0.integer.value = option; 414 arg0.integer.value = option;
423 415
@@ -425,7 +417,7 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
425 if (ACPI_SUCCESS(status)) 417 if (ACPI_SUCCESS(status))
426 status = tmp ? (-EINVAL) : (AE_OK); 418 status = tmp ? (-EINVAL) : (AE_OK);
427 419
428 return_VALUE(status); 420 return status;
429} 421}
430 422
431static int 423static int
@@ -433,11 +425,10 @@ acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
433{ 425{
434 int status; 426 int status;
435 427
436 ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
437 428
438 status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id); 429 status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
439 430
440 return_VALUE(status); 431 return status;
441} 432}
442 433
443static int 434static int
@@ -445,12 +436,11 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video,
445 unsigned long *options) 436 unsigned long *options)
446{ 437{
447 int status; 438 int status;
448 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
449 439
450 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); 440 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
451 *options &= 3; 441 *options &= 3;
452 442
453 return_VALUE(status); 443 return status;
454} 444}
455 445
456/* 446/*
@@ -481,7 +471,6 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
481 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 471 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
482 struct acpi_object_list args = { 1, &arg0 }; 472 struct acpi_object_list args = { 1, &arg0 };
483 473
484 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
485 474
486 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { 475 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
487 status = -1; 476 status = -1;
@@ -492,7 +481,7 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
492 acpi_evaluate_object(video->handle, "_DOS", &args, NULL); 481 acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
493 482
494 Failed: 483 Failed:
495 return_VALUE(status); 484 return status;
496} 485}
497 486
498/* 487/*
@@ -514,7 +503,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
514 union acpi_object *obj = NULL; 503 union acpi_object *obj = NULL;
515 struct acpi_video_device_brightness *br = NULL; 504 struct acpi_video_device_brightness *br = NULL;
516 505
517 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
518 506
519 memset(&device->cap, 0, 4); 507 memset(&device->cap, 0, 4);
520 508
@@ -560,8 +548,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
560 o = (union acpi_object *)&obj->package. 548 o = (union acpi_object *)&obj->package.
561 elements[i]; 549 elements[i];
562 if (o->type != ACPI_TYPE_INTEGER) { 550 if (o->type != ACPI_TYPE_INTEGER) {
563 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 551 printk(KERN_ERR PREFIX "Invalid data\n");
564 "Invalid data\n"));
565 continue; 552 continue;
566 } 553 }
567 br->levels[count] = (u32) o->integer.value; 554 br->levels[count] = (u32) o->integer.value;
@@ -583,7 +570,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
583 570
584 kfree(obj); 571 kfree(obj);
585 572
586 return_VOID; 573 return;
587} 574}
588 575
589/* 576/*
@@ -630,10 +617,9 @@ static int acpi_video_bus_check(struct acpi_video_bus *video)
630{ 617{
631 acpi_status status = -ENOENT; 618 acpi_status status = -ENOENT;
632 619
633 ACPI_FUNCTION_TRACE("acpi_video_bus_check");
634 620
635 if (!video) 621 if (!video)
636 return_VALUE(-EINVAL); 622 return -EINVAL;
637 623
638 /* Since there is no HID, CID and so on for VGA driver, we have 624 /* Since there is no HID, CID and so on for VGA driver, we have
639 * to check well known required nodes. 625 * to check well known required nodes.
@@ -657,7 +643,7 @@ static int acpi_video_bus_check(struct acpi_video_bus *video)
657 status = 0; 643 status = 0;
658 } 644 }
659 645
660 return_VALUE(status); 646 return status;
661} 647}
662 648
663/* -------------------------------------------------------------------------- 649/* --------------------------------------------------------------------------
@@ -673,7 +659,6 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
673 struct acpi_video_device *dev = 659 struct acpi_video_device *dev =
674 (struct acpi_video_device *)seq->private; 660 (struct acpi_video_device *)seq->private;
675 661
676 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
677 662
678 if (!dev) 663 if (!dev)
679 goto end; 664 goto end;
@@ -692,7 +677,7 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
692 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no"); 677 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
693 678
694 end: 679 end:
695 return_VALUE(0); 680 return 0;
696} 681}
697 682
698static int 683static int
@@ -709,7 +694,6 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
709 (struct acpi_video_device *)seq->private; 694 (struct acpi_video_device *)seq->private;
710 unsigned long state; 695 unsigned long state;
711 696
712 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
713 697
714 if (!dev) 698 if (!dev)
715 goto end; 699 goto end;
@@ -729,7 +713,7 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
729 seq_printf(seq, "<not supported>\n"); 713 seq_printf(seq, "<not supported>\n");
730 714
731 end: 715 end:
732 return_VALUE(0); 716 return 0;
733} 717}
734 718
735static int 719static int
@@ -750,13 +734,12 @@ acpi_video_device_write_state(struct file *file,
750 char str[12] = { 0 }; 734 char str[12] = { 0 };
751 u32 state = 0; 735 u32 state = 0;
752 736
753 ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
754 737
755 if (!dev || count + 1 > sizeof str) 738 if (!dev || count + 1 > sizeof str)
756 return_VALUE(-EINVAL); 739 return -EINVAL;
757 740
758 if (copy_from_user(str, buffer, count)) 741 if (copy_from_user(str, buffer, count))
759 return_VALUE(-EFAULT); 742 return -EFAULT;
760 743
761 str[count] = 0; 744 str[count] = 0;
762 state = simple_strtoul(str, NULL, 0); 745 state = simple_strtoul(str, NULL, 0);
@@ -765,9 +748,9 @@ acpi_video_device_write_state(struct file *file,
765 status = acpi_video_device_set_state(dev, state); 748 status = acpi_video_device_set_state(dev, state);
766 749
767 if (status) 750 if (status)
768 return_VALUE(-EFAULT); 751 return -EFAULT;
769 752
770 return_VALUE(count); 753 return count;
771} 754}
772 755
773static int 756static int
@@ -777,11 +760,10 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
777 (struct acpi_video_device *)seq->private; 760 (struct acpi_video_device *)seq->private;
778 int i; 761 int i;
779 762
780 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
781 763
782 if (!dev || !dev->brightness) { 764 if (!dev || !dev->brightness) {
783 seq_printf(seq, "<not supported>\n"); 765 seq_printf(seq, "<not supported>\n");
784 return_VALUE(0); 766 return 0;
785 } 767 }
786 768
787 seq_printf(seq, "levels: "); 769 seq_printf(seq, "levels: ");
@@ -789,7 +771,7 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
789 seq_printf(seq, " %d", dev->brightness->levels[i]); 771 seq_printf(seq, " %d", dev->brightness->levels[i]);
790 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); 772 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
791 773
792 return_VALUE(0); 774 return 0;
793} 775}
794 776
795static int 777static int
@@ -810,19 +792,18 @@ acpi_video_device_write_brightness(struct file *file,
810 unsigned int level = 0; 792 unsigned int level = 0;
811 int i; 793 int i;
812 794
813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
814 795
815 if (!dev || !dev->brightness || count + 1 > sizeof str) 796 if (!dev || !dev->brightness || count + 1 > sizeof str)
816 return_VALUE(-EINVAL); 797 return -EINVAL;
817 798
818 if (copy_from_user(str, buffer, count)) 799 if (copy_from_user(str, buffer, count))
819 return_VALUE(-EFAULT); 800 return -EFAULT;
820 801
821 str[count] = 0; 802 str[count] = 0;
822 level = simple_strtoul(str, NULL, 0); 803 level = simple_strtoul(str, NULL, 0);
823 804
824 if (level > 100) 805 if (level > 100)
825 return_VALUE(-EFAULT); 806 return -EFAULT;
826 807
827 /* validate though the list of available levels */ 808 /* validate though the list of available levels */
828 for (i = 0; i < dev->brightness->count; i++) 809 for (i = 0; i < dev->brightness->count; i++)
@@ -833,7 +814,7 @@ acpi_video_device_write_brightness(struct file *file,
833 break; 814 break;
834 } 815 }
835 816
836 return_VALUE(count); 817 return count;
837} 818}
838 819
839static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) 820static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
@@ -844,7 +825,6 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
844 int i; 825 int i;
845 union acpi_object *edid = NULL; 826 union acpi_object *edid = NULL;
846 827
847 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
848 828
849 if (!dev) 829 if (!dev)
850 goto out; 830 goto out;
@@ -869,7 +849,7 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
869 else 849 else
870 kfree(edid); 850 kfree(edid);
871 851
872 return_VALUE(0); 852 return 0;
873} 853}
874 854
875static int 855static int
@@ -884,28 +864,26 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
884 struct proc_dir_entry *entry = NULL; 864 struct proc_dir_entry *entry = NULL;
885 struct acpi_video_device *vid_dev; 865 struct acpi_video_device *vid_dev;
886 866
887 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
888 867
889 if (!device) 868 if (!device)
890 return_VALUE(-ENODEV); 869 return -ENODEV;
891 870
892 vid_dev = (struct acpi_video_device *)acpi_driver_data(device); 871 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
893 if (!vid_dev) 872 if (!vid_dev)
894 return_VALUE(-ENODEV); 873 return -ENODEV;
895 874
896 if (!acpi_device_dir(device)) { 875 if (!acpi_device_dir(device)) {
897 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 876 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
898 vid_dev->video->dir); 877 vid_dev->video->dir);
899 if (!acpi_device_dir(device)) 878 if (!acpi_device_dir(device))
900 return_VALUE(-ENODEV); 879 return -ENODEV;
901 acpi_device_dir(device)->owner = THIS_MODULE; 880 acpi_device_dir(device)->owner = THIS_MODULE;
902 } 881 }
903 882
904 /* 'info' [R] */ 883 /* 'info' [R] */
905 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 884 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
906 if (!entry) 885 if (!entry)
907 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 886 return -ENODEV;
908 "Unable to create 'info' fs entry\n"));
909 else { 887 else {
910 entry->proc_fops = &acpi_video_device_info_fops; 888 entry->proc_fops = &acpi_video_device_info_fops;
911 entry->data = acpi_driver_data(device); 889 entry->data = acpi_driver_data(device);
@@ -917,8 +895,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
917 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, 895 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
918 acpi_device_dir(device)); 896 acpi_device_dir(device));
919 if (!entry) 897 if (!entry)
920 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 898 return -ENODEV;
921 "Unable to create 'state' fs entry\n"));
922 else { 899 else {
923 acpi_video_device_state_fops.write = acpi_video_device_write_state; 900 acpi_video_device_state_fops.write = acpi_video_device_write_state;
924 entry->proc_fops = &acpi_video_device_state_fops; 901 entry->proc_fops = &acpi_video_device_state_fops;
@@ -931,8 +908,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
931 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, 908 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
932 acpi_device_dir(device)); 909 acpi_device_dir(device));
933 if (!entry) 910 if (!entry)
934 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 911 return -ENODEV;
935 "Unable to create 'brightness' fs entry\n"));
936 else { 912 else {
937 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness; 913 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
938 entry->proc_fops = &acpi_video_device_brightness_fops; 914 entry->proc_fops = &acpi_video_device_brightness_fops;
@@ -943,25 +919,23 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
943 /* 'EDID' [R] */ 919 /* 'EDID' [R] */
944 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); 920 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
945 if (!entry) 921 if (!entry)
946 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 922 return -ENODEV;
947 "Unable to create 'brightness' fs entry\n"));
948 else { 923 else {
949 entry->proc_fops = &acpi_video_device_EDID_fops; 924 entry->proc_fops = &acpi_video_device_EDID_fops;
950 entry->data = acpi_driver_data(device); 925 entry->data = acpi_driver_data(device);
951 entry->owner = THIS_MODULE; 926 entry->owner = THIS_MODULE;
952 } 927 }
953 928
954 return_VALUE(0); 929 return 0;
955} 930}
956 931
957static int acpi_video_device_remove_fs(struct acpi_device *device) 932static int acpi_video_device_remove_fs(struct acpi_device *device)
958{ 933{
959 struct acpi_video_device *vid_dev; 934 struct acpi_video_device *vid_dev;
960 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
961 935
962 vid_dev = (struct acpi_video_device *)acpi_driver_data(device); 936 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
963 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) 937 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
964 return_VALUE(-ENODEV); 938 return -ENODEV;
965 939
966 if (acpi_device_dir(device)) { 940 if (acpi_device_dir(device)) {
967 remove_proc_entry("info", acpi_device_dir(device)); 941 remove_proc_entry("info", acpi_device_dir(device));
@@ -972,7 +946,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device)
972 acpi_device_dir(device) = NULL; 946 acpi_device_dir(device) = NULL;
973 } 947 }
974 948
975 return_VALUE(0); 949 return 0;
976} 950}
977 951
978/* video bus */ 952/* video bus */
@@ -980,7 +954,6 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
980{ 954{
981 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 955 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
982 956
983 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
984 957
985 if (!video) 958 if (!video)
986 goto end; 959 goto end;
@@ -993,7 +966,7 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
993 video->flags.post ? "yes" : "no"); 966 video->flags.post ? "yes" : "no");
994 967
995 end: 968 end:
996 return_VALUE(0); 969 return 0;
997} 970}
998 971
999static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file) 972static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
@@ -1006,7 +979,6 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1006{ 979{
1007 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 980 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1008 981
1009 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
1010 982
1011 if (!video) 983 if (!video)
1012 goto end; 984 goto end;
@@ -1015,7 +987,7 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1015 seq_printf(seq, "<TODO>\n"); 987 seq_printf(seq, "<TODO>\n");
1016 988
1017 end: 989 end:
1018 return_VALUE(0); 990 return 0;
1019} 991}
1020 992
1021static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file) 993static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
@@ -1029,7 +1001,6 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1029 unsigned long options; 1001 unsigned long options;
1030 int status; 1002 int status;
1031 1003
1032 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
1033 1004
1034 if (!video) 1005 if (!video)
1035 goto end; 1006 goto end;
@@ -1052,7 +1023,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1052 } else 1023 } else
1053 seq_printf(seq, "<not supported>\n"); 1024 seq_printf(seq, "<not supported>\n");
1054 end: 1025 end:
1055 return_VALUE(0); 1026 return 0;
1056} 1027}
1057 1028
1058static int 1029static int
@@ -1068,7 +1039,6 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1068 int status; 1039 int status;
1069 unsigned long id; 1040 unsigned long id;
1070 1041
1071 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
1072 1042
1073 if (!video) 1043 if (!video)
1074 goto end; 1044 goto end;
@@ -1081,18 +1051,17 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1081 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); 1051 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
1082 1052
1083 end: 1053 end:
1084 return_VALUE(0); 1054 return 0;
1085} 1055}
1086 1056
1087static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) 1057static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1088{ 1058{
1089 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 1059 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1090 1060
1091 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
1092 1061
1093 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); 1062 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1094 1063
1095 return_VALUE(0); 1064 return 0;
1096} 1065}
1097 1066
1098static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file) 1067static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
@@ -1117,22 +1086,21 @@ acpi_video_bus_write_POST(struct file *file,
1117 char str[12] = { 0 }; 1086 char str[12] = { 0 };
1118 unsigned long opt, options; 1087 unsigned long opt, options;
1119 1088
1120 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
1121 1089
1122 if (!video || count + 1 > sizeof str) 1090 if (!video || count + 1 > sizeof str)
1123 return_VALUE(-EINVAL); 1091 return -EINVAL;
1124 1092
1125 status = acpi_video_bus_POST_options(video, &options); 1093 status = acpi_video_bus_POST_options(video, &options);
1126 if (!ACPI_SUCCESS(status)) 1094 if (!ACPI_SUCCESS(status))
1127 return_VALUE(-EINVAL); 1095 return -EINVAL;
1128 1096
1129 if (copy_from_user(str, buffer, count)) 1097 if (copy_from_user(str, buffer, count))
1130 return_VALUE(-EFAULT); 1098 return -EFAULT;
1131 1099
1132 str[count] = 0; 1100 str[count] = 0;
1133 opt = strtoul(str, NULL, 0); 1101 opt = strtoul(str, NULL, 0);
1134 if (opt > 3) 1102 if (opt > 3)
1135 return_VALUE(-EFAULT); 1103 return -EFAULT;
1136 1104
1137 /* just in case an OEM 'forget' the motherboard... */ 1105 /* just in case an OEM 'forget' the motherboard... */
1138 options |= 1; 1106 options |= 1;
@@ -1140,11 +1108,11 @@ acpi_video_bus_write_POST(struct file *file,
1140 if (options & (1ul << opt)) { 1108 if (options & (1ul << opt)) {
1141 status = acpi_video_bus_set_POST(video, opt); 1109 status = acpi_video_bus_set_POST(video, opt);
1142 if (!ACPI_SUCCESS(status)) 1110 if (!ACPI_SUCCESS(status))
1143 return_VALUE(-EFAULT); 1111 return -EFAULT;
1144 1112
1145 } 1113 }
1146 1114
1147 return_VALUE(count); 1115 return count;
1148} 1116}
1149 1117
1150static ssize_t 1118static ssize_t
@@ -1158,25 +1126,24 @@ acpi_video_bus_write_DOS(struct file *file,
1158 char str[12] = { 0 }; 1126 char str[12] = { 0 };
1159 unsigned long opt; 1127 unsigned long opt;
1160 1128
1161 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
1162 1129
1163 if (!video || count + 1 > sizeof str) 1130 if (!video || count + 1 > sizeof str)
1164 return_VALUE(-EINVAL); 1131 return -EINVAL;
1165 1132
1166 if (copy_from_user(str, buffer, count)) 1133 if (copy_from_user(str, buffer, count))
1167 return_VALUE(-EFAULT); 1134 return -EFAULT;
1168 1135
1169 str[count] = 0; 1136 str[count] = 0;
1170 opt = strtoul(str, NULL, 0); 1137 opt = strtoul(str, NULL, 0);
1171 if (opt > 7) 1138 if (opt > 7)
1172 return_VALUE(-EFAULT); 1139 return -EFAULT;
1173 1140
1174 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2); 1141 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1175 1142
1176 if (!ACPI_SUCCESS(status)) 1143 if (!ACPI_SUCCESS(status))
1177 return_VALUE(-EFAULT); 1144 return -EFAULT;
1178 1145
1179 return_VALUE(count); 1146 return count;
1180} 1147}
1181 1148
1182static int acpi_video_bus_add_fs(struct acpi_device *device) 1149static int acpi_video_bus_add_fs(struct acpi_device *device)
@@ -1184,7 +1151,6 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1184 struct proc_dir_entry *entry = NULL; 1151 struct proc_dir_entry *entry = NULL;
1185 struct acpi_video_bus *video; 1152 struct acpi_video_bus *video;
1186 1153
1187 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
1188 1154
1189 video = (struct acpi_video_bus *)acpi_driver_data(device); 1155 video = (struct acpi_video_bus *)acpi_driver_data(device);
1190 1156
@@ -1192,7 +1158,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1192 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1158 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1193 acpi_video_dir); 1159 acpi_video_dir);
1194 if (!acpi_device_dir(device)) 1160 if (!acpi_device_dir(device))
1195 return_VALUE(-ENODEV); 1161 return -ENODEV;
1196 video->dir = acpi_device_dir(device); 1162 video->dir = acpi_device_dir(device);
1197 acpi_device_dir(device)->owner = THIS_MODULE; 1163 acpi_device_dir(device)->owner = THIS_MODULE;
1198 } 1164 }
@@ -1200,8 +1166,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1200 /* 'info' [R] */ 1166 /* 'info' [R] */
1201 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 1167 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1202 if (!entry) 1168 if (!entry)
1203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1169 return -ENODEV;
1204 "Unable to create 'info' fs entry\n"));
1205 else { 1170 else {
1206 entry->proc_fops = &acpi_video_bus_info_fops; 1171 entry->proc_fops = &acpi_video_bus_info_fops;
1207 entry->data = acpi_driver_data(device); 1172 entry->data = acpi_driver_data(device);
@@ -1211,8 +1176,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1211 /* 'ROM' [R] */ 1176 /* 'ROM' [R] */
1212 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); 1177 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1213 if (!entry) 1178 if (!entry)
1214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1179 return -ENODEV;
1215 "Unable to create 'ROM' fs entry\n"));
1216 else { 1180 else {
1217 entry->proc_fops = &acpi_video_bus_ROM_fops; 1181 entry->proc_fops = &acpi_video_bus_ROM_fops;
1218 entry->data = acpi_driver_data(device); 1182 entry->data = acpi_driver_data(device);
@@ -1223,8 +1187,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1223 entry = 1187 entry =
1224 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); 1188 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1225 if (!entry) 1189 if (!entry)
1226 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1190 return -ENODEV;
1227 "Unable to create 'POST_info' fs entry\n"));
1228 else { 1191 else {
1229 entry->proc_fops = &acpi_video_bus_POST_info_fops; 1192 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1230 entry->data = acpi_driver_data(device); 1193 entry->data = acpi_driver_data(device);
@@ -1236,8 +1199,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1236 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, 1199 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
1237 acpi_device_dir(device)); 1200 acpi_device_dir(device));
1238 if (!entry) 1201 if (!entry)
1239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1202 return -ENODEV;
1240 "Unable to create 'POST' fs entry\n"));
1241 else { 1203 else {
1242 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; 1204 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
1243 entry->proc_fops = &acpi_video_bus_POST_fops; 1205 entry->proc_fops = &acpi_video_bus_POST_fops;
@@ -1250,8 +1212,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1250 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, 1212 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
1251 acpi_device_dir(device)); 1213 acpi_device_dir(device));
1252 if (!entry) 1214 if (!entry)
1253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1215 return -ENODEV;
1254 "Unable to create 'DOS' fs entry\n"));
1255 else { 1216 else {
1256 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; 1217 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
1257 entry->proc_fops = &acpi_video_bus_DOS_fops; 1218 entry->proc_fops = &acpi_video_bus_DOS_fops;
@@ -1259,14 +1220,13 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1259 entry->owner = THIS_MODULE; 1220 entry->owner = THIS_MODULE;
1260 } 1221 }
1261 1222
1262 return_VALUE(0); 1223 return 0;
1263} 1224}
1264 1225
1265static int acpi_video_bus_remove_fs(struct acpi_device *device) 1226static int acpi_video_bus_remove_fs(struct acpi_device *device)
1266{ 1227{
1267 struct acpi_video_bus *video; 1228 struct acpi_video_bus *video;
1268 1229
1269 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
1270 1230
1271 video = (struct acpi_video_bus *)acpi_driver_data(device); 1231 video = (struct acpi_video_bus *)acpi_driver_data(device);
1272 1232
@@ -1280,7 +1240,7 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device)
1280 acpi_device_dir(device) = NULL; 1240 acpi_device_dir(device) = NULL;
1281 } 1241 }
1282 1242
1283 return_VALUE(0); 1243 return 0;
1284} 1244}
1285 1245
1286/* -------------------------------------------------------------------------- 1246/* --------------------------------------------------------------------------
@@ -1297,10 +1257,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1297 int status; 1257 int status;
1298 struct acpi_video_device *data; 1258 struct acpi_video_device *data;
1299 1259
1300 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
1301 1260
1302 if (!device || !video) 1261 if (!device || !video)
1303 return_VALUE(-EINVAL); 1262 return -EINVAL;
1304 1263
1305 status = 1264 status =
1306 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); 1265 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
@@ -1308,7 +1267,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1308 1267
1309 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); 1268 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
1310 if (!data) 1269 if (!data)
1311 return_VALUE(-ENOMEM); 1270 return -ENOMEM;
1312 1271
1313 memset(data, 0, sizeof(struct acpi_video_device)); 1272 memset(data, 0, sizeof(struct acpi_video_device));
1314 1273
@@ -1359,10 +1318,10 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1359 1318
1360 acpi_video_device_add_fs(device); 1319 acpi_video_device_add_fs(device);
1361 1320
1362 return_VALUE(0); 1321 return 0;
1363 } 1322 }
1364 1323
1365 return_VALUE(-ENOENT); 1324 return -ENOENT;
1366} 1325}
1367 1326
1368/* 1327/*
@@ -1405,7 +1364,6 @@ acpi_video_device_bind(struct acpi_video_bus *video,
1405 struct acpi_video_device *device) 1364 struct acpi_video_device *device)
1406{ 1365{
1407 int i; 1366 int i;
1408 ACPI_FUNCTION_TRACE("acpi_video_device_bind");
1409 1367
1410#define IDS_VAL(i) video->attached_array[i].value.int_val 1368#define IDS_VAL(i) video->attached_array[i].value.int_val
1411#define IDS_BIND(i) video->attached_array[i].bind_info 1369#define IDS_BIND(i) video->attached_array[i].bind_info
@@ -1442,17 +1400,16 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1442 union acpi_object *dod = NULL; 1400 union acpi_object *dod = NULL;
1443 union acpi_object *obj; 1401 union acpi_object *obj;
1444 1402
1445 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
1446 1403
1447 status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer); 1404 status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer);
1448 if (!ACPI_SUCCESS(status)) { 1405 if (!ACPI_SUCCESS(status)) {
1449 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n")); 1406 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
1450 return_VALUE(status); 1407 return status;
1451 } 1408 }
1452 1409
1453 dod = (union acpi_object *)buffer.pointer; 1410 dod = (union acpi_object *)buffer.pointer;
1454 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { 1411 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1455 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); 1412 ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
1456 status = -EFAULT; 1413 status = -EFAULT;
1457 goto out; 1414 goto out;
1458 } 1415 }
@@ -1476,8 +1433,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1476 obj = (union acpi_object *)&dod->package.elements[i]; 1433 obj = (union acpi_object *)&dod->package.elements[i];
1477 1434
1478 if (obj->type != ACPI_TYPE_INTEGER) { 1435 if (obj->type != ACPI_TYPE_INTEGER) {
1479 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1436 printk(KERN_ERR PREFIX "Invalid _DOD data\n");
1480 "Invalid _DOD data\n"));
1481 active_device_list[i].value.int_val = 1437 active_device_list[i].value.int_val =
1482 ACPI_VIDEO_HEAD_INVALID; 1438 ACPI_VIDEO_HEAD_INVALID;
1483 } 1439 }
@@ -1495,7 +1451,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1495 video->attached_count = count; 1451 video->attached_count = count;
1496 out: 1452 out:
1497 acpi_os_free(buffer.pointer); 1453 acpi_os_free(buffer.pointer);
1498 return_VALUE(status); 1454 return status;
1499} 1455}
1500 1456
1501/* 1457/*
@@ -1520,7 +1476,6 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1520 unsigned long state; 1476 unsigned long state;
1521 int status = 0; 1477 int status = 0;
1522 1478
1523 ACPI_FUNCTION_TRACE("acpi_video_switch_output");
1524 1479
1525 list_for_each_safe(node, next, &video->video_device_list) { 1480 list_for_each_safe(node, next, &video->video_device_list) {
1526 dev = container_of(node, struct acpi_video_device, entry); 1481 dev = container_of(node, struct acpi_video_device, entry);
@@ -1551,7 +1506,7 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1551 break; 1506 break;
1552 } 1507 }
1553 1508
1554 return_VALUE(status); 1509 return status;
1555} 1510}
1556 1511
1557static int 1512static int
@@ -1578,7 +1533,6 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
1578 int status = 0; 1533 int status = 0;
1579 struct list_head *node, *next; 1534 struct list_head *node, *next;
1580 1535
1581 ACPI_FUNCTION_TRACE("acpi_video_get_devices");
1582 1536
1583 acpi_video_device_enumerate(video); 1537 acpi_video_device_enumerate(video);
1584 1538
@@ -1591,13 +1545,12 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
1591 1545
1592 status = acpi_video_bus_get_one_device(dev, video); 1546 status = acpi_video_bus_get_one_device(dev, video);
1593 if (ACPI_FAILURE(status)) { 1547 if (ACPI_FAILURE(status)) {
1594 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1548 ACPI_EXCEPTION((AE_INFO, status, "Cant attach device"));
1595 "Cant attach device\n"));
1596 continue; 1549 continue;
1597 } 1550 }
1598 1551
1599 } 1552 }
1600 return_VALUE(status); 1553 return status;
1601} 1554}
1602 1555
1603static int acpi_video_bus_put_one_device(struct acpi_video_device *device) 1556static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
@@ -1605,10 +1558,9 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1605 acpi_status status; 1558 acpi_status status;
1606 struct acpi_video_bus *video; 1559 struct acpi_video_bus *video;
1607 1560
1608 ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
1609 1561
1610 if (!device || !device->video) 1562 if (!device || !device->video)
1611 return_VALUE(-ENOENT); 1563 return -ENOENT;
1612 1564
1613 video = device->video; 1565 video = device->video;
1614 1566
@@ -1620,11 +1572,8 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1620 status = acpi_remove_notify_handler(device->handle, 1572 status = acpi_remove_notify_handler(device->handle,
1621 ACPI_DEVICE_NOTIFY, 1573 ACPI_DEVICE_NOTIFY,
1622 acpi_video_device_notify); 1574 acpi_video_device_notify);
1623 if (ACPI_FAILURE(status))
1624 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1625 "Error removing notify handler\n"));
1626 1575
1627 return_VALUE(0); 1576 return 0;
1628} 1577}
1629 1578
1630static int acpi_video_bus_put_devices(struct acpi_video_bus *video) 1579static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
@@ -1632,7 +1581,6 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1632 int status; 1581 int status;
1633 struct list_head *node, *next; 1582 struct list_head *node, *next;
1634 1583
1635 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
1636 1584
1637 list_for_each_safe(node, next, &video->video_device_list) { 1585 list_for_each_safe(node, next, &video->video_device_list) {
1638 struct acpi_video_device *data = 1586 struct acpi_video_device *data =
@@ -1651,7 +1599,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1651 kfree(data); 1599 kfree(data);
1652 } 1600 }
1653 1601
1654 return_VALUE(0); 1602 return 0;
1655} 1603}
1656 1604
1657/* acpi_video interface */ 1605/* acpi_video interface */
@@ -1671,14 +1619,13 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1671 struct acpi_video_bus *video = (struct acpi_video_bus *)data; 1619 struct acpi_video_bus *video = (struct acpi_video_bus *)data;
1672 struct acpi_device *device = NULL; 1620 struct acpi_device *device = NULL;
1673 1621
1674 ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
1675 printk("video bus notify\n"); 1622 printk("video bus notify\n");
1676 1623
1677 if (!video) 1624 if (!video)
1678 return_VOID; 1625 return;
1679 1626
1680 if (acpi_bus_get_device(handle, &device)) 1627 if (acpi_bus_get_device(handle, &device))
1681 return_VOID; 1628 return;
1682 1629
1683 switch (event) { 1630 switch (event) {
1684 case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur, 1631 case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur,
@@ -1707,7 +1654,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1707 break; 1654 break;
1708 } 1655 }
1709 1656
1710 return_VOID; 1657 return;
1711} 1658}
1712 1659
1713static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) 1660static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
@@ -1716,14 +1663,13 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1716 (struct acpi_video_device *)data; 1663 (struct acpi_video_device *)data;
1717 struct acpi_device *device = NULL; 1664 struct acpi_device *device = NULL;
1718 1665
1719 ACPI_FUNCTION_TRACE("acpi_video_device_notify");
1720 1666
1721 printk("video device notify\n"); 1667 printk("video device notify\n");
1722 if (!video_device) 1668 if (!video_device)
1723 return_VOID; 1669 return;
1724 1670
1725 if (acpi_bus_get_device(handle, &device)) 1671 if (acpi_bus_get_device(handle, &device))
1726 return_VOID; 1672 return;
1727 1673
1728 switch (event) { 1674 switch (event) {
1729 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ 1675 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
@@ -1743,7 +1689,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1743 "Unsupported event [0x%x]\n", event)); 1689 "Unsupported event [0x%x]\n", event));
1744 break; 1690 break;
1745 } 1691 }
1746 return_VOID; 1692 return;
1747} 1693}
1748 1694
1749static int acpi_video_bus_add(struct acpi_device *device) 1695static int acpi_video_bus_add(struct acpi_device *device)
@@ -1752,14 +1698,13 @@ static int acpi_video_bus_add(struct acpi_device *device)
1752 acpi_status status = 0; 1698 acpi_status status = 0;
1753 struct acpi_video_bus *video = NULL; 1699 struct acpi_video_bus *video = NULL;
1754 1700
1755 ACPI_FUNCTION_TRACE("acpi_video_bus_add");
1756 1701
1757 if (!device) 1702 if (!device)
1758 return_VALUE(-EINVAL); 1703 return -EINVAL;
1759 1704
1760 video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); 1705 video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
1761 if (!video) 1706 if (!video)
1762 return_VALUE(-ENOMEM); 1707 return -ENOMEM;
1763 memset(video, 0, sizeof(struct acpi_video_bus)); 1708 memset(video, 0, sizeof(struct acpi_video_bus));
1764 1709
1765 video->handle = device->handle; 1710 video->handle = device->handle;
@@ -1806,7 +1751,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
1806 if (result) 1751 if (result)
1807 kfree(video); 1752 kfree(video);
1808 1753
1809 return_VALUE(result); 1754 return result;
1810} 1755}
1811 1756
1812static int acpi_video_bus_remove(struct acpi_device *device, int type) 1757static int acpi_video_bus_remove(struct acpi_device *device, int type)
@@ -1814,10 +1759,9 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1814 acpi_status status = 0; 1759 acpi_status status = 0;
1815 struct acpi_video_bus *video = NULL; 1760 struct acpi_video_bus *video = NULL;
1816 1761
1817 ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
1818 1762
1819 if (!device || !acpi_driver_data(device)) 1763 if (!device || !acpi_driver_data(device))
1820 return_VALUE(-EINVAL); 1764 return -EINVAL;
1821 1765
1822 video = (struct acpi_video_bus *)acpi_driver_data(device); 1766 video = (struct acpi_video_bus *)acpi_driver_data(device);
1823 1767
@@ -1826,9 +1770,6 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1826 status = acpi_remove_notify_handler(video->handle, 1770 status = acpi_remove_notify_handler(video->handle,
1827 ACPI_DEVICE_NOTIFY, 1771 ACPI_DEVICE_NOTIFY,
1828 acpi_video_bus_notify); 1772 acpi_video_bus_notify);
1829 if (ACPI_FAILURE(status))
1830 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1831 "Error removing notify handler\n"));
1832 1773
1833 acpi_video_bus_put_devices(video); 1774 acpi_video_bus_put_devices(video);
1834 acpi_video_bus_remove_fs(device); 1775 acpi_video_bus_remove_fs(device);
@@ -1836,7 +1777,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1836 kfree(video->attached_array); 1777 kfree(video->attached_array);
1837 kfree(video); 1778 kfree(video);
1838 1779
1839 return_VALUE(0); 1780 return 0;
1840} 1781}
1841 1782
1842static int 1783static int
@@ -1846,10 +1787,9 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
1846 acpi_handle h_dummy2; 1787 acpi_handle h_dummy2;
1847 acpi_handle h_dummy3; 1788 acpi_handle h_dummy3;
1848 1789
1849 ACPI_FUNCTION_TRACE("acpi_video_bus_match");
1850 1790
1851 if (!device || !driver) 1791 if (!device || !driver)
1852 return_VALUE(-EINVAL); 1792 return -EINVAL;
1853 1793
1854 /* Since there is no HID, CID for ACPI Video drivers, we have 1794 /* Since there is no HID, CID for ACPI Video drivers, we have
1855 * to check well known required nodes for each feature we support. 1795 * to check well known required nodes for each feature we support.
@@ -1858,26 +1798,25 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
1858 /* Does this device able to support video switching ? */ 1798 /* Does this device able to support video switching ? */
1859 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) && 1799 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) &&
1860 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2))) 1800 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2)))
1861 return_VALUE(0); 1801 return 0;
1862 1802
1863 /* Does this device able to retrieve a video ROM ? */ 1803 /* Does this device able to retrieve a video ROM ? */
1864 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1))) 1804 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1)))
1865 return_VALUE(0); 1805 return 0;
1866 1806
1867 /* Does this device able to configure which video head to be POSTed ? */ 1807 /* Does this device able to configure which video head to be POSTed ? */
1868 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) && 1808 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) &&
1869 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) && 1809 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) &&
1870 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) 1810 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
1871 return_VALUE(0); 1811 return 0;
1872 1812
1873 return_VALUE(-ENODEV); 1813 return -ENODEV;
1874} 1814}
1875 1815
1876static int __init acpi_video_init(void) 1816static int __init acpi_video_init(void)
1877{ 1817{
1878 int result = 0; 1818 int result = 0;
1879 1819
1880 ACPI_FUNCTION_TRACE("acpi_video_init");
1881 1820
1882 /* 1821 /*
1883 acpi_dbg_level = 0xFFFFFFFF; 1822 acpi_dbg_level = 0xFFFFFFFF;
@@ -1886,27 +1825,26 @@ static int __init acpi_video_init(void)
1886 1825
1887 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 1826 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1888 if (!acpi_video_dir) 1827 if (!acpi_video_dir)
1889 return_VALUE(-ENODEV); 1828 return -ENODEV;
1890 acpi_video_dir->owner = THIS_MODULE; 1829 acpi_video_dir->owner = THIS_MODULE;
1891 1830
1892 result = acpi_bus_register_driver(&acpi_video_bus); 1831 result = acpi_bus_register_driver(&acpi_video_bus);
1893 if (result < 0) { 1832 if (result < 0) {
1894 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); 1833 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1895 return_VALUE(-ENODEV); 1834 return -ENODEV;
1896 } 1835 }
1897 1836
1898 return_VALUE(0); 1837 return 0;
1899} 1838}
1900 1839
1901static void __exit acpi_video_exit(void) 1840static void __exit acpi_video_exit(void)
1902{ 1841{
1903 ACPI_FUNCTION_TRACE("acpi_video_exit");
1904 1842
1905 acpi_bus_unregister_driver(&acpi_video_bus); 1843 acpi_bus_unregister_driver(&acpi_video_bus);
1906 1844
1907 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); 1845 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1908 1846
1909 return_VOID; 1847 return;
1910} 1848}
1911 1849
1912module_init(acpi_video_init); 1850module_init(acpi_video_init);
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 421cfffb1756..34a1891191fd 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -40,8 +40,7 @@ ibmphp-objs := ibmphp_core.o \
40 ibmphp_hpc.o 40 ibmphp_hpc.o
41 41
42acpiphp-objs := acpiphp_core.o \ 42acpiphp-objs := acpiphp_core.o \
43 acpiphp_glue.o \ 43 acpiphp_glue.o
44 acpiphp_dock.o
45 44
46rpaphp-objs := rpaphp_core.o \ 45rpaphp-objs := rpaphp_core.o \
47 rpaphp_pci.o \ 46 rpaphp_pci.o \
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 17a93f890dba..be104eced34c 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -130,7 +130,7 @@ struct acpiphp_func {
130 130
131 struct list_head sibling; 131 struct list_head sibling;
132 struct pci_dev *pci_dev; 132 struct pci_dev *pci_dev;
133 133 struct notifier_block nb;
134 acpi_handle handle; 134 acpi_handle handle;
135 135
136 u8 function; /* pci function# */ 136 u8 function; /* pci function# */
@@ -151,24 +151,6 @@ struct acpiphp_attention_info
151}; 151};
152 152
153 153
154struct dependent_device {
155 struct list_head device_list;
156 struct list_head pci_list;
157 acpi_handle handle;
158 struct acpiphp_func *func;
159};
160
161
162struct acpiphp_dock_station {
163 acpi_handle handle;
164 u32 last_dock_time;
165 u32 flags;
166 struct acpiphp_func *dock_bridge;
167 struct list_head dependent_devices;
168 struct list_head pci_dependent_devices;
169};
170
171
172/* PCI bus bridge HID */ 154/* PCI bus bridge HID */
173#define ACPI_PCI_HOST_HID "PNP0A03" 155#define ACPI_PCI_HOST_HID "PNP0A03"
174 156
@@ -207,11 +189,6 @@ struct acpiphp_dock_station {
207#define FUNC_HAS_PS2 (0x00000040) 189#define FUNC_HAS_PS2 (0x00000040)
208#define FUNC_HAS_PS3 (0x00000080) 190#define FUNC_HAS_PS3 (0x00000080)
209#define FUNC_HAS_DCK (0x00000100) 191#define FUNC_HAS_DCK (0x00000100)
210#define FUNC_IS_DD (0x00000200)
211
212/* dock station flags */
213#define DOCK_DOCKING (0x00000001)
214#define DOCK_HAS_BRIDGE (0x00000002)
215 192
216/* function prototypes */ 193/* function prototypes */
217 194
@@ -226,7 +203,6 @@ extern int acpiphp_glue_init (void);
226extern void acpiphp_glue_exit (void); 203extern void acpiphp_glue_exit (void);
227extern int acpiphp_get_num_slots (void); 204extern int acpiphp_get_num_slots (void);
228typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); 205typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
229void handle_hotplug_event_func(acpi_handle, u32, void*);
230 206
231extern int acpiphp_enable_slot (struct acpiphp_slot *slot); 207extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
232extern int acpiphp_disable_slot (struct acpiphp_slot *slot); 208extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
@@ -236,16 +212,6 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
236extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); 212extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
237extern u32 acpiphp_get_address (struct acpiphp_slot *slot); 213extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
238 214
239/* acpiphp_dock.c */
240extern int find_dock_station(void);
241extern void remove_dock_station(void);
242extern void add_dependent_device(struct dependent_device *new_dd);
243extern void add_pci_dependent_device(struct dependent_device *new_dd);
244extern struct dependent_device *get_dependent_device(acpi_handle handle);
245extern int is_dependent_device(acpi_handle handle);
246extern int detect_dependent_devices(acpi_handle *bridge_handle);
247extern struct dependent_device *alloc_dependent_device(acpi_handle handle);
248
249/* variables */ 215/* variables */
250extern int acpiphp_debug; 216extern int acpiphp_debug;
251 217
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 4f1b0da8e47e..34de5697983d 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -416,27 +416,12 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
416 416
417static int __init acpiphp_init(void) 417static int __init acpiphp_init(void)
418{ 418{
419 int retval;
420 int docking_station;
421
422 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 419 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
423 420
424 acpiphp_debug = debug; 421 acpiphp_debug = debug;
425 422
426 docking_station = find_dock_station();
427
428 /* read all the ACPI info from the system */ 423 /* read all the ACPI info from the system */
429 retval = init_acpi(); 424 return init_acpi();
430
431 /* if we have found a docking station, we should
432 * go ahead and load even if init_acpi has found
433 * no slots. This handles the case when the _DCK
434 * method not defined under the actual dock bridge
435 */
436 if (docking_station)
437 return 0;
438 else
439 return retval;
440} 425}
441 426
442 427
@@ -444,8 +429,6 @@ static void __exit acpiphp_exit(void)
444{ 429{
445 /* deallocate internal data structures etc. */ 430 /* deallocate internal data structures etc. */
446 acpiphp_glue_exit(); 431 acpiphp_glue_exit();
447
448 remove_dock_station();
449} 432}
450 433
451module_init(acpiphp_init); 434module_init(acpiphp_init);
diff --git a/drivers/pci/hotplug/acpiphp_dock.c b/drivers/pci/hotplug/acpiphp_dock.c
deleted file mode 100644
index 4f1aaf128312..000000000000
--- a/drivers/pci/hotplug/acpiphp_dock.c
+++ /dev/null
@@ -1,438 +0,0 @@
1/*
2 * ACPI PCI HotPlug dock functions to ACPI CA subsystem
3 *
4 * Copyright (C) 2006 Kristen Carlson Accardi (kristen.c.accardi@intel.com)
5 * Copyright (C) 2006 Intel Corporation
6 *
7 * All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
17 * NON INFRINGEMENT. See the GNU General Public License for more
18 * details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * Send feedback to <kristen.c.accardi@intel.com>
25 *
26 */
27#include <linux/init.h>
28#include <linux/module.h>
29
30#include <linux/kernel.h>
31#include <linux/pci.h>
32#include <linux/smp_lock.h>
33#include <linux/mutex.h>
34
35#include "../pci.h"
36#include "pci_hotplug.h"
37#include "acpiphp.h"
38
39static struct acpiphp_dock_station *ds;
40#define MY_NAME "acpiphp_dock"
41
42
43int is_dependent_device(acpi_handle handle)
44{
45 return (get_dependent_device(handle) ? 1 : 0);
46}
47
48
49static acpi_status
50find_dependent_device(acpi_handle handle, u32 lvl, void *context, void **rv)
51{
52 int *count = (int *)context;
53
54 if (is_dependent_device(handle)) {
55 (*count)++;
56 return AE_CTRL_TERMINATE;
57 } else {
58 return AE_OK;
59 }
60}
61
62
63
64
65void add_dependent_device(struct dependent_device *new_dd)
66{
67 list_add_tail(&new_dd->device_list, &ds->dependent_devices);
68}
69
70
71void add_pci_dependent_device(struct dependent_device *new_dd)
72{
73 list_add_tail(&new_dd->pci_list, &ds->pci_dependent_devices);
74}
75
76
77
78struct dependent_device * get_dependent_device(acpi_handle handle)
79{
80 struct dependent_device *dd;
81
82 if (!ds)
83 return NULL;
84
85 list_for_each_entry(dd, &ds->dependent_devices, device_list) {
86 if (handle == dd->handle)
87 return dd;
88 }
89 return NULL;
90}
91
92
93
94struct dependent_device *alloc_dependent_device(acpi_handle handle)
95{
96 struct dependent_device *dd;
97
98 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
99 if (dd) {
100 INIT_LIST_HEAD(&dd->pci_list);
101 INIT_LIST_HEAD(&dd->device_list);
102 dd->handle = handle;
103 }
104 return dd;
105}
106
107
108
109static int is_dock(acpi_handle handle)
110{
111 acpi_status status;
112 acpi_handle tmp;
113
114 status = acpi_get_handle(handle, "_DCK", &tmp);
115 if (ACPI_FAILURE(status)) {
116 return 0;
117 }
118 return 1;
119}
120
121
122
123static int dock_present(void)
124{
125 unsigned long sta;
126 acpi_status status;
127
128 if (ds) {
129 status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
130 if (ACPI_SUCCESS(status) && sta)
131 return 1;
132 }
133 return 0;
134}
135
136
137
138static void eject_dock(void)
139{
140 struct acpi_object_list arg_list;
141 union acpi_object arg;
142
143 arg_list.count = 1;
144 arg_list.pointer = &arg;
145 arg.type = ACPI_TYPE_INTEGER;
146 arg.integer.value = 1;
147
148 if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0",
149 &arg_list, NULL)) || dock_present())
150 warn("%s: failed to eject dock!\n", __FUNCTION__);
151
152 return;
153}
154
155
156
157
158static acpi_status handle_dock(int dock)
159{
160 acpi_status status;
161 struct acpi_object_list arg_list;
162 union acpi_object arg;
163 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
164
165 dbg("%s: %s\n", __FUNCTION__, dock ? "docking" : "undocking");
166
167 /* _DCK method has one argument */
168 arg_list.count = 1;
169 arg_list.pointer = &arg;
170 arg.type = ACPI_TYPE_INTEGER;
171 arg.integer.value = dock;
172 status = acpi_evaluate_object(ds->handle, "_DCK",
173 &arg_list, &buffer);
174 if (ACPI_FAILURE(status))
175 err("%s: failed to execute _DCK\n", __FUNCTION__);
176 acpi_os_free(buffer.pointer);
177
178 return status;
179}
180
181
182
183static inline void dock(void)
184{
185 handle_dock(1);
186}
187
188
189
190static inline void undock(void)
191{
192 handle_dock(0);
193}
194
195
196
197/*
198 * the _DCK method can do funny things... and sometimes not
199 * hah-hah funny.
200 *
201 * TBD - figure out a way to only call fixups for
202 * systems that require them.
203 */
204static void post_dock_fixups(void)
205{
206 struct pci_bus *bus;
207 u32 buses;
208 struct dependent_device *dd;
209
210 list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) {
211 bus = dd->func->slot->bridge->pci_bus;
212
213 /* fixup bad _DCK function that rewrites
214 * secondary bridge on slot
215 */
216 pci_read_config_dword(bus->self,
217 PCI_PRIMARY_BUS,
218 &buses);
219
220 if (((buses >> 8) & 0xff) != bus->secondary) {
221 buses = (buses & 0xff000000)
222 | ((unsigned int)(bus->primary) << 0)
223 | ((unsigned int)(bus->secondary) << 8)
224 | ((unsigned int)(bus->subordinate) << 16);
225 pci_write_config_dword(bus->self,
226 PCI_PRIMARY_BUS,
227 buses);
228 }
229 }
230}
231
232
233
234static void hotplug_pci(u32 type)
235{
236 struct dependent_device *dd;
237
238 list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list)
239 handle_hotplug_event_func(dd->handle, type, dd->func);
240}
241
242
243
244static inline void begin_dock(void)
245{
246 ds->flags |= DOCK_DOCKING;
247}
248
249
250static inline void complete_dock(void)
251{
252 ds->flags &= ~(DOCK_DOCKING);
253 ds->last_dock_time = jiffies;
254}
255
256
257static int dock_in_progress(void)
258{
259 if (ds->flags & DOCK_DOCKING ||
260 ds->last_dock_time == jiffies) {
261 dbg("dock in progress\n");
262 return 1;
263 }
264 return 0;
265}
266
267
268
269static void
270handle_hotplug_event_dock(acpi_handle handle, u32 type, void *context)
271{
272 dbg("%s: enter\n", __FUNCTION__);
273
274 switch (type) {
275 case ACPI_NOTIFY_BUS_CHECK:
276 dbg("BUS Check\n");
277 if (!dock_in_progress() && dock_present()) {
278 begin_dock();
279 dock();
280 if (!dock_present()) {
281 err("Unable to dock!\n");
282 break;
283 }
284 post_dock_fixups();
285 hotplug_pci(type);
286 complete_dock();
287 }
288 break;
289 case ACPI_NOTIFY_EJECT_REQUEST:
290 dbg("EJECT request\n");
291 if (!dock_in_progress() && dock_present()) {
292 hotplug_pci(type);
293 undock();
294 eject_dock();
295 if (dock_present())
296 err("Unable to undock!\n");
297 }
298 break;
299 }
300}
301
302
303
304
305static acpi_status
306find_dock_ejd(acpi_handle handle, u32 lvl, void *context, void **rv)
307{
308 acpi_status status;
309 acpi_handle tmp;
310 acpi_handle dck_handle = (acpi_handle) context;
311 char objname[64];
312 struct acpi_buffer buffer = { .length = sizeof(objname),
313 .pointer = objname };
314 struct acpi_buffer ejd_buffer = {ACPI_ALLOCATE_BUFFER, NULL};
315 union acpi_object *ejd_obj;
316
317 status = acpi_get_handle(handle, "_EJD", &tmp);
318 if (ACPI_FAILURE(status))
319 return AE_OK;
320
321 /* make sure we are dependent on the dock device,
322 * by executing the _EJD method, then getting a handle
323 * to the device referenced by that name. If that
324 * device handle is the same handle as the dock station
325 * handle, then we are a device dependent on the dock station
326 */
327 acpi_get_name(dck_handle, ACPI_FULL_PATHNAME, &buffer);
328 status = acpi_evaluate_object(handle, "_EJD", NULL, &ejd_buffer);
329 if (ACPI_FAILURE(status)) {
330 err("Unable to execute _EJD!\n");
331 goto find_ejd_out;
332 }
333 ejd_obj = ejd_buffer.pointer;
334 status = acpi_get_handle(NULL, ejd_obj->string.pointer, &tmp);
335 if (ACPI_FAILURE(status))
336 goto find_ejd_out;
337
338 if (tmp == dck_handle) {
339 struct dependent_device *dd;
340 dbg("%s: found device dependent on dock\n", __FUNCTION__);
341 dd = alloc_dependent_device(handle);
342 if (!dd) {
343 err("Can't allocate memory for dependent device!\n");
344 goto find_ejd_out;
345 }
346 add_dependent_device(dd);
347 }
348
349find_ejd_out:
350 acpi_os_free(ejd_buffer.pointer);
351 return AE_OK;
352}
353
354
355
356int detect_dependent_devices(acpi_handle *bridge_handle)
357{
358 acpi_status status;
359 int count;
360
361 count = 0;
362
363 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
364 (u32)1, find_dependent_device,
365 (void *)&count, NULL);
366
367 return count;
368}
369
370
371
372
373
374static acpi_status
375find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
376{
377 int *count = (int *)context;
378
379 if (is_dock(handle)) {
380 dbg("%s: found dock\n", __FUNCTION__);
381 ds = kzalloc(sizeof(*ds), GFP_KERNEL);
382 ds->handle = handle;
383 INIT_LIST_HEAD(&ds->dependent_devices);
384 INIT_LIST_HEAD(&ds->pci_dependent_devices);
385
386 /* look for devices dependent on dock station */
387 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
388 ACPI_UINT32_MAX, find_dock_ejd, handle, NULL);
389
390 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
391 handle_hotplug_event_dock, ds);
392 (*count)++;
393 }
394
395 return AE_OK;
396}
397
398
399
400
401int find_dock_station(void)
402{
403 int num = 0;
404
405 ds = NULL;
406
407 /* start from the root object, because some laptops define
408 * _DCK methods outside the scope of PCI (IBM x-series laptop)
409 */
410 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
411 ACPI_UINT32_MAX, find_dock, &num, NULL);
412
413 return num;
414}
415
416
417
418void remove_dock_station(void)
419{
420 struct dependent_device *dd, *tmp;
421 if (ds) {
422 if (ACPI_FAILURE(acpi_remove_notify_handler(ds->handle,
423 ACPI_SYSTEM_NOTIFY, handle_hotplug_event_dock)))
424 err("failed to remove dock notify handler\n");
425
426 /* free all dependent devices */
427 list_for_each_entry_safe(dd, tmp, &ds->dependent_devices,
428 device_list)
429 kfree(dd);
430
431 /* no need to touch the pci_dependent_device list,
432 * cause all memory was freed above
433 */
434 kfree(ds);
435 }
436}
437
438
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index d370f999782e..ef95d12fb32c 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -59,6 +59,7 @@ static LIST_HEAD(bridge_list);
59static void handle_hotplug_event_bridge (acpi_handle, u32, void *); 59static void handle_hotplug_event_bridge (acpi_handle, u32, void *);
60static void acpiphp_sanitize_bus(struct pci_bus *bus); 60static void acpiphp_sanitize_bus(struct pci_bus *bus);
61static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); 61static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
62static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
62 63
63 64
64/* 65/*
@@ -116,6 +117,59 @@ is_ejectable_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
116 } 117 }
117} 118}
118 119
120/* callback routine to check for the existance of a pci dock device */
121static acpi_status
122is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
123{
124 int *count = (int *)context;
125
126 if (is_dock_device(handle)) {
127 (*count)++;
128 return AE_CTRL_TERMINATE;
129 } else {
130 return AE_OK;
131 }
132}
133
134
135
136
137/*
138 * the _DCK method can do funny things... and sometimes not
139 * hah-hah funny.
140 *
141 * TBD - figure out a way to only call fixups for
142 * systems that require them.
143 */
144static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
145 void *v)
146{
147 struct acpiphp_func *func = container_of(nb, struct acpiphp_func, nb);
148 struct pci_bus *bus = func->slot->bridge->pci_bus;
149 u32 buses;
150
151 if (!bus->self)
152 return NOTIFY_OK;
153
154 /* fixup bad _DCK function that rewrites
155 * secondary bridge on slot
156 */
157 pci_read_config_dword(bus->self,
158 PCI_PRIMARY_BUS,
159 &buses);
160
161 if (((buses >> 8) & 0xff) != bus->secondary) {
162 buses = (buses & 0xff000000)
163 | ((unsigned int)(bus->primary) << 0)
164 | ((unsigned int)(bus->secondary) << 8)
165 | ((unsigned int)(bus->subordinate) << 16);
166 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
167 }
168 return NOTIFY_OK;
169}
170
171
172
119 173
120/* callback routine to register each ACPI PCI slot object */ 174/* callback routine to register each ACPI PCI slot object */
121static acpi_status 175static acpi_status
@@ -124,7 +178,6 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
124 struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; 178 struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context;
125 struct acpiphp_slot *slot; 179 struct acpiphp_slot *slot;
126 struct acpiphp_func *newfunc; 180 struct acpiphp_func *newfunc;
127 struct dependent_device *dd;
128 acpi_handle tmp; 181 acpi_handle tmp;
129 acpi_status status = AE_OK; 182 acpi_status status = AE_OK;
130 unsigned long adr, sun; 183 unsigned long adr, sun;
@@ -137,7 +190,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
137 190
138 status = acpi_get_handle(handle, "_EJ0", &tmp); 191 status = acpi_get_handle(handle, "_EJ0", &tmp);
139 192
140 if (ACPI_FAILURE(status) && !(is_dependent_device(handle))) 193 if (ACPI_FAILURE(status) && !(is_dock_device(handle)))
141 return AE_OK; 194 return AE_OK;
142 195
143 device = (adr >> 16) & 0xffff; 196 device = (adr >> 16) & 0xffff;
@@ -162,22 +215,17 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
162 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) 215 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp)))
163 newfunc->flags |= FUNC_HAS_PS3; 216 newfunc->flags |= FUNC_HAS_PS3;
164 217
165 if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) { 218 if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp)))
166 newfunc->flags |= FUNC_HAS_DCK; 219 newfunc->flags |= FUNC_HAS_DCK;
167 /* add to devices dependent on dock station,
168 * because this may actually be the dock bridge
169 */
170 dd = alloc_dependent_device(handle);
171 if (!dd)
172 err("Can't allocate memory for "
173 "new dependent device!\n");
174 else
175 add_dependent_device(dd);
176 }
177 220
178 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); 221 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
179 if (ACPI_FAILURE(status)) 222 if (ACPI_FAILURE(status)) {
180 sun = -1; 223 /*
224 * use the count of the number of slots we've found
225 * for the number of the slot
226 */
227 sun = bridge->nr_slots+1;
228 }
181 229
182 /* search for objects that share the same slot */ 230 /* search for objects that share the same slot */
183 for (slot = bridge->slots; slot; slot = slot->next) 231 for (slot = bridge->slots; slot; slot = slot->next)
@@ -225,20 +273,23 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
225 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); 273 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
226 } 274 }
227 275
228 /* if this is a device dependent on a dock station, 276 if (is_dock_device(handle)) {
229 * associate the acpiphp_func to the dependent_device 277 /* we don't want to call this device's _EJ0
230 * struct. 278 * because we want the dock notify handler
231 */ 279 * to call it after it calls _DCK
232 if ((dd = get_dependent_device(handle))) {
233 newfunc->flags |= FUNC_IS_DD;
234 /*
235 * we don't want any devices which is dependent
236 * on the dock to have it's _EJ0 method executed.
237 * because we need to run _DCK first.
238 */ 280 */
239 newfunc->flags &= ~FUNC_HAS_EJ0; 281 newfunc->flags &= ~FUNC_HAS_EJ0;
240 dd->func = newfunc; 282 if (register_hotplug_dock_device(handle,
241 add_pci_dependent_device(dd); 283 handle_hotplug_event_func, newfunc))
284 dbg("failed to register dock device\n");
285
286 /* we need to be notified when dock events happen
287 * outside of the hotplug operation, since we may
288 * need to do fixups before we can hotplug.
289 */
290 newfunc->nb.notifier_call = post_dock_fixups;
291 if (register_dock_notifier(&newfunc->nb))
292 dbg("failed to register a dock notifier");
242 } 293 }
243 294
244 /* install notify handler */ 295 /* install notify handler */
@@ -277,6 +328,15 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle)
277 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1, 328 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1,
278 is_ejectable_slot, (void *)&count, NULL); 329 is_ejectable_slot, (void *)&count, NULL);
279 330
331 /*
332 * we also need to add this bridge if there is a dock bridge or
333 * other pci device on a dock station (removable)
334 */
335 if (!count)
336 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
337 (u32)1, is_pci_dock_device, (void *)&count,
338 NULL);
339
280 return count; 340 return count;
281} 341}
282 342
@@ -487,8 +547,7 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
487 goto out; 547 goto out;
488 548
489 /* check if this bridge has ejectable slots */ 549 /* check if this bridge has ejectable slots */
490 if ((detect_ejectable_slots(handle) > 0) || 550 if ((detect_ejectable_slots(handle) > 0)) {
491 (detect_dependent_devices(handle) > 0)) {
492 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); 551 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev));
493 add_p2p_bridge(handle, dev); 552 add_p2p_bridge(handle, dev);
494 } 553 }
@@ -605,6 +664,10 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
605 list_for_each_safe (list, tmp, &slot->funcs) { 664 list_for_each_safe (list, tmp, &slot->funcs) {
606 struct acpiphp_func *func; 665 struct acpiphp_func *func;
607 func = list_entry(list, struct acpiphp_func, sibling); 666 func = list_entry(list, struct acpiphp_func, sibling);
667 if (is_dock_device(func->handle)) {
668 unregister_hotplug_dock_device(func->handle);
669 unregister_dock_notifier(&func->nb);
670 }
608 if (!(func->flags & FUNC_HAS_DCK)) { 671 if (!(func->flags & FUNC_HAS_DCK)) {
609 status = acpi_remove_notify_handler(func->handle, 672 status = acpi_remove_notify_handler(func->handle,
610 ACPI_SYSTEM_NOTIFY, 673 ACPI_SYSTEM_NOTIFY,
@@ -1440,7 +1503,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont
1440 * handles ACPI event notification on slots 1503 * handles ACPI event notification on slots
1441 * 1504 *
1442 */ 1505 */
1443void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) 1506static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context)
1444{ 1507{
1445 struct acpiphp_func *func; 1508 struct acpiphp_func *func;
1446 char objname[64]; 1509 char objname[64];
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index b9beceb33141..b492857fe721 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -63,7 +63,7 @@
63 63
64/* Current ACPICA subsystem version in YYYYMMDD format */ 64/* Current ACPICA subsystem version in YYYYMMDD format */
65 65
66#define ACPI_CA_VERSION 0x20060608 66#define ACPI_CA_VERSION 0x20060623
67 67
68/* 68/*
69 * OS name, used for the _OS object. The _OS object is essentially obsolete, 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h
index 288f84903af7..a22fe9cf8493 100644
--- a/include/acpi/acdispat.h
+++ b/include/acpi/acdispat.h
@@ -201,7 +201,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
201acpi_status 201acpi_status
202acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, 202acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
203 union acpi_operand_object *obj_desc, 203 union acpi_operand_object *obj_desc,
204 struct acpi_namespace_node *calling_method_node); 204 struct acpi_walk_state *walk_state);
205 205
206acpi_status 206acpi_status
207acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state); 207acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state);
diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h
index 14531d48f6b6..06972e6637de 100644
--- a/include/acpi/acglobal.h
+++ b/include/acpi/acglobal.h
@@ -181,6 +181,12 @@ ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
181extern struct acpi_table_list acpi_gbl_table_lists[ACPI_TABLE_ID_MAX + 1]; 181extern struct acpi_table_list acpi_gbl_table_lists[ACPI_TABLE_ID_MAX + 1];
182extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1]; 182extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1];
183 183
184/*****************************************************************************
185 *
186 * Mutual exlusion within ACPICA subsystem
187 *
188 ****************************************************************************/
189
184/* 190/*
185 * Predefined mutex objects. This array contains the 191 * Predefined mutex objects. This array contains the
186 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. 192 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
@@ -188,6 +194,20 @@ extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1];
188 */ 194 */
189ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX]; 195ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];
190 196
197/*
198 * Global lock semaphore works in conjunction with the actual HW global lock
199 */
200ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;
201
202/*
203 * Spinlocks are used for interfaces that can be possibly called at
204 * interrupt level
205 */
206ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock; /* For GPE data structs and registers */
207ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */
208#define acpi_gbl_gpe_lock &_acpi_gbl_gpe_lock
209#define acpi_gbl_hardware_lock &_acpi_gbl_hardware_lock
210
191/***************************************************************************** 211/*****************************************************************************
192 * 212 *
193 * Miscellaneous globals 213 * Miscellaneous globals
@@ -217,7 +237,6 @@ ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
217ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; 237ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
218ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; 238ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
219ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; 239ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
220ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore;
221 240
222/* Misc */ 241/* Misc */
223 242
@@ -315,11 +334,6 @@ ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
315ACPI_EXTERN struct acpi_gpe_block_info 334ACPI_EXTERN struct acpi_gpe_block_info
316 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 335 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
317 336
318/* Spinlocks */
319
320ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock;
321ACPI_EXTERN acpi_handle acpi_gbl_hardware_lock;
322
323/***************************************************************************** 337/*****************************************************************************
324 * 338 *
325 * Debugger globals 339 * Debugger globals
diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h
index 9f22cfcb624b..216339a8f1f6 100644
--- a/include/acpi/acinterp.h
+++ b/include/acpi/acinterp.h
@@ -287,7 +287,10 @@ acpi_ex_system_wait_event(union acpi_operand_object *time,
287 287
288acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc); 288acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc);
289 289
290acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout); 290acpi_status
291acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout);
292
293acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout);
291 294
292/* 295/*
293 * exoparg1 - ACPI AML execution, 1 operand 296 * exoparg1 - ACPI AML execution, 1 operand
diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h
index 1eeca7adca95..56b802486161 100644
--- a/include/acpi/aclocal.h
+++ b/include/acpi/aclocal.h
@@ -47,10 +47,11 @@
47/* acpisrc:struct_defs -- for acpisrc conversion */ 47/* acpisrc:struct_defs -- for acpisrc conversion */
48 48
49#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */ 49#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */
50#define ACPI_INFINITE_CONCURRENCY 0xFF 50#define ACPI_DO_NOT_WAIT 0
51#define ACPI_SERIALIZED 0xFF
51 52
52typedef void *acpi_mutex;
53typedef u32 acpi_mutex_handle; 53typedef u32 acpi_mutex_handle;
54#define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1)
54 55
55/* Total number of aml opcodes defined */ 56/* Total number of aml opcodes defined */
56 57
@@ -79,16 +80,15 @@ union acpi_parse_object;
79 * table below also! 80 * table below also!
80 */ 81 */
81#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ 82#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */
82#define ACPI_MTX_CONTROL_METHOD 1 /* Control method termination [TBD: may no longer be necessary] */ 83#define ACPI_MTX_TABLES 1 /* Data for ACPI tables */
83#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ 84#define ACPI_MTX_NAMESPACE 2 /* ACPI Namespace */
84#define ACPI_MTX_NAMESPACE 3 /* ACPI Namespace */ 85#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */
85#define ACPI_MTX_EVENTS 4 /* Data for ACPI events */ 86#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */
86#define ACPI_MTX_CACHES 5 /* Internal caches, general purposes */ 87#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */
87#define ACPI_MTX_MEMORY 6 /* Debug memory tracking lists */ 88#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */
88#define ACPI_MTX_DEBUG_CMD_COMPLETE 7 /* AML debugger */ 89#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */
89#define ACPI_MTX_DEBUG_CMD_READY 8 /* AML debugger */ 90
90 91#define ACPI_MAX_MUTEX 7
91#define ACPI_MAX_MUTEX 8
92#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 92#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1
93 93
94#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 94#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
@@ -98,14 +98,13 @@ union acpi_parse_object;
98 98
99static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = { 99static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
100 "ACPI_MTX_Interpreter", 100 "ACPI_MTX_Interpreter",
101 "ACPI_MTX_Method",
102 "ACPI_MTX_Tables", 101 "ACPI_MTX_Tables",
103 "ACPI_MTX_Namespace", 102 "ACPI_MTX_Namespace",
104 "ACPI_MTX_Events", 103 "ACPI_MTX_Events",
105 "ACPI_MTX_Caches", 104 "ACPI_MTX_Caches",
106 "ACPI_MTX_Memory", 105 "ACPI_MTX_Memory",
107 "ACPI_MTX_DebugCmdComplete", 106 "ACPI_MTX_CommandComplete",
108 "ACPI_MTX_DebugCmdReady" 107 "ACPI_MTX_CommandReady"
109}; 108};
110 109
111#endif 110#endif
@@ -705,6 +704,13 @@ struct acpi_bit_register_info {
705}; 704};
706 705
707/* 706/*
707 * Some ACPI registers have bits that must be ignored -- meaning that they
708 * must be preserved.
709 */
710#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */
711#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0201 /* Bit 9, Bit 0 (SCI_EN) */
712
713/*
708 * Register IDs 714 * Register IDs
709 * These are the full ACPI registers 715 * These are the full ACPI registers
710 */ 716 */
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 38f9aa4bef00..4bb38068f40d 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -394,6 +394,8 @@
394#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) 394#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
395#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) 395#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
396 396
397#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask))
398
397/* Generate a UUID */ 399/* Generate a UUID */
398 400
399#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 401#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h
index 1747d94084d8..8fdee31119f3 100644
--- a/include/acpi/acobject.h
+++ b/include/acpi/acobject.h
@@ -140,14 +140,14 @@ struct acpi_object_package {
140 *****************************************************************************/ 140 *****************************************************************************/
141 141
142struct acpi_object_event { 142struct acpi_object_event {
143 ACPI_OBJECT_COMMON_HEADER void *semaphore; 143 ACPI_OBJECT_COMMON_HEADER acpi_semaphore os_semaphore; /* Actual OS synchronization object */
144}; 144};
145 145
146struct acpi_object_mutex { 146struct acpi_object_mutex {
147 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */ 147 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */
148 u16 acquisition_depth; /* Allow multiple Acquires, same thread */ 148 u16 acquisition_depth; /* Allow multiple Acquires, same thread */
149 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */ 149 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
150 void *semaphore; /* Actual OS synchronization object */ 150 acpi_mutex os_mutex; /* Actual OS synchronization object */
151 union acpi_operand_object *prev; /* Link for list of acquired mutexes */ 151 union acpi_operand_object *prev; /* Link for list of acquired mutexes */
152 union acpi_operand_object *next; /* Link for list of acquired mutexes */ 152 union acpi_operand_object *next; /* Link for list of acquired mutexes */
153 struct acpi_namespace_node *node; /* Containing namespace node */ 153 struct acpi_namespace_node *node; /* Containing namespace node */
@@ -166,8 +166,8 @@ struct acpi_object_region {
166struct acpi_object_method { 166struct acpi_object_method {
167 ACPI_OBJECT_COMMON_HEADER u8 method_flags; 167 ACPI_OBJECT_COMMON_HEADER u8 method_flags;
168 u8 param_count; 168 u8 param_count;
169 u8 concurrency; 169 u8 sync_level;
170 void *semaphore; 170 union acpi_operand_object *mutex;
171 u8 *aml_start; 171 u8 *aml_start;
172 ACPI_INTERNAL_METHOD implementation; 172 ACPI_INTERNAL_METHOD implementation;
173 u32 aml_length; 173 u32 aml_length;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index a2b3e390a503..f338e40bd544 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -334,7 +334,7 @@ int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,
334 acpi_handle handle, int type); 334 acpi_handle handle, int type);
335int acpi_bus_trim(struct acpi_device *start, int rmdevice); 335int acpi_bus_trim(struct acpi_device *start, int rmdevice);
336int acpi_bus_start(struct acpi_device *device); 336int acpi_bus_start(struct acpi_device *device);
337 337acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd);
338int acpi_match_ids(struct acpi_device *device, char *ids); 338int acpi_match_ids(struct acpi_device *device, char *ids);
339int acpi_create_dir(struct acpi_device *); 339int acpi_create_dir(struct acpi_device *);
340void acpi_remove_dir(struct acpi_device *); 340void acpi_remove_dir(struct acpi_device *);
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index b425f9bb6d43..6a5bdcefec64 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -110,4 +110,21 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
110 110
111extern int acpi_specific_hotkey_enabled; 111extern int acpi_specific_hotkey_enabled;
112 112
113/*--------------------------------------------------------------------------
114 Dock Station
115 -------------------------------------------------------------------------- */
116#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE)
117extern int is_dock_device(acpi_handle handle);
118extern int register_dock_notifier(struct notifier_block *nb);
119extern void unregister_dock_notifier(struct notifier_block *nb);
120extern int register_hotplug_dock_device(acpi_handle handle,
121 acpi_notify_handler handler, void *context);
122extern void unregister_hotplug_dock_device(acpi_handle handle);
123#else
124#define is_dock_device(h) (0)
125#define register_dock_notifier(nb) (-ENODEV)
126#define unregister_dock_notifier(nb) do { } while(0)
127#define register_hotplug_dock_device(h1, h2, c) (-ENODEV)
128#define unregister_hotplug_dock_device(h) do { } while(0)
129#endif
113#endif /*__ACPI_DRIVERS_H__*/ 130#endif /*__ACPI_DRIVERS_H__*/
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 8f473c83b7c4..89bc4a16c2e8 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -96,25 +96,47 @@ acpi_os_table_override(struct acpi_table_header *existing_table,
96 struct acpi_table_header **new_table); 96 struct acpi_table_header **new_table);
97 97
98/* 98/*
99 * Synchronization primitives 99 * Spinlock primitives
100 */
101acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
102
103void acpi_os_delete_lock(acpi_spinlock handle);
104
105acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
106
107void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
108
109/*
110 * Semaphore primitives
100 */ 111 */
101acpi_status 112acpi_status
102acpi_os_create_semaphore(u32 max_units, 113acpi_os_create_semaphore(u32 max_units,
103 u32 initial_units, acpi_handle * out_handle); 114 u32 initial_units, acpi_semaphore * out_handle);
104 115
105acpi_status acpi_os_delete_semaphore(acpi_handle handle); 116acpi_status acpi_os_delete_semaphore(acpi_semaphore handle);
106 117
107acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout); 118acpi_status
119acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
120
121acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
122
123/*
124 * Mutex primitives
125 */
126acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
108 127
109acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units); 128void acpi_os_delete_mutex(acpi_mutex handle);
110 129
111acpi_status acpi_os_create_lock(acpi_handle * out_handle); 130acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
112 131
113void acpi_os_delete_lock(acpi_handle handle); 132void acpi_os_release_mutex(acpi_mutex handle);
114 133
115acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle); 134/* Temporary macros for Mutex* interfaces, map to existing semaphore xfaces */
116 135
117void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags); 136#define acpi_os_create_mutex(out_handle) acpi_os_create_semaphore (1, 1, out_handle)
137#define acpi_os_delete_mutex(handle) (void) acpi_os_delete_semaphore (handle)
138#define acpi_os_acquire_mutex(handle,time) acpi_os_wait_semaphore (handle, 1, time)
139#define acpi_os_release_mutex(handle) (void) acpi_os_signal_semaphore (handle, 1)
118 140
119/* 141/*
120 * Memory allocation and mapping 142 * Memory allocation and mapping
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 77cf1236b05a..64b603cfe92e 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -241,7 +241,7 @@ typedef acpi_native_uint acpi_size;
241 241
242/******************************************************************************* 242/*******************************************************************************
243 * 243 *
244 * OS- or compiler-dependent types 244 * OS-dependent and compiler-dependent types
245 * 245 *
246 * If the defaults below are not appropriate for the host system, they can 246 * If the defaults below are not appropriate for the host system, they can
247 * be defined in the compiler-specific or OS-specific header, and this will 247 * be defined in the compiler-specific or OS-specific header, and this will
@@ -249,29 +249,36 @@ typedef acpi_native_uint acpi_size;
249 * 249 *
250 ******************************************************************************/ 250 ******************************************************************************/
251 251
252/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ 252/* Value returned by acpi_os_get_thread_id */
253 253
254#ifndef acpi_uintptr_t 254#ifndef acpi_thread_id
255#define acpi_uintptr_t void * 255#define acpi_thread_id acpi_native_uint
256#endif 256#endif
257 257
258/* 258/* Object returned from acpi_os_create_lock */
259 * If acpi_cache_t was not defined in the OS-dependent header, 259
260 * define it now. This is typically the case where the local cache 260#ifndef acpi_spinlock
261 * manager implementation is to be used (ACPI_USE_LOCAL_CACHE) 261#define acpi_spinlock void *
262 */
263#ifndef acpi_cache_t
264#define acpi_cache_t struct acpi_memory_list
265#endif 262#endif
266 263
267/* 264/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */
268 * Allow the CPU flags word to be defined per-OS to simplify the use of the 265
269 * lock and unlock OSL interfaces.
270 */
271#ifndef acpi_cpu_flags 266#ifndef acpi_cpu_flags
272#define acpi_cpu_flags acpi_native_uint 267#define acpi_cpu_flags acpi_native_uint
273#endif 268#endif
274 269
270/* Object returned from acpi_os_create_cache */
271
272#ifndef acpi_cache_t
273#define acpi_cache_t struct acpi_memory_list
274#endif
275
276/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
277
278#ifndef acpi_uintptr_t
279#define acpi_uintptr_t void *
280#endif
281
275/* 282/*
276 * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because 283 * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because
277 * some compilers can catch printf format string problems 284 * some compilers can catch printf format string problems
@@ -298,13 +305,6 @@ typedef acpi_native_uint acpi_size;
298#define ACPI_EXPORT_SYMBOL(symbol) 305#define ACPI_EXPORT_SYMBOL(symbol)
299#endif 306#endif
300 307
301/*
302 * thread_id is returned by acpi_os_get_thread_id.
303 */
304#ifndef acpi_thread_id
305#define acpi_thread_id acpi_native_uint
306#endif
307
308/******************************************************************************* 308/*******************************************************************************
309 * 309 *
310 * Independent types 310 * Independent types
@@ -380,6 +380,11 @@ struct uint32_struct {
380 u32 hi; 380 u32 hi;
381}; 381};
382 382
383/* Synchronization objects */
384
385#define acpi_mutex void *
386#define acpi_semaphore void *
387
383/* 388/*
384 * Acpi integer width. In ACPI version 1, integers are 389 * Acpi integer width. In ACPI version 1, integers are
385 * 32 bits. In ACPI version 2, integers are 64 bits. 390 * 32 bits. In ACPI version 2, integers are 64 bits.
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 277d35bced03..3f853cabbd41 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -58,11 +58,13 @@
58#include <asm/div64.h> 58#include <asm/div64.h>
59#include <asm/acpi.h> 59#include <asm/acpi.h>
60#include <linux/slab.h> 60#include <linux/slab.h>
61#include <linux/spinlock_types.h>
61 62
62/* Host-dependent types and defines */ 63/* Host-dependent types and defines */
63 64
64#define ACPI_MACHINE_WIDTH BITS_PER_LONG 65#define ACPI_MACHINE_WIDTH BITS_PER_LONG
65#define acpi_cache_t kmem_cache_t 66#define acpi_cache_t kmem_cache_t
67#define acpi_spinlock spinlock_t *
66#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); 68#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
67#define strtoul simple_strtoul 69#define strtoul simple_strtoul
68 70
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 77371b3cdc44..9dd5b75961f8 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -62,6 +62,7 @@ struct acpi_processor_cx {
62 u32 latency_ticks; 62 u32 latency_ticks;
63 u32 power; 63 u32 power;
64 u32 usage; 64 u32 usage;
65 u64 time;
65 struct acpi_processor_cx_policy promotion; 66 struct acpi_processor_cx_policy promotion;
66 struct acpi_processor_cx_policy demotion; 67 struct acpi_processor_cx_policy demotion;
67}; 68};
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 466fbe9e4899..35e137636b0b 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -100,8 +100,10 @@ struct cpufreq_policy {
100#define CPUFREQ_INCOMPATIBLE (1) 100#define CPUFREQ_INCOMPATIBLE (1)
101#define CPUFREQ_NOTIFY (2) 101#define CPUFREQ_NOTIFY (2)
102 102
103#define CPUFREQ_SHARED_TYPE_ALL (0) /* All dependent CPUs should set freq */ 103#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
104#define CPUFREQ_SHARED_TYPE_ANY (1) /* Freq can be set from any dependent CPU */ 104#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
105#define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */
106#define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/
105 107
106/******************** cpufreq transition notifiers *******************/ 108/******************** cpufreq transition notifiers *******************/
107 109
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 2d229327959e..0503b2ed8bae 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -46,6 +46,8 @@ enum kobject_action {
46 KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices (broken) */ 46 KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices (broken) */
47 KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* device offline */ 47 KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* device offline */
48 KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* device online */ 48 KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* device online */
49 KOBJ_UNDOCK = (__force kobject_action_t) 0x08, /* undocking */
50 KOBJ_DOCK = (__force kobject_action_t) 0x09, /* dock */
49}; 51};
50 52
51struct kobject { 53struct kobject {
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 7f20e7b857cb..2b1530fc573b 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -50,6 +50,10 @@ static char *action_to_string(enum kobject_action action)
50 return "offline"; 50 return "offline";
51 case KOBJ_ONLINE: 51 case KOBJ_ONLINE:
52 return "online"; 52 return "online";
53 case KOBJ_DOCK:
54 return "dock";
55 case KOBJ_UNDOCK:
56 return "undock";
53 default: 57 default:
54 return NULL; 58 return NULL;
55 } 59 }