diff options
Diffstat (limited to 'drivers/acpi/acpica/evxface.c')
| -rw-r--r-- | drivers/acpi/acpica/evxface.c | 436 |
1 files changed, 220 insertions, 216 deletions
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c index 61944e89565a..44bef5744ebb 100644 --- a/drivers/acpi/acpica/evxface.c +++ b/drivers/acpi/acpica/evxface.c | |||
| @@ -51,222 +51,6 @@ | |||
| 51 | #define _COMPONENT ACPI_EVENTS | 51 | #define _COMPONENT ACPI_EVENTS |
| 52 | ACPI_MODULE_NAME("evxface") | 52 | ACPI_MODULE_NAME("evxface") |
| 53 | 53 | ||
| 54 | /******************************************************************************* | ||
| 55 | * | ||
| 56 | * FUNCTION: acpi_install_exception_handler | ||
| 57 | * | ||
| 58 | * PARAMETERS: Handler - Pointer to the handler function for the | ||
| 59 | * event | ||
| 60 | * | ||
| 61 | * RETURN: Status | ||
| 62 | * | ||
| 63 | * DESCRIPTION: Saves the pointer to the handler function | ||
| 64 | * | ||
| 65 | ******************************************************************************/ | ||
| 66 | #ifdef ACPI_FUTURE_USAGE | ||
| 67 | acpi_status acpi_install_exception_handler(acpi_exception_handler handler) | ||
| 68 | { | ||
| 69 | acpi_status status; | ||
| 70 | |||
| 71 | ACPI_FUNCTION_TRACE(acpi_install_exception_handler); | ||
| 72 | |||
| 73 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 74 | if (ACPI_FAILURE(status)) { | ||
| 75 | return_ACPI_STATUS(status); | ||
| 76 | } | ||
| 77 | |||
| 78 | /* Don't allow two handlers. */ | ||
| 79 | |||
| 80 | if (acpi_gbl_exception_handler) { | ||
| 81 | status = AE_ALREADY_EXISTS; | ||
| 82 | goto cleanup; | ||
| 83 | } | ||
| 84 | |||
| 85 | /* Install the handler */ | ||
| 86 | |||
| 87 | acpi_gbl_exception_handler = handler; | ||
| 88 | |||
| 89 | cleanup: | ||
| 90 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 91 | return_ACPI_STATUS(status); | ||
| 92 | } | ||
| 93 | |||
| 94 | ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) | ||
| 95 | #endif /* ACPI_FUTURE_USAGE */ | ||
| 96 | |||
| 97 | /******************************************************************************* | ||
| 98 | * | ||
| 99 | * FUNCTION: acpi_install_global_event_handler | ||
| 100 | * | ||
| 101 | * PARAMETERS: Handler - Pointer to the global event handler function | ||
| 102 | * Context - Value passed to the handler on each event | ||
| 103 | * | ||
| 104 | * RETURN: Status | ||
| 105 | * | ||
| 106 | * DESCRIPTION: Saves the pointer to the handler function. The global handler | ||
| 107 | * is invoked upon each incoming GPE and Fixed Event. It is | ||
| 108 | * invoked at interrupt level at the time of the event dispatch. | ||
| 109 | * Can be used to update event counters, etc. | ||
| 110 | * | ||
| 111 | ******************************************************************************/ | ||
| 112 | acpi_status | ||
| 113 | acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context) | ||
| 114 | { | ||
| 115 | acpi_status status; | ||
| 116 | |||
| 117 | ACPI_FUNCTION_TRACE(acpi_install_global_event_handler); | ||
| 118 | |||
| 119 | /* Parameter validation */ | ||
| 120 | |||
| 121 | if (!handler) { | ||
| 122 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 123 | } | ||
| 124 | |||
| 125 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 126 | if (ACPI_FAILURE(status)) { | ||
| 127 | return_ACPI_STATUS(status); | ||
| 128 | } | ||
| 129 | |||
| 130 | /* Don't allow two handlers. */ | ||
| 131 | |||
| 132 | if (acpi_gbl_global_event_handler) { | ||
| 133 | status = AE_ALREADY_EXISTS; | ||
| 134 | goto cleanup; | ||
| 135 | } | ||
| 136 | |||
| 137 | acpi_gbl_global_event_handler = handler; | ||
| 138 | acpi_gbl_global_event_handler_context = context; | ||
| 139 | |||
| 140 | cleanup: | ||
| 141 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 142 | return_ACPI_STATUS(status); | ||
| 143 | } | ||
| 144 | |||
| 145 | ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler) | ||
| 146 | |||
| 147 | /******************************************************************************* | ||
| 148 | * | ||
| 149 | * FUNCTION: acpi_install_fixed_event_handler | ||
| 150 | * | ||
| 151 | * PARAMETERS: Event - Event type to enable. | ||
| 152 | * Handler - Pointer to the handler function for the | ||
| 153 | * event | ||
| 154 | * Context - Value passed to the handler on each GPE | ||
| 155 | * | ||
| 156 | * RETURN: Status | ||
| 157 | * | ||
| 158 | * DESCRIPTION: Saves the pointer to the handler function and then enables the | ||
| 159 | * event. | ||
| 160 | * | ||
| 161 | ******************************************************************************/ | ||
| 162 | acpi_status | ||
| 163 | acpi_install_fixed_event_handler(u32 event, | ||
| 164 | acpi_event_handler handler, void *context) | ||
| 165 | { | ||
| 166 | acpi_status status; | ||
| 167 | |||
| 168 | ACPI_FUNCTION_TRACE(acpi_install_fixed_event_handler); | ||
| 169 | |||
| 170 | /* Parameter validation */ | ||
| 171 | |||
| 172 | if (event > ACPI_EVENT_MAX) { | ||
| 173 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 174 | } | ||
| 175 | |||
| 176 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 177 | if (ACPI_FAILURE(status)) { | ||
| 178 | return_ACPI_STATUS(status); | ||
| 179 | } | ||
| 180 | |||
| 181 | /* Don't allow two handlers. */ | ||
| 182 | |||
| 183 | if (NULL != acpi_gbl_fixed_event_handlers[event].handler) { | ||
| 184 | status = AE_ALREADY_EXISTS; | ||
| 185 | goto cleanup; | ||
| 186 | } | ||
| 187 | |||
| 188 | /* Install the handler before enabling the event */ | ||
| 189 | |||
| 190 | acpi_gbl_fixed_event_handlers[event].handler = handler; | ||
| 191 | acpi_gbl_fixed_event_handlers[event].context = context; | ||
| 192 | |||
| 193 | status = acpi_clear_event(event); | ||
| 194 | if (ACPI_SUCCESS(status)) | ||
| 195 | status = acpi_enable_event(event, 0); | ||
| 196 | if (ACPI_FAILURE(status)) { | ||
| 197 | ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X", | ||
| 198 | event)); | ||
| 199 | |||
| 200 | /* Remove the handler */ | ||
| 201 | |||
| 202 | acpi_gbl_fixed_event_handlers[event].handler = NULL; | ||
| 203 | acpi_gbl_fixed_event_handlers[event].context = NULL; | ||
| 204 | } else { | ||
| 205 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 206 | "Enabled fixed event %X, Handler=%p\n", event, | ||
| 207 | handler)); | ||
| 208 | } | ||
| 209 | |||
| 210 | cleanup: | ||
| 211 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 212 | return_ACPI_STATUS(status); | ||
| 213 | } | ||
| 214 | |||
| 215 | ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler) | ||
| 216 | |||
| 217 | /******************************************************************************* | ||
| 218 | * | ||
| 219 | * FUNCTION: acpi_remove_fixed_event_handler | ||
| 220 | * | ||
| 221 | * PARAMETERS: Event - Event type to disable. | ||
| 222 | * Handler - Address of the handler | ||
| 223 | * | ||
| 224 | * RETURN: Status | ||
| 225 | * | ||
| 226 | * DESCRIPTION: Disables the event and unregisters the event handler. | ||
| 227 | * | ||
| 228 | ******************************************************************************/ | ||
| 229 | acpi_status | ||
| 230 | acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) | ||
| 231 | { | ||
| 232 | acpi_status status = AE_OK; | ||
| 233 | |||
| 234 | ACPI_FUNCTION_TRACE(acpi_remove_fixed_event_handler); | ||
| 235 | |||
| 236 | /* Parameter validation */ | ||
| 237 | |||
| 238 | if (event > ACPI_EVENT_MAX) { | ||
| 239 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 240 | } | ||
| 241 | |||
| 242 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 243 | if (ACPI_FAILURE(status)) { | ||
| 244 | return_ACPI_STATUS(status); | ||
| 245 | } | ||
| 246 | |||
| 247 | /* Disable the event before removing the handler */ | ||
| 248 | |||
| 249 | status = acpi_disable_event(event, 0); | ||
| 250 | |||
| 251 | /* Always Remove the handler */ | ||
| 252 | |||
| 253 | acpi_gbl_fixed_event_handlers[event].handler = NULL; | ||
| 254 | acpi_gbl_fixed_event_handlers[event].context = NULL; | ||
| 255 | |||
| 256 | if (ACPI_FAILURE(status)) { | ||
| 257 | ACPI_WARNING((AE_INFO, | ||
| 258 | "Could not write to fixed event enable register 0x%X", | ||
| 259 | event)); | ||
| 260 | } else { | ||
| 261 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", | ||
| 262 | event)); | ||
| 263 | } | ||
| 264 | |||
| 265 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 266 | return_ACPI_STATUS(status); | ||
| 267 | } | ||
| 268 | |||
| 269 | ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler) | ||
| 270 | 54 | ||
| 271 | /******************************************************************************* | 55 | /******************************************************************************* |
| 272 | * | 56 | * |
| @@ -334,6 +118,7 @@ acpi_add_handler_object(struct acpi_object_notify_handler *parent_obj, | |||
| 334 | return AE_OK; | 118 | return AE_OK; |
| 335 | } | 119 | } |
| 336 | 120 | ||
| 121 | |||
| 337 | /******************************************************************************* | 122 | /******************************************************************************* |
| 338 | * | 123 | * |
| 339 | * FUNCTION: acpi_install_notify_handler | 124 | * FUNCTION: acpi_install_notify_handler |
| @@ -705,6 +490,224 @@ ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler) | |||
| 705 | 490 | ||
| 706 | /******************************************************************************* | 491 | /******************************************************************************* |
| 707 | * | 492 | * |
| 493 | * FUNCTION: acpi_install_exception_handler | ||
| 494 | * | ||
| 495 | * PARAMETERS: Handler - Pointer to the handler function for the | ||
| 496 | * event | ||
| 497 | * | ||
| 498 | * RETURN: Status | ||
| 499 | * | ||
| 500 | * DESCRIPTION: Saves the pointer to the handler function | ||
| 501 | * | ||
| 502 | ******************************************************************************/ | ||
| 503 | #ifdef ACPI_FUTURE_USAGE | ||
| 504 | acpi_status acpi_install_exception_handler(acpi_exception_handler handler) | ||
| 505 | { | ||
| 506 | acpi_status status; | ||
| 507 | |||
| 508 | ACPI_FUNCTION_TRACE(acpi_install_exception_handler); | ||
| 509 | |||
| 510 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 511 | if (ACPI_FAILURE(status)) { | ||
| 512 | return_ACPI_STATUS(status); | ||
| 513 | } | ||
| 514 | |||
| 515 | /* Don't allow two handlers. */ | ||
| 516 | |||
| 517 | if (acpi_gbl_exception_handler) { | ||
| 518 | status = AE_ALREADY_EXISTS; | ||
| 519 | goto cleanup; | ||
| 520 | } | ||
| 521 | |||
| 522 | /* Install the handler */ | ||
| 523 | |||
| 524 | acpi_gbl_exception_handler = handler; | ||
| 525 | |||
| 526 | cleanup: | ||
| 527 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 528 | return_ACPI_STATUS(status); | ||
| 529 | } | ||
| 530 | |||
| 531 | ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) | ||
| 532 | #endif /* ACPI_FUTURE_USAGE */ | ||
| 533 | |||
| 534 | #if (!ACPI_REDUCED_HARDWARE) | ||
| 535 | /******************************************************************************* | ||
| 536 | * | ||
| 537 | * FUNCTION: acpi_install_global_event_handler | ||
| 538 | * | ||
| 539 | * PARAMETERS: Handler - Pointer to the global event handler function | ||
| 540 | * Context - Value passed to the handler on each event | ||
| 541 | * | ||
| 542 | * RETURN: Status | ||
| 543 | * | ||
| 544 | * DESCRIPTION: Saves the pointer to the handler function. The global handler | ||
| 545 | * is invoked upon each incoming GPE and Fixed Event. It is | ||
| 546 | * invoked at interrupt level at the time of the event dispatch. | ||
| 547 | * Can be used to update event counters, etc. | ||
| 548 | * | ||
| 549 | ******************************************************************************/ | ||
| 550 | acpi_status | ||
| 551 | acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context) | ||
| 552 | { | ||
| 553 | acpi_status status; | ||
| 554 | |||
| 555 | ACPI_FUNCTION_TRACE(acpi_install_global_event_handler); | ||
| 556 | |||
| 557 | /* Parameter validation */ | ||
| 558 | |||
| 559 | if (!handler) { | ||
| 560 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 561 | } | ||
| 562 | |||
| 563 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 564 | if (ACPI_FAILURE(status)) { | ||
| 565 | return_ACPI_STATUS(status); | ||
| 566 | } | ||
| 567 | |||
| 568 | /* Don't allow two handlers. */ | ||
| 569 | |||
| 570 | if (acpi_gbl_global_event_handler) { | ||
| 571 | status = AE_ALREADY_EXISTS; | ||
| 572 | goto cleanup; | ||
| 573 | } | ||
| 574 | |||
| 575 | acpi_gbl_global_event_handler = handler; | ||
| 576 | acpi_gbl_global_event_handler_context = context; | ||
| 577 | |||
| 578 | cleanup: | ||
| 579 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 580 | return_ACPI_STATUS(status); | ||
| 581 | } | ||
| 582 | |||
| 583 | ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler) | ||
| 584 | |||
| 585 | /******************************************************************************* | ||
| 586 | * | ||
| 587 | * FUNCTION: acpi_install_fixed_event_handler | ||
| 588 | * | ||
| 589 | * PARAMETERS: Event - Event type to enable. | ||
| 590 | * Handler - Pointer to the handler function for the | ||
| 591 | * event | ||
| 592 | * Context - Value passed to the handler on each GPE | ||
| 593 | * | ||
| 594 | * RETURN: Status | ||
| 595 | * | ||
| 596 | * DESCRIPTION: Saves the pointer to the handler function and then enables the | ||
| 597 | * event. | ||
| 598 | * | ||
| 599 | ******************************************************************************/ | ||
| 600 | acpi_status | ||
| 601 | acpi_install_fixed_event_handler(u32 event, | ||
| 602 | acpi_event_handler handler, void *context) | ||
| 603 | { | ||
| 604 | acpi_status status; | ||
| 605 | |||
| 606 | ACPI_FUNCTION_TRACE(acpi_install_fixed_event_handler); | ||
| 607 | |||
| 608 | /* Parameter validation */ | ||
| 609 | |||
| 610 | if (event > ACPI_EVENT_MAX) { | ||
| 611 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 612 | } | ||
| 613 | |||
| 614 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 615 | if (ACPI_FAILURE(status)) { | ||
| 616 | return_ACPI_STATUS(status); | ||
| 617 | } | ||
| 618 | |||
| 619 | /* Don't allow two handlers. */ | ||
| 620 | |||
| 621 | if (NULL != acpi_gbl_fixed_event_handlers[event].handler) { | ||
| 622 | status = AE_ALREADY_EXISTS; | ||
| 623 | goto cleanup; | ||
| 624 | } | ||
| 625 | |||
| 626 | /* Install the handler before enabling the event */ | ||
| 627 | |||
| 628 | acpi_gbl_fixed_event_handlers[event].handler = handler; | ||
| 629 | acpi_gbl_fixed_event_handlers[event].context = context; | ||
| 630 | |||
| 631 | status = acpi_clear_event(event); | ||
| 632 | if (ACPI_SUCCESS(status)) | ||
| 633 | status = acpi_enable_event(event, 0); | ||
| 634 | if (ACPI_FAILURE(status)) { | ||
| 635 | ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X", | ||
| 636 | event)); | ||
| 637 | |||
| 638 | /* Remove the handler */ | ||
| 639 | |||
| 640 | acpi_gbl_fixed_event_handlers[event].handler = NULL; | ||
| 641 | acpi_gbl_fixed_event_handlers[event].context = NULL; | ||
| 642 | } else { | ||
| 643 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 644 | "Enabled fixed event %X, Handler=%p\n", event, | ||
| 645 | handler)); | ||
| 646 | } | ||
| 647 | |||
| 648 | cleanup: | ||
| 649 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 650 | return_ACPI_STATUS(status); | ||
| 651 | } | ||
| 652 | |||
| 653 | ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler) | ||
| 654 | |||
| 655 | /******************************************************************************* | ||
| 656 | * | ||
| 657 | * FUNCTION: acpi_remove_fixed_event_handler | ||
| 658 | * | ||
| 659 | * PARAMETERS: Event - Event type to disable. | ||
| 660 | * Handler - Address of the handler | ||
| 661 | * | ||
| 662 | * RETURN: Status | ||
| 663 | * | ||
| 664 | * DESCRIPTION: Disables the event and unregisters the event handler. | ||
| 665 | * | ||
| 666 | ******************************************************************************/ | ||
| 667 | acpi_status | ||
| 668 | acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) | ||
| 669 | { | ||
| 670 | acpi_status status = AE_OK; | ||
| 671 | |||
| 672 | ACPI_FUNCTION_TRACE(acpi_remove_fixed_event_handler); | ||
| 673 | |||
| 674 | /* Parameter validation */ | ||
| 675 | |||
| 676 | if (event > ACPI_EVENT_MAX) { | ||
| 677 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 678 | } | ||
| 679 | |||
| 680 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 681 | if (ACPI_FAILURE(status)) { | ||
| 682 | return_ACPI_STATUS(status); | ||
| 683 | } | ||
| 684 | |||
| 685 | /* Disable the event before removing the handler */ | ||
| 686 | |||
| 687 | status = acpi_disable_event(event, 0); | ||
| 688 | |||
| 689 | /* Always Remove the handler */ | ||
| 690 | |||
| 691 | acpi_gbl_fixed_event_handlers[event].handler = NULL; | ||
| 692 | acpi_gbl_fixed_event_handlers[event].context = NULL; | ||
| 693 | |||
| 694 | if (ACPI_FAILURE(status)) { | ||
| 695 | ACPI_WARNING((AE_INFO, | ||
| 696 | "Could not write to fixed event enable register 0x%X", | ||
| 697 | event)); | ||
| 698 | } else { | ||
| 699 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", | ||
| 700 | event)); | ||
| 701 | } | ||
| 702 | |||
| 703 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 704 | return_ACPI_STATUS(status); | ||
| 705 | } | ||
| 706 | |||
| 707 | ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler) | ||
| 708 | |||
| 709 | /******************************************************************************* | ||
| 710 | * | ||
| 708 | * FUNCTION: acpi_install_gpe_handler | 711 | * FUNCTION: acpi_install_gpe_handler |
| 709 | * | 712 | * |
| 710 | * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT | 713 | * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT |
| @@ -984,3 +987,4 @@ acpi_status acpi_release_global_lock(u32 handle) | |||
| 984 | } | 987 | } |
| 985 | 988 | ||
| 986 | ACPI_EXPORT_SYMBOL(acpi_release_global_lock) | 989 | ACPI_EXPORT_SYMBOL(acpi_release_global_lock) |
| 990 | #endif /* !ACPI_REDUCED_HARDWARE */ | ||
