evxfgpe.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /******************************************************************************
  2. *
  3. * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2011, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acevents.h"
  45. #include "acnamesp.h"
  46. #define _COMPONENT ACPI_EVENTS
  47. ACPI_MODULE_NAME("evxfgpe")
  48. /******************************************************************************
  49. *
  50. * FUNCTION: acpi_update_all_gpes
  51. *
  52. * PARAMETERS: None
  53. *
  54. * RETURN: Status
  55. *
  56. * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
  57. * associated _Lxx or _Exx methods and are not pointed to by any
  58. * device _PRW methods (this indicates that these GPEs are
  59. * generally intended for system or device wakeup. Such GPEs
  60. * have to be enabled directly when the devices whose _PRW
  61. * methods point to them are set up for wakeup signaling.)
  62. *
  63. * NOTE: Should be called after any GPEs are added to the system. Primarily,
  64. * after the system _PRW methods have been run, but also after a GPE Block
  65. * Device has been added or if any new GPE methods have been added via a
  66. * dynamic table load.
  67. *
  68. ******************************************************************************/
  69. acpi_status acpi_update_all_gpes(void)
  70. {
  71. acpi_status status;
  72. ACPI_FUNCTION_TRACE(acpi_update_all_gpes);
  73. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  74. if (ACPI_FAILURE(status)) {
  75. return_ACPI_STATUS(status);
  76. }
  77. if (acpi_gbl_all_gpes_initialized) {
  78. goto unlock_and_exit;
  79. }
  80. status = acpi_ev_walk_gpe_list(acpi_ev_initialize_gpe_block, NULL);
  81. if (ACPI_SUCCESS(status)) {
  82. acpi_gbl_all_gpes_initialized = TRUE;
  83. }
  84. unlock_and_exit:
  85. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  86. return_ACPI_STATUS(status);
  87. }
  88. ACPI_EXPORT_SYMBOL(acpi_update_all_gpes)
  89. /*******************************************************************************
  90. *
  91. * FUNCTION: acpi_enable_gpe
  92. *
  93. * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
  94. * gpe_number - GPE level within the GPE block
  95. *
  96. * RETURN: Status
  97. *
  98. * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
  99. * hardware-enabled.
  100. *
  101. ******************************************************************************/
  102. acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
  103. {
  104. acpi_status status = AE_BAD_PARAMETER;
  105. struct acpi_gpe_event_info *gpe_event_info;
  106. acpi_cpu_flags flags;
  107. ACPI_FUNCTION_TRACE(acpi_enable_gpe);
  108. flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
  109. /* Ensure that we have a valid GPE number */
  110. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  111. if (gpe_event_info) {
  112. status = acpi_ev_add_gpe_reference(gpe_event_info);
  113. }
  114. acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
  115. return_ACPI_STATUS(status);
  116. }
  117. ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
  118. /*******************************************************************************
  119. *
  120. * FUNCTION: acpi_disable_gpe
  121. *
  122. * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
  123. * gpe_number - GPE level within the GPE block
  124. *
  125. * RETURN: Status
  126. *
  127. * DESCRIPTION: Remove a reference to a GPE. When the last reference is
  128. * removed, only then is the GPE disabled (for runtime GPEs), or
  129. * the GPE mask bit disabled (for wake GPEs)
  130. *
  131. ******************************************************************************/
  132. acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
  133. {
  134. acpi_status status = AE_BAD_PARAMETER;
  135. struct acpi_gpe_event_info *gpe_event_info;
  136. acpi_cpu_flags flags;
  137. ACPI_FUNCTION_TRACE(acpi_disable_gpe);
  138. flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
  139. /* Ensure that we have a valid GPE number */
  140. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  141. if (gpe_event_info) {
  142. status = acpi_ev_remove_gpe_reference(gpe_event_info) ;
  143. }
  144. acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
  145. return_ACPI_STATUS(status);
  146. }
  147. ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
  148. /*******************************************************************************
  149. *
  150. * FUNCTION: acpi_setup_gpe_for_wake
  151. *
  152. * PARAMETERS: wake_device - Device associated with the GPE (via _PRW)
  153. * gpe_device - Parent GPE Device. NULL for GPE0/GPE1
  154. * gpe_number - GPE level within the GPE block
  155. *
  156. * RETURN: Status
  157. *
  158. * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
  159. * interface is intended to be used as the host executes the
  160. * _PRW methods (Power Resources for Wake) in the system tables.
  161. * Each _PRW appears under a Device Object (The wake_device), and
  162. * contains the info for the wake GPE associated with the
  163. * wake_device.
  164. *
  165. ******************************************************************************/
  166. acpi_status
  167. acpi_setup_gpe_for_wake(acpi_handle wake_device,
  168. acpi_handle gpe_device, u32 gpe_number)
  169. {
  170. acpi_status status = AE_BAD_PARAMETER;
  171. struct acpi_gpe_event_info *gpe_event_info;
  172. struct acpi_namespace_node *device_node;
  173. acpi_cpu_flags flags;
  174. ACPI_FUNCTION_TRACE(acpi_setup_gpe_for_wake);
  175. /* Parameter Validation */
  176. if (!wake_device) {
  177. /*
  178. * By forcing wake_device to be valid, we automatically enable the
  179. * implicit notify feature on all hosts.
  180. */
  181. return_ACPI_STATUS(AE_BAD_PARAMETER);
  182. }
  183. flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
  184. /* Ensure that we have a valid GPE number */
  185. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  186. if (!gpe_event_info) {
  187. goto unlock_and_exit;
  188. }
  189. /*
  190. * If there is no method or handler for this GPE, then the
  191. * wake_device will be notified whenever this GPE fires (aka
  192. * "implicit notify") Note: The GPE is assumed to be
  193. * level-triggered (for windows compatibility).
  194. */
  195. if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
  196. ACPI_GPE_DISPATCH_NONE) && (wake_device != ACPI_ROOT_OBJECT)) {
  197. /* Validate wake_device is of type Device */
  198. device_node = ACPI_CAST_PTR(struct acpi_namespace_node,
  199. wake_device);
  200. if (device_node->type != ACPI_TYPE_DEVICE) {
  201. goto unlock_and_exit;
  202. }
  203. gpe_event_info->flags = (ACPI_GPE_DISPATCH_NOTIFY |
  204. ACPI_GPE_LEVEL_TRIGGERED);
  205. gpe_event_info->dispatch.device_node = device_node;
  206. }
  207. gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
  208. status = AE_OK;
  209. unlock_and_exit:
  210. acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
  211. return_ACPI_STATUS(status);
  212. }
  213. ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake)
  214. /*******************************************************************************
  215. *
  216. * FUNCTION: acpi_set_gpe_wake_mask
  217. *
  218. * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
  219. * gpe_number - GPE level within the GPE block
  220. * Action - Enable or Disable
  221. *
  222. * RETURN: Status
  223. *
  224. * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
  225. * already be marked as a WAKE GPE.
  226. *
  227. ******************************************************************************/
  228. acpi_status acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action)
  229. {
  230. acpi_status status = AE_OK;
  231. struct acpi_gpe_event_info *gpe_event_info;
  232. struct acpi_gpe_register_info *gpe_register_info;
  233. acpi_cpu_flags flags;
  234. u32 register_bit;
  235. ACPI_FUNCTION_TRACE(acpi_set_gpe_wake_mask);
  236. flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
  237. /*
  238. * Ensure that we have a valid GPE number and that this GPE is in
  239. * fact a wake GPE
  240. */
  241. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  242. if (!gpe_event_info) {
  243. status = AE_BAD_PARAMETER;
  244. goto unlock_and_exit;
  245. }
  246. if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
  247. status = AE_TYPE;
  248. goto unlock_and_exit;
  249. }
  250. gpe_register_info = gpe_event_info->register_info;
  251. if (!gpe_register_info) {
  252. status = AE_NOT_EXIST;
  253. goto unlock_and_exit;
  254. }
  255. register_bit =
  256. acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
  257. /* Perform the action */
  258. switch (action) {
  259. case ACPI_GPE_ENABLE:
  260. ACPI_SET_BIT(gpe_register_info->enable_for_wake,
  261. (u8)register_bit);
  262. break;
  263. case ACPI_GPE_DISABLE:
  264. ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
  265. (u8)register_bit);
  266. break;
  267. default:
  268. ACPI_ERROR((AE_INFO, "%u, Invalid action", action));
  269. status = AE_BAD_PARAMETER;
  270. break;
  271. }
  272. unlock_and_exit:
  273. acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
  274. return_ACPI_STATUS(status);
  275. }
  276. ACPI_EXPORT_SYMBOL(acpi_set_gpe_wake_mask)
  277. /*******************************************************************************
  278. *
  279. * FUNCTION: acpi_clear_gpe
  280. *
  281. * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
  282. * gpe_number - GPE level within the GPE block
  283. *
  284. * RETURN: Status
  285. *
  286. * DESCRIPTION: Clear an ACPI event (general purpose)
  287. *
  288. ******************************************************************************/
  289. acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number)
  290. {
  291. acpi_status status = AE_OK;
  292. struct acpi_gpe_event_info *gpe_event_info;
  293. acpi_cpu_flags flags;
  294. ACPI_FUNCTION_TRACE(acpi_clear_gpe);
  295. flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
  296. /* Ensure that we have a valid GPE number */
  297. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  298. if (!gpe_event_info) {
  299. status = AE_BAD_PARAMETER;
  300. goto unlock_and_exit;
  301. }
  302. status = acpi_hw_clear_gpe(gpe_event_info);
  303. unlock_and_exit:
  304. acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
  305. return_ACPI_STATUS(status);
  306. }
  307. ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
  308. /*******************************************************************************
  309. *
  310. * FUNCTION: acpi_get_gpe_status
  311. *
  312. * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
  313. * gpe_number - GPE level within the GPE block
  314. * event_status - Where the current status of the event will
  315. * be returned
  316. *
  317. * RETURN: Status
  318. *
  319. * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
  320. *
  321. ******************************************************************************/
  322. acpi_status
  323. acpi_get_gpe_status(acpi_handle gpe_device,
  324. u32 gpe_number, acpi_event_status *event_status)
  325. {
  326. acpi_status status = AE_OK;
  327. struct acpi_gpe_event_info *gpe_event_info;
  328. acpi_cpu_flags flags;
  329. ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
  330. flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
  331. /* Ensure that we have a valid GPE number */
  332. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  333. if (!gpe_event_info) {
  334. status = AE_BAD_PARAMETER;
  335. goto unlock_and_exit;
  336. }
  337. /* Obtain status on the requested GPE number */
  338. status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
  339. if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
  340. *event_status |= ACPI_EVENT_FLAG_HANDLE;
  341. unlock_and_exit:
  342. acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
  343. return_ACPI_STATUS(status);
  344. }
  345. ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
  346. /******************************************************************************
  347. *
  348. * FUNCTION: acpi_disable_all_gpes
  349. *
  350. * PARAMETERS: None
  351. *
  352. * RETURN: Status
  353. *
  354. * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
  355. *
  356. ******************************************************************************/
  357. acpi_status acpi_disable_all_gpes(void)
  358. {
  359. acpi_status status;
  360. ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
  361. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  362. if (ACPI_FAILURE(status)) {
  363. return_ACPI_STATUS(status);
  364. }
  365. status = acpi_hw_disable_all_gpes();
  366. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  367. return_ACPI_STATUS(status);
  368. }
  369. ACPI_EXPORT_SYMBOL(acpi_disable_all_gpes)
  370. /******************************************************************************
  371. *
  372. * FUNCTION: acpi_enable_all_runtime_gpes
  373. *
  374. * PARAMETERS: None
  375. *
  376. * RETURN: Status
  377. *
  378. * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
  379. *
  380. ******************************************************************************/
  381. acpi_status acpi_enable_all_runtime_gpes(void)
  382. {
  383. acpi_status status;
  384. ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
  385. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  386. if (ACPI_FAILURE(status)) {
  387. return_ACPI_STATUS(status);
  388. }
  389. status = acpi_hw_enable_all_runtime_gpes();
  390. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  391. return_ACPI_STATUS(status);
  392. }
  393. ACPI_EXPORT_SYMBOL(acpi_enable_all_runtime_gpes)
  394. /*******************************************************************************
  395. *
  396. * FUNCTION: acpi_install_gpe_block
  397. *
  398. * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
  399. * gpe_block_address - Address and space_iD
  400. * register_count - Number of GPE register pairs in the block
  401. * interrupt_number - H/W interrupt for the block
  402. *
  403. * RETURN: Status
  404. *
  405. * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
  406. * enabled here.
  407. *
  408. ******************************************************************************/
  409. acpi_status
  410. acpi_install_gpe_block(acpi_handle gpe_device,
  411. struct acpi_generic_address *gpe_block_address,
  412. u32 register_count, u32 interrupt_number)
  413. {
  414. acpi_status status;
  415. union acpi_operand_object *obj_desc;
  416. struct acpi_namespace_node *node;
  417. struct acpi_gpe_block_info *gpe_block;
  418. ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
  419. if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
  420. return_ACPI_STATUS(AE_BAD_PARAMETER);
  421. }
  422. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  423. if (ACPI_FAILURE(status)) {
  424. return (status);
  425. }
  426. node = acpi_ns_validate_handle(gpe_device);
  427. if (!node) {
  428. status = AE_BAD_PARAMETER;
  429. goto unlock_and_exit;
  430. }
  431. /*
  432. * For user-installed GPE Block Devices, the gpe_block_base_number
  433. * is always zero
  434. */
  435. status =
  436. acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
  437. interrupt_number, &gpe_block);
  438. if (ACPI_FAILURE(status)) {
  439. goto unlock_and_exit;
  440. }
  441. /* Install block in the device_object attached to the node */
  442. obj_desc = acpi_ns_get_attached_object(node);
  443. if (!obj_desc) {
  444. /*
  445. * No object, create a new one (Device nodes do not always have
  446. * an attached object)
  447. */
  448. obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
  449. if (!obj_desc) {
  450. status = AE_NO_MEMORY;
  451. goto unlock_and_exit;
  452. }
  453. status =
  454. acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
  455. /* Remove local reference to the object */
  456. acpi_ut_remove_reference(obj_desc);
  457. if (ACPI_FAILURE(status)) {
  458. goto unlock_and_exit;
  459. }
  460. }
  461. /* Now install the GPE block in the device_object */
  462. obj_desc->device.gpe_block = gpe_block;
  463. unlock_and_exit:
  464. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  465. return_ACPI_STATUS(status);
  466. }
  467. ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
  468. /*******************************************************************************
  469. *
  470. * FUNCTION: acpi_remove_gpe_block
  471. *
  472. * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
  473. *
  474. * RETURN: Status
  475. *
  476. * DESCRIPTION: Remove a previously installed block of GPE registers
  477. *
  478. ******************************************************************************/
  479. acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
  480. {
  481. union acpi_operand_object *obj_desc;
  482. acpi_status status;
  483. struct acpi_namespace_node *node;
  484. ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
  485. if (!gpe_device) {
  486. return_ACPI_STATUS(AE_BAD_PARAMETER);
  487. }
  488. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  489. if (ACPI_FAILURE(status)) {
  490. return (status);
  491. }
  492. node = acpi_ns_validate_handle(gpe_device);
  493. if (!node) {
  494. status = AE_BAD_PARAMETER;
  495. goto unlock_and_exit;
  496. }
  497. /* Get the device_object attached to the node */
  498. obj_desc = acpi_ns_get_attached_object(node);
  499. if (!obj_desc || !obj_desc->device.gpe_block) {
  500. return_ACPI_STATUS(AE_NULL_OBJECT);
  501. }
  502. /* Delete the GPE block (but not the device_object) */
  503. status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
  504. if (ACPI_SUCCESS(status)) {
  505. obj_desc->device.gpe_block = NULL;
  506. }
  507. unlock_and_exit:
  508. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  509. return_ACPI_STATUS(status);
  510. }
  511. ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
  512. /*******************************************************************************
  513. *
  514. * FUNCTION: acpi_get_gpe_device
  515. *
  516. * PARAMETERS: Index - System GPE index (0-current_gpe_count)
  517. * gpe_device - Where the parent GPE Device is returned
  518. *
  519. * RETURN: Status
  520. *
  521. * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
  522. * gpe device indicates that the gpe number is contained in one of
  523. * the FADT-defined gpe blocks. Otherwise, the GPE block device.
  524. *
  525. ******************************************************************************/
  526. acpi_status
  527. acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
  528. {
  529. struct acpi_gpe_device_info info;
  530. acpi_status status;
  531. ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
  532. if (!gpe_device) {
  533. return_ACPI_STATUS(AE_BAD_PARAMETER);
  534. }
  535. if (index >= acpi_current_gpe_count) {
  536. return_ACPI_STATUS(AE_NOT_EXIST);
  537. }
  538. /* Setup and walk the GPE list */
  539. info.index = index;
  540. info.status = AE_NOT_EXIST;
  541. info.gpe_device = NULL;
  542. info.next_block_base_index = 0;
  543. status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
  544. if (ACPI_FAILURE(status)) {
  545. return_ACPI_STATUS(status);
  546. }
  547. *gpe_device = ACPI_CAST_PTR(acpi_handle, info.gpe_device);
  548. return_ACPI_STATUS(info.status);
  549. }
  550. ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)