aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/evxface.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/acpi/acpica/evxface.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/acpi/acpica/evxface.c')
-rw-r--r--drivers/acpi/acpica/evxface.c94
1 files changed, 73 insertions, 21 deletions
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 14e48add32fa..e1141402dbed 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -92,6 +92,57 @@ acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
92 92
93ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) 93ACPI_EXPORT_SYMBOL(acpi_install_exception_handler)
94#endif /* ACPI_FUTURE_USAGE */ 94#endif /* ACPI_FUTURE_USAGE */
95
96/*******************************************************************************
97 *
98 * FUNCTION: acpi_install_global_event_handler
99 *
100 * PARAMETERS: Handler - Pointer to the global event handler function
101 * Context - Value passed to the handler on each event
102 *
103 * RETURN: Status
104 *
105 * DESCRIPTION: Saves the pointer to the handler function. The global handler
106 * is invoked upon each incoming GPE and Fixed Event. It is
107 * invoked at interrupt level at the time of the event dispatch.
108 * Can be used to update event counters, etc.
109 *
110 ******************************************************************************/
111acpi_status
112acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context)
113{
114 acpi_status status;
115
116 ACPI_FUNCTION_TRACE(acpi_install_global_event_handler);
117
118 /* Parameter validation */
119
120 if (!handler) {
121 return_ACPI_STATUS(AE_BAD_PARAMETER);
122 }
123
124 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
125 if (ACPI_FAILURE(status)) {
126 return_ACPI_STATUS(status);
127 }
128
129 /* Don't allow two handlers. */
130
131 if (acpi_gbl_global_event_handler) {
132 status = AE_ALREADY_EXISTS;
133 goto cleanup;
134 }
135
136 acpi_gbl_global_event_handler = handler;
137 acpi_gbl_global_event_handler_context = context;
138
139 cleanup:
140 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
141 return_ACPI_STATUS(status);
142}
143
144ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler)
145
95/******************************************************************************* 146/*******************************************************************************
96 * 147 *
97 * FUNCTION: acpi_install_fixed_event_handler 148 * FUNCTION: acpi_install_fixed_event_handler
@@ -671,10 +722,10 @@ ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler)
671acpi_status 722acpi_status
672acpi_install_gpe_handler(acpi_handle gpe_device, 723acpi_install_gpe_handler(acpi_handle gpe_device,
673 u32 gpe_number, 724 u32 gpe_number,
674 u32 type, acpi_event_handler address, void *context) 725 u32 type, acpi_gpe_handler address, void *context)
675{ 726{
676 struct acpi_gpe_event_info *gpe_event_info; 727 struct acpi_gpe_event_info *gpe_event_info;
677 struct acpi_handler_info *handler; 728 struct acpi_gpe_handler_info *handler;
678 acpi_status status; 729 acpi_status status;
679 acpi_cpu_flags flags; 730 acpi_cpu_flags flags;
680 731
@@ -693,7 +744,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
693 744
694 /* Allocate memory for the handler object */ 745 /* Allocate memory for the handler object */
695 746
696 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); 747 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_handler_info));
697 if (!handler) { 748 if (!handler) {
698 status = AE_NO_MEMORY; 749 status = AE_NO_MEMORY;
699 goto unlock_and_exit; 750 goto unlock_and_exit;
@@ -722,19 +773,20 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
722 handler->address = address; 773 handler->address = address;
723 handler->context = context; 774 handler->context = context;
724 handler->method_node = gpe_event_info->dispatch.method_node; 775 handler->method_node = gpe_event_info->dispatch.method_node;
725 handler->orig_flags = gpe_event_info->flags & 776 handler->original_flags = gpe_event_info->flags &
726 (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); 777 (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
727 778
728 /* 779 /*
729 * If the GPE is associated with a method and it cannot wake up the 780 * If the GPE is associated with a method, it might have been enabled
730 * system from sleep states, it was enabled automatically during 781 * automatically during initialization, in which case it has to be
731 * initialization, so it has to be disabled now to avoid spurious 782 * disabled now to avoid spurious execution of the handler.
732 * execution of the handler.
733 */ 783 */
734 784
735 if ((handler->orig_flags & ACPI_GPE_DISPATCH_METHOD) 785 if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD)
736 && !(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) 786 && gpe_event_info->runtime_count) {
737 (void)acpi_raw_disable_gpe(gpe_event_info); 787 handler->originally_enabled = 1;
788 (void)acpi_ev_remove_gpe_reference(gpe_event_info);
789 }
738 790
739 /* Install the handler */ 791 /* Install the handler */
740 792
@@ -776,10 +828,10 @@ ACPI_EXPORT_SYMBOL(acpi_install_gpe_handler)
776 ******************************************************************************/ 828 ******************************************************************************/
777acpi_status 829acpi_status
778acpi_remove_gpe_handler(acpi_handle gpe_device, 830acpi_remove_gpe_handler(acpi_handle gpe_device,
779 u32 gpe_number, acpi_event_handler address) 831 u32 gpe_number, acpi_gpe_handler address)
780{ 832{
781 struct acpi_gpe_event_info *gpe_event_info; 833 struct acpi_gpe_event_info *gpe_event_info;
782 struct acpi_handler_info *handler; 834 struct acpi_gpe_handler_info *handler;
783 acpi_status status; 835 acpi_status status;
784 acpi_cpu_flags flags; 836 acpi_cpu_flags flags;
785 837
@@ -834,17 +886,17 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
834 gpe_event_info->dispatch.method_node = handler->method_node; 886 gpe_event_info->dispatch.method_node = handler->method_node;
835 gpe_event_info->flags &= 887 gpe_event_info->flags &=
836 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); 888 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
837 gpe_event_info->flags |= handler->orig_flags; 889 gpe_event_info->flags |= handler->original_flags;
838 890
839 /* 891 /*
840 * If the GPE was previously associated with a method and it cannot wake 892 * If the GPE was previously associated with a method and it was
841 * up the system from sleep states, it should be enabled at this point 893 * enabled, it should be enabled at this point to restore the
842 * to restore the post-initialization configuration. 894 * post-initialization configuration.
843 */ 895 */
844 896
845 if ((handler->orig_flags & ACPI_GPE_DISPATCH_METHOD) 897 if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD)
846 && !(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) 898 && handler->originally_enabled)
847 (void)acpi_raw_enable_gpe(gpe_event_info); 899 (void)acpi_ev_add_gpe_reference(gpe_event_info);
848 900
849 /* Now we can free the handler object */ 901 /* Now we can free the handler object */
850 902