aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/events/evxface.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/events/evxface.c')
-rw-r--r--drivers/acpi/events/evxface.c446
1 files changed, 202 insertions, 244 deletions
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 4c1c25e316a8..43b33d19cdf9 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -49,8 +49,7 @@
49#include <acpi/acinterp.h> 49#include <acpi/acinterp.h>
50 50
51#define _COMPONENT ACPI_EVENTS 51#define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME ("evxface") 52ACPI_MODULE_NAME("evxface")
53
54 53
55/******************************************************************************* 54/*******************************************************************************
56 * 55 *
@@ -64,21 +63,16 @@
64 * DESCRIPTION: Saves the pointer to the handler function 63 * DESCRIPTION: Saves the pointer to the handler function
65 * 64 *
66 ******************************************************************************/ 65 ******************************************************************************/
67
68#ifdef ACPI_FUTURE_USAGE 66#ifdef ACPI_FUTURE_USAGE
69acpi_status 67acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
70acpi_install_exception_handler (
71 acpi_exception_handler handler)
72{ 68{
73 acpi_status status; 69 acpi_status status;
74
75 70
76 ACPI_FUNCTION_TRACE ("acpi_install_exception_handler"); 71 ACPI_FUNCTION_TRACE("acpi_install_exception_handler");
77 72
78 73 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
79 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 74 if (ACPI_FAILURE(status)) {
80 if (ACPI_FAILURE (status)) { 75 return_ACPI_STATUS(status);
81 return_ACPI_STATUS (status);
82 } 76 }
83 77
84 /* Don't allow two handlers. */ 78 /* Don't allow two handlers. */
@@ -92,12 +86,11 @@ acpi_install_exception_handler (
92 86
93 acpi_gbl_exception_handler = handler; 87 acpi_gbl_exception_handler = handler;
94 88
95cleanup: 89 cleanup:
96 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 90 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
97 return_ACPI_STATUS (status); 91 return_ACPI_STATUS(status);
98} 92}
99#endif /* ACPI_FUTURE_USAGE */ 93#endif /* ACPI_FUTURE_USAGE */
100
101 94
102/******************************************************************************* 95/*******************************************************************************
103 * 96 *
@@ -116,26 +109,22 @@ cleanup:
116 ******************************************************************************/ 109 ******************************************************************************/
117 110
118acpi_status 111acpi_status
119acpi_install_fixed_event_handler ( 112acpi_install_fixed_event_handler(u32 event,
120 u32 event, 113 acpi_event_handler handler, void *context)
121 acpi_event_handler handler,
122 void *context)
123{ 114{
124 acpi_status status; 115 acpi_status status;
125
126
127 ACPI_FUNCTION_TRACE ("acpi_install_fixed_event_handler");
128 116
117 ACPI_FUNCTION_TRACE("acpi_install_fixed_event_handler");
129 118
130 /* Parameter validation */ 119 /* Parameter validation */
131 120
132 if (event > ACPI_EVENT_MAX) { 121 if (event > ACPI_EVENT_MAX) {
133 return_ACPI_STATUS (AE_BAD_PARAMETER); 122 return_ACPI_STATUS(AE_BAD_PARAMETER);
134 } 123 }
135 124
136 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 125 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
137 if (ACPI_FAILURE (status)) { 126 if (ACPI_FAILURE(status)) {
138 return_ACPI_STATUS (status); 127 return_ACPI_STATUS(status);
139 } 128 }
140 129
141 /* Don't allow two handlers. */ 130 /* Don't allow two handlers. */
@@ -150,29 +139,29 @@ acpi_install_fixed_event_handler (
150 acpi_gbl_fixed_event_handlers[event].handler = handler; 139 acpi_gbl_fixed_event_handlers[event].handler = handler;
151 acpi_gbl_fixed_event_handlers[event].context = context; 140 acpi_gbl_fixed_event_handlers[event].context = context;
152 141
153 status = acpi_clear_event (event); 142 status = acpi_clear_event(event);
154 if (ACPI_SUCCESS(status)) 143 if (ACPI_SUCCESS(status))
155 status = acpi_enable_event (event, 0); 144 status = acpi_enable_event(event, 0);
156 if (ACPI_FAILURE (status)) { 145 if (ACPI_FAILURE(status)) {
157 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n")); 146 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
147 "Could not enable fixed event.\n"));
158 148
159 /* Remove the handler */ 149 /* Remove the handler */
160 150
161 acpi_gbl_fixed_event_handlers[event].handler = NULL; 151 acpi_gbl_fixed_event_handlers[event].handler = NULL;
162 acpi_gbl_fixed_event_handlers[event].context = NULL; 152 acpi_gbl_fixed_event_handlers[event].context = NULL;
163 } 153 } else {
164 else { 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
165 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 155 "Enabled fixed event %X, Handler=%p\n", event,
166 "Enabled fixed event %X, Handler=%p\n", event, handler)); 156 handler));
167 } 157 }
168 158
169 159 cleanup:
170cleanup: 160 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
171 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 161 return_ACPI_STATUS(status);
172 return_ACPI_STATUS (status);
173} 162}
174EXPORT_SYMBOL(acpi_install_fixed_event_handler);
175 163
164EXPORT_SYMBOL(acpi_install_fixed_event_handler);
176 165
177/******************************************************************************* 166/*******************************************************************************
178 * 167 *
@@ -188,49 +177,45 @@ EXPORT_SYMBOL(acpi_install_fixed_event_handler);
188 ******************************************************************************/ 177 ******************************************************************************/
189 178
190acpi_status 179acpi_status
191acpi_remove_fixed_event_handler ( 180acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
192 u32 event,
193 acpi_event_handler handler)
194{ 181{
195 acpi_status status = AE_OK; 182 acpi_status status = AE_OK;
196
197
198 ACPI_FUNCTION_TRACE ("acpi_remove_fixed_event_handler");
199 183
184 ACPI_FUNCTION_TRACE("acpi_remove_fixed_event_handler");
200 185
201 /* Parameter validation */ 186 /* Parameter validation */
202 187
203 if (event > ACPI_EVENT_MAX) { 188 if (event > ACPI_EVENT_MAX) {
204 return_ACPI_STATUS (AE_BAD_PARAMETER); 189 return_ACPI_STATUS(AE_BAD_PARAMETER);
205 } 190 }
206 191
207 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 192 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
208 if (ACPI_FAILURE (status)) { 193 if (ACPI_FAILURE(status)) {
209 return_ACPI_STATUS (status); 194 return_ACPI_STATUS(status);
210 } 195 }
211 196
212 /* Disable the event before removing the handler */ 197 /* Disable the event before removing the handler */
213 198
214 status = acpi_disable_event (event, 0); 199 status = acpi_disable_event(event, 0);
215 200
216 /* Always Remove the handler */ 201 /* Always Remove the handler */
217 202
218 acpi_gbl_fixed_event_handlers[event].handler = NULL; 203 acpi_gbl_fixed_event_handlers[event].handler = NULL;
219 acpi_gbl_fixed_event_handlers[event].context = NULL; 204 acpi_gbl_fixed_event_handlers[event].context = NULL;
220 205
221 if (ACPI_FAILURE (status)) { 206 if (ACPI_FAILURE(status)) {
222 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 207 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
223 "Could not write to fixed event enable register.\n")); 208 "Could not write to fixed event enable register.\n"));
224 } 209 } else {
225 else { 210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n",
226 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", event)); 211 event));
227 } 212 }
228 213
229 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 214 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
230 return_ACPI_STATUS (status); 215 return_ACPI_STATUS(status);
231} 216}
232EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
233 217
218EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
234 219
235/******************************************************************************* 220/*******************************************************************************
236 * 221 *
@@ -251,37 +236,32 @@ EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
251 ******************************************************************************/ 236 ******************************************************************************/
252 237
253acpi_status 238acpi_status
254acpi_install_notify_handler ( 239acpi_install_notify_handler(acpi_handle device,
255 acpi_handle device, 240 u32 handler_type,
256 u32 handler_type, 241 acpi_notify_handler handler, void *context)
257 acpi_notify_handler handler,
258 void *context)
259{ 242{
260 union acpi_operand_object *obj_desc; 243 union acpi_operand_object *obj_desc;
261 union acpi_operand_object *notify_obj; 244 union acpi_operand_object *notify_obj;
262 struct acpi_namespace_node *node; 245 struct acpi_namespace_node *node;
263 acpi_status status; 246 acpi_status status;
264
265
266 ACPI_FUNCTION_TRACE ("acpi_install_notify_handler");
267 247
248 ACPI_FUNCTION_TRACE("acpi_install_notify_handler");
268 249
269 /* Parameter validation */ 250 /* Parameter validation */
270 251
271 if ((!device) || 252 if ((!device) ||
272 (!handler) || 253 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
273 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 254 return_ACPI_STATUS(AE_BAD_PARAMETER);
274 return_ACPI_STATUS (AE_BAD_PARAMETER);
275 } 255 }
276 256
277 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 257 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
278 if (ACPI_FAILURE (status)) { 258 if (ACPI_FAILURE(status)) {
279 return_ACPI_STATUS (status); 259 return_ACPI_STATUS(status);
280 } 260 }
281 261
282 /* Convert and validate the device handle */ 262 /* Convert and validate the device handle */
283 263
284 node = acpi_ns_map_handle_to_node (device); 264 node = acpi_ns_map_handle_to_node(device);
285 if (!node) { 265 if (!node) {
286 status = AE_BAD_PARAMETER; 266 status = AE_BAD_PARAMETER;
287 goto unlock_and_exit; 267 goto unlock_and_exit;
@@ -297,21 +277,21 @@ acpi_install_notify_handler (
297 /* Make sure the handler is not already installed */ 277 /* Make sure the handler is not already installed */
298 278
299 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 279 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
300 acpi_gbl_system_notify.handler) || 280 acpi_gbl_system_notify.handler) ||
301 ((handler_type & ACPI_DEVICE_NOTIFY) && 281 ((handler_type & ACPI_DEVICE_NOTIFY) &&
302 acpi_gbl_device_notify.handler)) { 282 acpi_gbl_device_notify.handler)) {
303 status = AE_ALREADY_EXISTS; 283 status = AE_ALREADY_EXISTS;
304 goto unlock_and_exit; 284 goto unlock_and_exit;
305 } 285 }
306 286
307 if (handler_type & ACPI_SYSTEM_NOTIFY) { 287 if (handler_type & ACPI_SYSTEM_NOTIFY) {
308 acpi_gbl_system_notify.node = node; 288 acpi_gbl_system_notify.node = node;
309 acpi_gbl_system_notify.handler = handler; 289 acpi_gbl_system_notify.handler = handler;
310 acpi_gbl_system_notify.context = context; 290 acpi_gbl_system_notify.context = context;
311 } 291 }
312 292
313 if (handler_type & ACPI_DEVICE_NOTIFY) { 293 if (handler_type & ACPI_DEVICE_NOTIFY) {
314 acpi_gbl_device_notify.node = node; 294 acpi_gbl_device_notify.node = node;
315 acpi_gbl_device_notify.handler = handler; 295 acpi_gbl_device_notify.handler = handler;
316 acpi_gbl_device_notify.context = context; 296 acpi_gbl_device_notify.context = context;
317 } 297 }
@@ -327,29 +307,28 @@ acpi_install_notify_handler (
327 else { 307 else {
328 /* Notifies allowed on this object? */ 308 /* Notifies allowed on this object? */
329 309
330 if (!acpi_ev_is_notify_object (node)) { 310 if (!acpi_ev_is_notify_object(node)) {
331 status = AE_TYPE; 311 status = AE_TYPE;
332 goto unlock_and_exit; 312 goto unlock_and_exit;
333 } 313 }
334 314
335 /* Check for an existing internal object */ 315 /* Check for an existing internal object */
336 316
337 obj_desc = acpi_ns_get_attached_object (node); 317 obj_desc = acpi_ns_get_attached_object(node);
338 if (obj_desc) { 318 if (obj_desc) {
339 /* Object exists - make sure there's no handler */ 319 /* Object exists - make sure there's no handler */
340 320
341 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 321 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
342 obj_desc->common_notify.system_notify) || 322 obj_desc->common_notify.system_notify) ||
343 ((handler_type & ACPI_DEVICE_NOTIFY) && 323 ((handler_type & ACPI_DEVICE_NOTIFY) &&
344 obj_desc->common_notify.device_notify)) { 324 obj_desc->common_notify.device_notify)) {
345 status = AE_ALREADY_EXISTS; 325 status = AE_ALREADY_EXISTS;
346 goto unlock_and_exit; 326 goto unlock_and_exit;
347 } 327 }
348 } 328 } else {
349 else {
350 /* Create a new object */ 329 /* Create a new object */
351 330
352 obj_desc = acpi_ut_create_internal_object (node->type); 331 obj_desc = acpi_ut_create_internal_object(node->type);
353 if (!obj_desc) { 332 if (!obj_desc) {
354 status = AE_NO_MEMORY; 333 status = AE_NO_MEMORY;
355 goto unlock_and_exit; 334 goto unlock_and_exit;
@@ -357,25 +336,27 @@ acpi_install_notify_handler (
357 336
358 /* Attach new object to the Node */ 337 /* Attach new object to the Node */
359 338
360 status = acpi_ns_attach_object (device, obj_desc, node->type); 339 status =
340 acpi_ns_attach_object(device, obj_desc, node->type);
361 341
362 /* Remove local reference to the object */ 342 /* Remove local reference to the object */
363 343
364 acpi_ut_remove_reference (obj_desc); 344 acpi_ut_remove_reference(obj_desc);
365 if (ACPI_FAILURE (status)) { 345 if (ACPI_FAILURE(status)) {
366 goto unlock_and_exit; 346 goto unlock_and_exit;
367 } 347 }
368 } 348 }
369 349
370 /* Install the handler */ 350 /* Install the handler */
371 351
372 notify_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_NOTIFY); 352 notify_obj =
353 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_NOTIFY);
373 if (!notify_obj) { 354 if (!notify_obj) {
374 status = AE_NO_MEMORY; 355 status = AE_NO_MEMORY;
375 goto unlock_and_exit; 356 goto unlock_and_exit;
376 } 357 }
377 358
378 notify_obj->notify.node = node; 359 notify_obj->notify.node = node;
379 notify_obj->notify.handler = handler; 360 notify_obj->notify.handler = handler;
380 notify_obj->notify.context = context; 361 notify_obj->notify.context = context;
381 362
@@ -390,17 +371,16 @@ acpi_install_notify_handler (
390 if (handler_type == ACPI_ALL_NOTIFY) { 371 if (handler_type == ACPI_ALL_NOTIFY) {
391 /* Extra ref if installed in both */ 372 /* Extra ref if installed in both */
392 373
393 acpi_ut_add_reference (notify_obj); 374 acpi_ut_add_reference(notify_obj);
394 } 375 }
395 } 376 }
396 377
397 378 unlock_and_exit:
398unlock_and_exit: 379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
399 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 380 return_ACPI_STATUS(status);
400 return_ACPI_STATUS (status);
401} 381}
402EXPORT_SYMBOL(acpi_install_notify_handler);
403 382
383EXPORT_SYMBOL(acpi_install_notify_handler);
404 384
405/******************************************************************************* 385/*******************************************************************************
406 * 386 *
@@ -420,36 +400,31 @@ EXPORT_SYMBOL(acpi_install_notify_handler);
420 ******************************************************************************/ 400 ******************************************************************************/
421 401
422acpi_status 402acpi_status
423acpi_remove_notify_handler ( 403acpi_remove_notify_handler(acpi_handle device,
424 acpi_handle device, 404 u32 handler_type, acpi_notify_handler handler)
425 u32 handler_type,
426 acpi_notify_handler handler)
427{ 405{
428 union acpi_operand_object *notify_obj; 406 union acpi_operand_object *notify_obj;
429 union acpi_operand_object *obj_desc; 407 union acpi_operand_object *obj_desc;
430 struct acpi_namespace_node *node; 408 struct acpi_namespace_node *node;
431 acpi_status status; 409 acpi_status status;
432
433
434 ACPI_FUNCTION_TRACE ("acpi_remove_notify_handler");
435 410
411 ACPI_FUNCTION_TRACE("acpi_remove_notify_handler");
436 412
437 /* Parameter validation */ 413 /* Parameter validation */
438 414
439 if ((!device) || 415 if ((!device) ||
440 (!handler) || 416 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
441 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 417 return_ACPI_STATUS(AE_BAD_PARAMETER);
442 return_ACPI_STATUS (AE_BAD_PARAMETER);
443 } 418 }
444 419
445 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 420 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
446 if (ACPI_FAILURE (status)) { 421 if (ACPI_FAILURE(status)) {
447 return_ACPI_STATUS (status); 422 return_ACPI_STATUS(status);
448 } 423 }
449 424
450 /* Convert and validate the device handle */ 425 /* Convert and validate the device handle */
451 426
452 node = acpi_ns_map_handle_to_node (device); 427 node = acpi_ns_map_handle_to_node(device);
453 if (!node) { 428 if (!node) {
454 status = AE_BAD_PARAMETER; 429 status = AE_BAD_PARAMETER;
455 goto unlock_and_exit; 430 goto unlock_and_exit;
@@ -458,34 +433,34 @@ acpi_remove_notify_handler (
458 /* Root Object */ 433 /* Root Object */
459 434
460 if (device == ACPI_ROOT_OBJECT) { 435 if (device == ACPI_ROOT_OBJECT) {
461 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 436 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
462 "Removing notify handler for ROOT object.\n")); 437 "Removing notify handler for ROOT object.\n"));
463 438
464 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 439 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
465 !acpi_gbl_system_notify.handler) || 440 !acpi_gbl_system_notify.handler) ||
466 ((handler_type & ACPI_DEVICE_NOTIFY) && 441 ((handler_type & ACPI_DEVICE_NOTIFY) &&
467 !acpi_gbl_device_notify.handler)) { 442 !acpi_gbl_device_notify.handler)) {
468 status = AE_NOT_EXIST; 443 status = AE_NOT_EXIST;
469 goto unlock_and_exit; 444 goto unlock_and_exit;
470 } 445 }
471 446
472 /* Make sure all deferred tasks are completed */ 447 /* Make sure all deferred tasks are completed */
473 448
474 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 449 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
475 acpi_os_wait_events_complete(NULL); 450 acpi_os_wait_events_complete(NULL);
476 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 451 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
477 if (ACPI_FAILURE (status)) { 452 if (ACPI_FAILURE(status)) {
478 return_ACPI_STATUS (status); 453 return_ACPI_STATUS(status);
479 } 454 }
480 455
481 if (handler_type & ACPI_SYSTEM_NOTIFY) { 456 if (handler_type & ACPI_SYSTEM_NOTIFY) {
482 acpi_gbl_system_notify.node = NULL; 457 acpi_gbl_system_notify.node = NULL;
483 acpi_gbl_system_notify.handler = NULL; 458 acpi_gbl_system_notify.handler = NULL;
484 acpi_gbl_system_notify.context = NULL; 459 acpi_gbl_system_notify.context = NULL;
485 } 460 }
486 461
487 if (handler_type & ACPI_DEVICE_NOTIFY) { 462 if (handler_type & ACPI_DEVICE_NOTIFY) {
488 acpi_gbl_device_notify.node = NULL; 463 acpi_gbl_device_notify.node = NULL;
489 acpi_gbl_device_notify.handler = NULL; 464 acpi_gbl_device_notify.handler = NULL;
490 acpi_gbl_device_notify.context = NULL; 465 acpi_gbl_device_notify.context = NULL;
491 } 466 }
@@ -496,14 +471,14 @@ acpi_remove_notify_handler (
496 else { 471 else {
497 /* Notifies allowed on this object? */ 472 /* Notifies allowed on this object? */
498 473
499 if (!acpi_ev_is_notify_object (node)) { 474 if (!acpi_ev_is_notify_object(node)) {
500 status = AE_TYPE; 475 status = AE_TYPE;
501 goto unlock_and_exit; 476 goto unlock_and_exit;
502 } 477 }
503 478
504 /* Check for an existing internal object */ 479 /* Check for an existing internal object */
505 480
506 obj_desc = acpi_ns_get_attached_object (node); 481 obj_desc = acpi_ns_get_attached_object(node);
507 if (!obj_desc) { 482 if (!obj_desc) {
508 status = AE_NOT_EXIST; 483 status = AE_NOT_EXIST;
509 goto unlock_and_exit; 484 goto unlock_and_exit;
@@ -514,53 +489,52 @@ acpi_remove_notify_handler (
514 if (handler_type & ACPI_SYSTEM_NOTIFY) { 489 if (handler_type & ACPI_SYSTEM_NOTIFY) {
515 notify_obj = obj_desc->common_notify.system_notify; 490 notify_obj = obj_desc->common_notify.system_notify;
516 if ((!notify_obj) || 491 if ((!notify_obj) ||
517 (notify_obj->notify.handler != handler)) { 492 (notify_obj->notify.handler != handler)) {
518 status = AE_BAD_PARAMETER; 493 status = AE_BAD_PARAMETER;
519 goto unlock_and_exit; 494 goto unlock_and_exit;
520 } 495 }
521 /* Make sure all deferred tasks are completed */ 496 /* Make sure all deferred tasks are completed */
522 497
523 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 498 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
524 acpi_os_wait_events_complete(NULL); 499 acpi_os_wait_events_complete(NULL);
525 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 500 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
526 if (ACPI_FAILURE (status)) { 501 if (ACPI_FAILURE(status)) {
527 return_ACPI_STATUS (status); 502 return_ACPI_STATUS(status);
528 } 503 }
529 504
530 /* Remove the handler */ 505 /* Remove the handler */
531 obj_desc->common_notify.system_notify = NULL; 506 obj_desc->common_notify.system_notify = NULL;
532 acpi_ut_remove_reference (notify_obj); 507 acpi_ut_remove_reference(notify_obj);
533 } 508 }
534 509
535 if (handler_type & ACPI_DEVICE_NOTIFY) { 510 if (handler_type & ACPI_DEVICE_NOTIFY) {
536 notify_obj = obj_desc->common_notify.device_notify; 511 notify_obj = obj_desc->common_notify.device_notify;
537 if ((!notify_obj) || 512 if ((!notify_obj) ||
538 (notify_obj->notify.handler != handler)) { 513 (notify_obj->notify.handler != handler)) {
539 status = AE_BAD_PARAMETER; 514 status = AE_BAD_PARAMETER;
540 goto unlock_and_exit; 515 goto unlock_and_exit;
541 } 516 }
542 /* Make sure all deferred tasks are completed */ 517 /* Make sure all deferred tasks are completed */
543 518
544 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 519 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
545 acpi_os_wait_events_complete(NULL); 520 acpi_os_wait_events_complete(NULL);
546 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 521 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
547 if (ACPI_FAILURE (status)) { 522 if (ACPI_FAILURE(status)) {
548 return_ACPI_STATUS (status); 523 return_ACPI_STATUS(status);
549 } 524 }
550 525
551 /* Remove the handler */ 526 /* Remove the handler */
552 obj_desc->common_notify.device_notify = NULL; 527 obj_desc->common_notify.device_notify = NULL;
553 acpi_ut_remove_reference (notify_obj); 528 acpi_ut_remove_reference(notify_obj);
554 } 529 }
555 } 530 }
556 531
557 532 unlock_and_exit:
558unlock_and_exit: 533 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
559 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 534 return_ACPI_STATUS(status);
560 return_ACPI_STATUS (status);
561} 535}
562EXPORT_SYMBOL(acpi_remove_notify_handler);
563 536
537EXPORT_SYMBOL(acpi_remove_notify_handler);
564 538
565/******************************************************************************* 539/*******************************************************************************
566 * 540 *
@@ -581,36 +555,31 @@ EXPORT_SYMBOL(acpi_remove_notify_handler);
581 ******************************************************************************/ 555 ******************************************************************************/
582 556
583acpi_status 557acpi_status
584acpi_install_gpe_handler ( 558acpi_install_gpe_handler(acpi_handle gpe_device,
585 acpi_handle gpe_device, 559 u32 gpe_number,
586 u32 gpe_number, 560 u32 type, acpi_event_handler address, void *context)
587 u32 type,
588 acpi_event_handler address,
589 void *context)
590{ 561{
591 struct acpi_gpe_event_info *gpe_event_info; 562 struct acpi_gpe_event_info *gpe_event_info;
592 struct acpi_handler_info *handler; 563 struct acpi_handler_info *handler;
593 acpi_status status; 564 acpi_status status;
594 u32 flags; 565 u32 flags;
595
596
597 ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
598 566
567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
599 568
600 /* Parameter validation */ 569 /* Parameter validation */
601 570
602 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { 571 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
603 return_ACPI_STATUS (AE_BAD_PARAMETER); 572 return_ACPI_STATUS(AE_BAD_PARAMETER);
604 } 573 }
605 574
606 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 575 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
607 if (ACPI_FAILURE (status)) { 576 if (ACPI_FAILURE(status)) {
608 return_ACPI_STATUS (status); 577 return_ACPI_STATUS(status);
609 } 578 }
610 579
611 /* Ensure that we have a valid GPE number */ 580 /* Ensure that we have a valid GPE number */
612 581
613 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 582 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
614 if (!gpe_event_info) { 583 if (!gpe_event_info) {
615 status = AE_BAD_PARAMETER; 584 status = AE_BAD_PARAMETER;
616 goto unlock_and_exit; 585 goto unlock_and_exit;
@@ -618,49 +587,49 @@ acpi_install_gpe_handler (
618 587
619 /* Make sure that there isn't a handler there already */ 588 /* Make sure that there isn't a handler there already */
620 589
621 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { 590 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
591 ACPI_GPE_DISPATCH_HANDLER) {
622 status = AE_ALREADY_EXISTS; 592 status = AE_ALREADY_EXISTS;
623 goto unlock_and_exit; 593 goto unlock_and_exit;
624 } 594 }
625 595
626 /* Allocate and init handler object */ 596 /* Allocate and init handler object */
627 597
628 handler = ACPI_MEM_CALLOCATE (sizeof (struct acpi_handler_info)); 598 handler = ACPI_MEM_CALLOCATE(sizeof(struct acpi_handler_info));
629 if (!handler) { 599 if (!handler) {
630 status = AE_NO_MEMORY; 600 status = AE_NO_MEMORY;
631 goto unlock_and_exit; 601 goto unlock_and_exit;
632 } 602 }
633 603
634 handler->address = address; 604 handler->address = address;
635 handler->context = context; 605 handler->context = context;
636 handler->method_node = gpe_event_info->dispatch.method_node; 606 handler->method_node = gpe_event_info->dispatch.method_node;
637 607
638 /* Disable the GPE before installing the handler */ 608 /* Disable the GPE before installing the handler */
639 609
640 status = acpi_ev_disable_gpe (gpe_event_info); 610 status = acpi_ev_disable_gpe(gpe_event_info);
641 if (ACPI_FAILURE (status)) { 611 if (ACPI_FAILURE(status)) {
642 goto unlock_and_exit; 612 goto unlock_and_exit;
643 } 613 }
644 614
645 /* Install the handler */ 615 /* Install the handler */
646 616
647 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 617 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
648 gpe_event_info->dispatch.handler = handler; 618 gpe_event_info->dispatch.handler = handler;
649 619
650 /* Setup up dispatch flags to indicate handler (vs. method) */ 620 /* Setup up dispatch flags to indicate handler (vs. method) */
651 621
652 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ 622 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
653 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); 623 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
654 624
655 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 625 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
656
657 626
658unlock_and_exit: 627 unlock_and_exit:
659 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 628 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
660 return_ACPI_STATUS (status); 629 return_ACPI_STATUS(status);
661} 630}
662EXPORT_SYMBOL(acpi_install_gpe_handler);
663 631
632EXPORT_SYMBOL(acpi_install_gpe_handler);
664 633
665/******************************************************************************* 634/*******************************************************************************
666 * 635 *
@@ -678,34 +647,30 @@ EXPORT_SYMBOL(acpi_install_gpe_handler);
678 ******************************************************************************/ 647 ******************************************************************************/
679 648
680acpi_status 649acpi_status
681acpi_remove_gpe_handler ( 650acpi_remove_gpe_handler(acpi_handle gpe_device,
682 acpi_handle gpe_device, 651 u32 gpe_number, acpi_event_handler address)
683 u32 gpe_number,
684 acpi_event_handler address)
685{ 652{
686 struct acpi_gpe_event_info *gpe_event_info; 653 struct acpi_gpe_event_info *gpe_event_info;
687 struct acpi_handler_info *handler; 654 struct acpi_handler_info *handler;
688 acpi_status status; 655 acpi_status status;
689 u32 flags; 656 u32 flags;
690
691
692 ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
693 657
658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
694 659
695 /* Parameter validation */ 660 /* Parameter validation */
696 661
697 if (!address) { 662 if (!address) {
698 return_ACPI_STATUS (AE_BAD_PARAMETER); 663 return_ACPI_STATUS(AE_BAD_PARAMETER);
699 } 664 }
700 665
701 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 666 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
702 if (ACPI_FAILURE (status)) { 667 if (ACPI_FAILURE(status)) {
703 return_ACPI_STATUS (status); 668 return_ACPI_STATUS(status);
704 } 669 }
705 670
706 /* Ensure that we have a valid GPE number */ 671 /* Ensure that we have a valid GPE number */
707 672
708 gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number); 673 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
709 if (!gpe_event_info) { 674 if (!gpe_event_info) {
710 status = AE_BAD_PARAMETER; 675 status = AE_BAD_PARAMETER;
711 goto unlock_and_exit; 676 goto unlock_and_exit;
@@ -713,7 +678,8 @@ acpi_remove_gpe_handler (
713 678
714 /* Make sure that a handler is indeed installed */ 679 /* Make sure that a handler is indeed installed */
715 680
716 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) { 681 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
682 ACPI_GPE_DISPATCH_HANDLER) {
717 status = AE_NOT_EXIST; 683 status = AE_NOT_EXIST;
718 goto unlock_and_exit; 684 goto unlock_and_exit;
719 } 685 }
@@ -727,45 +693,44 @@ acpi_remove_gpe_handler (
727 693
728 /* Disable the GPE before removing the handler */ 694 /* Disable the GPE before removing the handler */
729 695
730 status = acpi_ev_disable_gpe (gpe_event_info); 696 status = acpi_ev_disable_gpe(gpe_event_info);
731 if (ACPI_FAILURE (status)) { 697 if (ACPI_FAILURE(status)) {
732 goto unlock_and_exit; 698 goto unlock_and_exit;
733 } 699 }
734 700
735 /* Make sure all deferred tasks are completed */ 701 /* Make sure all deferred tasks are completed */
736 702
737 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 703 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
738 acpi_os_wait_events_complete(NULL); 704 acpi_os_wait_events_complete(NULL);
739 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS); 705 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
740 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE(status)) {
741 return_ACPI_STATUS (status); 707 return_ACPI_STATUS(status);
742 } 708 }
743 709
744 /* Remove the handler */ 710 /* Remove the handler */
745 711
746 flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); 712 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
747 handler = gpe_event_info->dispatch.handler; 713 handler = gpe_event_info->dispatch.handler;
748 714
749 /* Restore Method node (if any), set dispatch flags */ 715 /* Restore Method node (if any), set dispatch flags */
750 716
751 gpe_event_info->dispatch.method_node = handler->method_node; 717 gpe_event_info->dispatch.method_node = handler->method_node;
752 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ 718 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */
753 if (handler->method_node) { 719 if (handler->method_node) {
754 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; 720 gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD;
755 } 721 }
756 acpi_os_release_lock (acpi_gbl_gpe_lock, flags); 722 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
757 723
758 /* Now we can free the handler object */ 724 /* Now we can free the handler object */
759 725
760 ACPI_MEM_FREE (handler); 726 ACPI_MEM_FREE(handler);
761 727
762 728 unlock_and_exit:
763unlock_and_exit: 729 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
764 (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS); 730 return_ACPI_STATUS(status);
765 return_ACPI_STATUS (status);
766} 731}
767EXPORT_SYMBOL(acpi_remove_gpe_handler);
768 732
733EXPORT_SYMBOL(acpi_remove_gpe_handler);
769 734
770/******************************************************************************* 735/*******************************************************************************
771 * 736 *
@@ -781,35 +746,31 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler);
781 * 746 *
782 ******************************************************************************/ 747 ******************************************************************************/
783 748
784acpi_status 749acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle)
785acpi_acquire_global_lock (
786 u16 timeout,
787 u32 *handle)
788{ 750{
789 acpi_status status; 751 acpi_status status;
790
791 752
792 if (!handle) { 753 if (!handle) {
793 return (AE_BAD_PARAMETER); 754 return (AE_BAD_PARAMETER);
794 } 755 }
795 756
796 status = acpi_ex_enter_interpreter (); 757 status = acpi_ex_enter_interpreter();
797 if (ACPI_FAILURE (status)) { 758 if (ACPI_FAILURE(status)) {
798 return (status); 759 return (status);
799 } 760 }
800 761
801 status = acpi_ev_acquire_global_lock (timeout); 762 status = acpi_ev_acquire_global_lock(timeout);
802 acpi_ex_exit_interpreter (); 763 acpi_ex_exit_interpreter();
803 764
804 if (ACPI_SUCCESS (status)) { 765 if (ACPI_SUCCESS(status)) {
805 acpi_gbl_global_lock_handle++; 766 acpi_gbl_global_lock_handle++;
806 *handle = acpi_gbl_global_lock_handle; 767 *handle = acpi_gbl_global_lock_handle;
807 } 768 }
808 769
809 return (status); 770 return (status);
810} 771}
811EXPORT_SYMBOL(acpi_acquire_global_lock);
812 772
773EXPORT_SYMBOL(acpi_acquire_global_lock);
813 774
814/******************************************************************************* 775/*******************************************************************************
815 * 776 *
@@ -823,19 +784,16 @@ EXPORT_SYMBOL(acpi_acquire_global_lock);
823 * 784 *
824 ******************************************************************************/ 785 ******************************************************************************/
825 786
826acpi_status 787acpi_status acpi_release_global_lock(u32 handle)
827acpi_release_global_lock (
828 u32 handle)
829{ 788{
830 acpi_status status; 789 acpi_status status;
831
832 790
833 if (handle != acpi_gbl_global_lock_handle) { 791 if (handle != acpi_gbl_global_lock_handle) {
834 return (AE_NOT_ACQUIRED); 792 return (AE_NOT_ACQUIRED);
835 } 793 }
836 794
837 status = acpi_ev_release_global_lock (); 795 status = acpi_ev_release_global_lock();
838 return (status); 796 return (status);
839} 797}
840EXPORT_SYMBOL(acpi_release_global_lock);
841 798
799EXPORT_SYMBOL(acpi_release_global_lock);