goto unlock_and_exit;
}
- if (handler_type == ACPI_SYSTEM_NOTIFY) {
+ /* Make sure all deferred tasks are completed */
+
+ (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+ acpi_os_wait_events_complete(NULL);
+ status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (status)) {
+ return_ACPI_STATUS (status);
+ }
+
+ if (handler_type & ACPI_SYSTEM_NOTIFY) {
acpi_gbl_system_notify.node = NULL;
acpi_gbl_system_notify.handler = NULL;
acpi_gbl_system_notify.context = NULL;
/* Object exists - make sure there's an existing handler */
- if (handler_type == ACPI_SYSTEM_NOTIFY) {
+ if (handler_type & ACPI_SYSTEM_NOTIFY) {
notify_obj = obj_desc->common_notify.system_notify;
- }
- else {
- notify_obj = obj_desc->common_notify.device_notify;
- }
+ if ((!notify_obj) ||
+ (notify_obj->notify.handler != handler)) {
+ status = AE_BAD_PARAMETER;
+ goto unlock_and_exit;
+ }
++ /* Make sure all deferred tasks are completed */
- if ((!notify_obj) ||
- (notify_obj->notify.handler != handler)) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
- /* Remove the handler */
++ (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
++ acpi_os_wait_events_complete(NULL);
++ status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
++ if (ACPI_FAILURE (status)) {
++ return_ACPI_STATUS (status);
++ }
- /* Make sure all deferred tasks are completed */
++ /* Remove the handler */
+ obj_desc->common_notify.system_notify = NULL;
+ acpi_ut_remove_reference (notify_obj);
+ }
- (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
- acpi_os_wait_events_complete(NULL);
- status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
+ if (handler_type & ACPI_DEVICE_NOTIFY) {
+ notify_obj = obj_desc->common_notify.device_notify;
+ if ((!notify_obj) ||
+ (notify_obj->notify.handler != handler)) {
+ status = AE_BAD_PARAMETER;
+ goto unlock_and_exit;
+ }
++ /* Make sure all deferred tasks are completed */
- /* Remove the handler */
- /* Remove the handler */
++ (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
++ acpi_os_wait_events_complete(NULL);
++ status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
++ if (ACPI_FAILURE (status)) {
++ return_ACPI_STATUS (status);
++ }
- if (handler_type == ACPI_SYSTEM_NOTIFY) {
- obj_desc->common_notify.system_notify = NULL;
- }
- else {
++ /* Remove the handler */
obj_desc->common_notify.device_notify = NULL;
+ acpi_ut_remove_reference (notify_obj);
}
-
- acpi_ut_remove_reference (notify_obj);
}
goto unlock_and_exit;
}
+ /* Disable the GPE before removing the handler */
+
+ status = acpi_ev_disable_gpe (gpe_event_info);
+ if (ACPI_FAILURE (status)) {
+ goto unlock_and_exit;
+ }
+
+ /* Make sure all deferred tasks are completed */
+
+ (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+ acpi_os_wait_events_complete(NULL);
+ status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+ if (ACPI_FAILURE (status)) {
+ return_ACPI_STATUS (status);
+ }
+
/* Remove the handler */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);