1 /******************************************************************************
3 * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #define EXPORT_ACPI_INTERFACES
46 #include <acpi/acpi.h>
51 #define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME("evxfgpe")
54 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
55 /*******************************************************************************
57 * FUNCTION: acpi_update_all_gpes
63 * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
64 * associated _Lxx or _Exx methods and are not pointed to by any
65 * device _PRW methods (this indicates that these GPEs are
66 * generally intended for system or device wakeup. Such GPEs
67 * have to be enabled directly when the devices whose _PRW
68 * methods point to them are set up for wakeup signaling.)
70 * NOTE: Should be called after any GPEs are added to the system. Primarily,
71 * after the system _PRW methods have been run, but also after a GPE Block
72 * Device has been added or if any new GPE methods have been added via a
75 ******************************************************************************/
77 acpi_status
acpi_update_all_gpes(void)
81 ACPI_FUNCTION_TRACE(acpi_update_all_gpes
);
83 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
84 if (ACPI_FAILURE(status
)) {
85 return_ACPI_STATUS(status
);
88 if (acpi_gbl_all_gpes_initialized
) {
92 status
= acpi_ev_walk_gpe_list(acpi_ev_initialize_gpe_block
, NULL
);
93 if (ACPI_SUCCESS(status
)) {
94 acpi_gbl_all_gpes_initialized
= TRUE
;
98 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
100 return_ACPI_STATUS(status
);
103 ACPI_EXPORT_SYMBOL(acpi_update_all_gpes
)
105 /*******************************************************************************
107 * FUNCTION: acpi_enable_gpe
109 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
110 * gpe_number - GPE level within the GPE block
114 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
117 ******************************************************************************/
119 acpi_status
acpi_enable_gpe(acpi_handle gpe_device
, u32 gpe_number
)
121 acpi_status status
= AE_BAD_PARAMETER
;
122 struct acpi_gpe_event_info
*gpe_event_info
;
123 acpi_cpu_flags flags
;
125 ACPI_FUNCTION_TRACE(acpi_enable_gpe
);
127 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
130 * Ensure that we have a valid GPE number and that there is some way
131 * of handling the GPE (handler or a GPE method). In other words, we
132 * won't allow a valid GPE to be enabled if there is no way to handle it.
134 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
135 if (gpe_event_info
) {
136 if ((gpe_event_info
->flags
& ACPI_GPE_DISPATCH_MASK
) !=
137 ACPI_GPE_DISPATCH_NONE
) {
138 status
= acpi_ev_add_gpe_reference(gpe_event_info
);
140 status
= AE_NO_HANDLER
;
144 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
145 return_ACPI_STATUS(status
);
147 ACPI_EXPORT_SYMBOL(acpi_enable_gpe
)
149 /*******************************************************************************
151 * FUNCTION: acpi_disable_gpe
153 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
154 * gpe_number - GPE level within the GPE block
158 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
159 * removed, only then is the GPE disabled (for runtime GPEs), or
160 * the GPE mask bit disabled (for wake GPEs)
162 ******************************************************************************/
164 acpi_status
acpi_disable_gpe(acpi_handle gpe_device
, u32 gpe_number
)
166 acpi_status status
= AE_BAD_PARAMETER
;
167 struct acpi_gpe_event_info
*gpe_event_info
;
168 acpi_cpu_flags flags
;
170 ACPI_FUNCTION_TRACE(acpi_disable_gpe
);
172 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
174 /* Ensure that we have a valid GPE number */
176 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
177 if (gpe_event_info
) {
178 status
= acpi_ev_remove_gpe_reference(gpe_event_info
) ;
181 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
182 return_ACPI_STATUS(status
);
185 ACPI_EXPORT_SYMBOL(acpi_disable_gpe
)
188 /*******************************************************************************
190 * FUNCTION: acpi_mark_gpe_for_wake
192 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
193 * gpe_number - GPE level within the GPE block
197 * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
198 * sets the ACPI_GPE_CAN_WAKE flag.
200 * Some potential callers of acpi_setup_gpe_for_wake may know in advance that
201 * there won't be any notify handlers installed for device wake notifications
202 * from the given GPE (one example is a button GPE in Linux). For these cases,
203 * acpi_mark_gpe_for_wake should be used instead of acpi_setup_gpe_for_wake.
204 * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
205 * setup implicit wake notification for it (since there's no handler method).
207 ******************************************************************************/
208 acpi_status
acpi_mark_gpe_for_wake(acpi_handle gpe_device
, u32 gpe_number
)
210 struct acpi_gpe_event_info
*gpe_event_info
;
211 acpi_status status
= AE_BAD_PARAMETER
;
212 acpi_cpu_flags flags
;
214 ACPI_FUNCTION_TRACE(acpi_mark_gpe_for_wake
);
216 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
218 /* Ensure that we have a valid GPE number */
220 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
221 if (gpe_event_info
) {
223 /* Mark the GPE as a possible wake event */
225 gpe_event_info
->flags
|= ACPI_GPE_CAN_WAKE
;
229 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
230 return_ACPI_STATUS(status
);
233 ACPI_EXPORT_SYMBOL(acpi_mark_gpe_for_wake
)
235 /*******************************************************************************
237 * FUNCTION: acpi_setup_gpe_for_wake
239 * PARAMETERS: wake_device - Device associated with the GPE (via _PRW)
240 * gpe_device - Parent GPE Device. NULL for GPE0/GPE1
241 * gpe_number - GPE level within the GPE block
245 * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
246 * interface is intended to be used as the host executes the
247 * _PRW methods (Power Resources for Wake) in the system tables.
248 * Each _PRW appears under a Device Object (The wake_device), and
249 * contains the info for the wake GPE associated with the
252 ******************************************************************************/
254 acpi_setup_gpe_for_wake(acpi_handle wake_device
,
255 acpi_handle gpe_device
, u32 gpe_number
)
258 struct acpi_gpe_event_info
*gpe_event_info
;
259 struct acpi_namespace_node
*device_node
;
260 struct acpi_gpe_notify_info
*notify
;
261 struct acpi_gpe_notify_info
*new_notify
;
262 acpi_cpu_flags flags
;
264 ACPI_FUNCTION_TRACE(acpi_setup_gpe_for_wake
);
266 /* Parameter Validation */
270 * By forcing wake_device to be valid, we automatically enable the
271 * implicit notify feature on all hosts.
273 return_ACPI_STATUS(AE_BAD_PARAMETER
);
276 /* Handle root object case */
278 if (wake_device
== ACPI_ROOT_OBJECT
) {
279 device_node
= acpi_gbl_root_node
;
282 ACPI_CAST_PTR(struct acpi_namespace_node
, wake_device
);
285 /* Validate wake_device is of type Device */
287 if (device_node
->type
!= ACPI_TYPE_DEVICE
) {
288 return_ACPI_STATUS (AE_BAD_PARAMETER
);
292 * Allocate a new notify object up front, in case it is needed.
293 * Memory allocation while holding a spinlock is a big no-no
296 new_notify
= ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_notify_info
));
298 return_ACPI_STATUS(AE_NO_MEMORY
);
301 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
303 /* Ensure that we have a valid GPE number */
305 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
306 if (!gpe_event_info
) {
307 status
= AE_BAD_PARAMETER
;
308 goto unlock_and_exit
;
312 * If there is no method or handler for this GPE, then the
313 * wake_device will be notified whenever this GPE fires. This is
314 * known as an "implicit notify". Note: The GPE is assumed to be
315 * level-triggered (for windows compatibility).
317 if ((gpe_event_info
->flags
& ACPI_GPE_DISPATCH_MASK
) ==
318 ACPI_GPE_DISPATCH_NONE
) {
320 * This is the first device for implicit notify on this GPE.
321 * Just set the flags here, and enter the NOTIFY block below.
323 gpe_event_info
->flags
=
324 (ACPI_GPE_DISPATCH_NOTIFY
| ACPI_GPE_LEVEL_TRIGGERED
);
328 * If we already have an implicit notify on this GPE, add
329 * this device to the notify list.
331 if ((gpe_event_info
->flags
& ACPI_GPE_DISPATCH_MASK
) ==
332 ACPI_GPE_DISPATCH_NOTIFY
) {
334 /* Ensure that the device is not already in the list */
336 notify
= gpe_event_info
->dispatch
.notify_list
;
338 if (notify
->device_node
== device_node
) {
339 status
= AE_ALREADY_EXISTS
;
340 goto unlock_and_exit
;
342 notify
= notify
->next
;
345 /* Add this device to the notify list for this GPE */
347 new_notify
->device_node
= device_node
;
348 new_notify
->next
= gpe_event_info
->dispatch
.notify_list
;
349 gpe_event_info
->dispatch
.notify_list
= new_notify
;
353 /* Mark the GPE as a possible wake event */
355 gpe_event_info
->flags
|= ACPI_GPE_CAN_WAKE
;
359 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
361 /* Delete the notify object if it was not used above */
364 ACPI_FREE(new_notify
);
366 return_ACPI_STATUS(status
);
368 ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake
)
370 /*******************************************************************************
372 * FUNCTION: acpi_set_gpe_wake_mask
374 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
375 * gpe_number - GPE level within the GPE block
376 * action - Enable or Disable
380 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
381 * already be marked as a WAKE GPE.
383 ******************************************************************************/
386 acpi_set_gpe_wake_mask(acpi_handle gpe_device
, u32 gpe_number
, u8 action
)
388 acpi_status status
= AE_OK
;
389 struct acpi_gpe_event_info
*gpe_event_info
;
390 struct acpi_gpe_register_info
*gpe_register_info
;
391 acpi_cpu_flags flags
;
394 ACPI_FUNCTION_TRACE(acpi_set_gpe_wake_mask
);
396 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
399 * Ensure that we have a valid GPE number and that this GPE is in
402 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
403 if (!gpe_event_info
) {
404 status
= AE_BAD_PARAMETER
;
405 goto unlock_and_exit
;
408 if (!(gpe_event_info
->flags
& ACPI_GPE_CAN_WAKE
)) {
410 goto unlock_and_exit
;
413 gpe_register_info
= gpe_event_info
->register_info
;
414 if (!gpe_register_info
) {
415 status
= AE_NOT_EXIST
;
416 goto unlock_and_exit
;
419 register_bit
= acpi_hw_get_gpe_register_bit(gpe_event_info
);
421 /* Perform the action */
424 case ACPI_GPE_ENABLE
:
426 ACPI_SET_BIT(gpe_register_info
->enable_for_wake
,
430 case ACPI_GPE_DISABLE
:
432 ACPI_CLEAR_BIT(gpe_register_info
->enable_for_wake
,
438 ACPI_ERROR((AE_INFO
, "%u, Invalid action", action
));
439 status
= AE_BAD_PARAMETER
;
444 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
445 return_ACPI_STATUS(status
);
448 ACPI_EXPORT_SYMBOL(acpi_set_gpe_wake_mask
)
450 /*******************************************************************************
452 * FUNCTION: acpi_clear_gpe
454 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
455 * gpe_number - GPE level within the GPE block
459 * DESCRIPTION: Clear an ACPI event (general purpose)
461 ******************************************************************************/
462 acpi_status
acpi_clear_gpe(acpi_handle gpe_device
, u32 gpe_number
)
464 acpi_status status
= AE_OK
;
465 struct acpi_gpe_event_info
*gpe_event_info
;
466 acpi_cpu_flags flags
;
468 ACPI_FUNCTION_TRACE(acpi_clear_gpe
);
470 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
472 /* Ensure that we have a valid GPE number */
474 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
475 if (!gpe_event_info
) {
476 status
= AE_BAD_PARAMETER
;
477 goto unlock_and_exit
;
480 status
= acpi_hw_clear_gpe(gpe_event_info
);
483 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
484 return_ACPI_STATUS(status
);
487 ACPI_EXPORT_SYMBOL(acpi_clear_gpe
)
489 /*******************************************************************************
491 * FUNCTION: acpi_get_gpe_status
493 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
494 * gpe_number - GPE level within the GPE block
495 * event_status - Where the current status of the event
500 * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
502 ******************************************************************************/
504 acpi_get_gpe_status(acpi_handle gpe_device
,
505 u32 gpe_number
, acpi_event_status
*event_status
)
507 acpi_status status
= AE_OK
;
508 struct acpi_gpe_event_info
*gpe_event_info
;
509 acpi_cpu_flags flags
;
511 ACPI_FUNCTION_TRACE(acpi_get_gpe_status
);
513 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
515 /* Ensure that we have a valid GPE number */
517 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
518 if (!gpe_event_info
) {
519 status
= AE_BAD_PARAMETER
;
520 goto unlock_and_exit
;
523 /* Obtain status on the requested GPE number */
525 status
= acpi_hw_get_gpe_status(gpe_event_info
, event_status
);
527 if (gpe_event_info
->flags
& ACPI_GPE_DISPATCH_MASK
)
528 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
531 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
532 return_ACPI_STATUS(status
);
535 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status
)
537 /******************************************************************************
539 * FUNCTION: acpi_disable_all_gpes
545 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
547 ******************************************************************************/
549 acpi_status
acpi_disable_all_gpes(void)
553 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes
);
555 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
556 if (ACPI_FAILURE(status
)) {
557 return_ACPI_STATUS(status
);
560 status
= acpi_hw_disable_all_gpes();
561 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
563 return_ACPI_STATUS(status
);
566 ACPI_EXPORT_SYMBOL(acpi_disable_all_gpes
)
568 /******************************************************************************
570 * FUNCTION: acpi_enable_all_runtime_gpes
576 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
578 ******************************************************************************/
580 acpi_status
acpi_enable_all_runtime_gpes(void)
584 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes
);
586 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
587 if (ACPI_FAILURE(status
)) {
588 return_ACPI_STATUS(status
);
591 status
= acpi_hw_enable_all_runtime_gpes();
592 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
594 return_ACPI_STATUS(status
);
597 ACPI_EXPORT_SYMBOL(acpi_enable_all_runtime_gpes
)
599 /*******************************************************************************
601 * FUNCTION: acpi_install_gpe_block
603 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
604 * gpe_block_address - Address and space_ID
605 * register_count - Number of GPE register pairs in the block
606 * interrupt_number - H/W interrupt for the block
610 * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
613 ******************************************************************************/
615 acpi_install_gpe_block(acpi_handle gpe_device
,
616 struct acpi_generic_address
*gpe_block_address
,
617 u32 register_count
, u32 interrupt_number
)
620 union acpi_operand_object
*obj_desc
;
621 struct acpi_namespace_node
*node
;
622 struct acpi_gpe_block_info
*gpe_block
;
624 ACPI_FUNCTION_TRACE(acpi_install_gpe_block
);
626 if ((!gpe_device
) || (!gpe_block_address
) || (!register_count
)) {
627 return_ACPI_STATUS(AE_BAD_PARAMETER
);
630 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
631 if (ACPI_FAILURE(status
)) {
632 return_ACPI_STATUS(status
);
635 node
= acpi_ns_validate_handle(gpe_device
);
637 status
= AE_BAD_PARAMETER
;
638 goto unlock_and_exit
;
641 /* Validate the parent device */
643 if (node
->type
!= ACPI_TYPE_DEVICE
) {
645 goto unlock_and_exit
;
649 status
= AE_ALREADY_EXISTS
;
650 goto unlock_and_exit
;
654 * For user-installed GPE Block Devices, the gpe_block_base_number
657 status
= acpi_ev_create_gpe_block(node
, gpe_block_address
->address
,
658 gpe_block_address
->space_id
,
659 register_count
, 0, interrupt_number
,
661 if (ACPI_FAILURE(status
)) {
662 goto unlock_and_exit
;
665 /* Install block in the device_object attached to the node */
667 obj_desc
= acpi_ns_get_attached_object(node
);
671 * No object, create a new one (Device nodes do not always have
672 * an attached object)
674 obj_desc
= acpi_ut_create_internal_object(ACPI_TYPE_DEVICE
);
676 status
= AE_NO_MEMORY
;
677 goto unlock_and_exit
;
681 acpi_ns_attach_object(node
, obj_desc
, ACPI_TYPE_DEVICE
);
683 /* Remove local reference to the object */
685 acpi_ut_remove_reference(obj_desc
);
687 if (ACPI_FAILURE(status
)) {
688 goto unlock_and_exit
;
692 /* Now install the GPE block in the device_object */
694 obj_desc
->device
.gpe_block
= gpe_block
;
697 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
698 return_ACPI_STATUS(status
);
701 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block
)
703 /*******************************************************************************
705 * FUNCTION: acpi_remove_gpe_block
707 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
711 * DESCRIPTION: Remove a previously installed block of GPE registers
713 ******************************************************************************/
714 acpi_status
acpi_remove_gpe_block(acpi_handle gpe_device
)
716 union acpi_operand_object
*obj_desc
;
718 struct acpi_namespace_node
*node
;
720 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block
);
723 return_ACPI_STATUS(AE_BAD_PARAMETER
);
726 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
727 if (ACPI_FAILURE(status
)) {
728 return_ACPI_STATUS(status
);
731 node
= acpi_ns_validate_handle(gpe_device
);
733 status
= AE_BAD_PARAMETER
;
734 goto unlock_and_exit
;
737 /* Validate the parent device */
739 if (node
->type
!= ACPI_TYPE_DEVICE
) {
741 goto unlock_and_exit
;
744 /* Get the device_object attached to the node */
746 obj_desc
= acpi_ns_get_attached_object(node
);
747 if (!obj_desc
|| !obj_desc
->device
.gpe_block
) {
748 return_ACPI_STATUS(AE_NULL_OBJECT
);
751 /* Delete the GPE block (but not the device_object) */
753 status
= acpi_ev_delete_gpe_block(obj_desc
->device
.gpe_block
);
754 if (ACPI_SUCCESS(status
)) {
755 obj_desc
->device
.gpe_block
= NULL
;
759 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
760 return_ACPI_STATUS(status
);
763 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block
)
765 /*******************************************************************************
767 * FUNCTION: acpi_get_gpe_device
769 * PARAMETERS: index - System GPE index (0-current_gpe_count)
770 * gpe_device - Where the parent GPE Device is returned
774 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
775 * gpe device indicates that the gpe number is contained in one of
776 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
778 ******************************************************************************/
779 acpi_status
acpi_get_gpe_device(u32 index
, acpi_handle
* gpe_device
)
781 struct acpi_gpe_device_info info
;
784 ACPI_FUNCTION_TRACE(acpi_get_gpe_device
);
787 return_ACPI_STATUS(AE_BAD_PARAMETER
);
790 if (index
>= acpi_current_gpe_count
) {
791 return_ACPI_STATUS(AE_NOT_EXIST
);
794 /* Setup and walk the GPE list */
797 info
.status
= AE_NOT_EXIST
;
798 info
.gpe_device
= NULL
;
799 info
.next_block_base_index
= 0;
801 status
= acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device
, &info
);
802 if (ACPI_FAILURE(status
)) {
803 return_ACPI_STATUS(status
);
806 *gpe_device
= ACPI_CAST_PTR(acpi_handle
, info
.gpe_device
);
807 return_ACPI_STATUS(info
.status
);
810 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device
)
811 #endif /* !ACPI_REDUCED_HARDWARE */