evxfevnt.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /******************************************************************************
  2. *
  3. * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2007, R. Byron Moore
  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 <acpi/acevents.h>
  44. #include <acpi/acnamesp.h>
  45. #include <acpi/actables.h>
  46. #define _COMPONENT ACPI_EVENTS
  47. ACPI_MODULE_NAME("evxfevnt")
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_enable
  51. *
  52. * PARAMETERS: None
  53. *
  54. * RETURN: Status
  55. *
  56. * DESCRIPTION: Transfers the system into ACPI mode.
  57. *
  58. ******************************************************************************/
  59. acpi_status acpi_enable(void)
  60. {
  61. acpi_status status = AE_OK;
  62. ACPI_FUNCTION_TRACE(acpi_enable);
  63. /* ACPI tables must be present */
  64. if (!acpi_tb_tables_loaded()) {
  65. return_ACPI_STATUS(AE_NO_ACPI_TABLES);
  66. }
  67. /* Check current mode */
  68. if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
  69. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  70. "System is already in ACPI mode\n"));
  71. } else {
  72. /* Transition to ACPI mode */
  73. status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
  74. if (ACPI_FAILURE(status)) {
  75. ACPI_ERROR((AE_INFO,
  76. "Could not transition to ACPI mode"));
  77. return_ACPI_STATUS(status);
  78. }
  79. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  80. "Transition to ACPI mode successful\n"));
  81. }
  82. return_ACPI_STATUS(status);
  83. }
  84. ACPI_EXPORT_SYMBOL(acpi_enable)
  85. /*******************************************************************************
  86. *
  87. * FUNCTION: acpi_disable
  88. *
  89. * PARAMETERS: None
  90. *
  91. * RETURN: Status
  92. *
  93. * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
  94. *
  95. ******************************************************************************/
  96. acpi_status acpi_disable(void)
  97. {
  98. acpi_status status = AE_OK;
  99. ACPI_FUNCTION_TRACE(acpi_disable);
  100. if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
  101. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  102. "System is already in legacy (non-ACPI) mode\n"));
  103. } else {
  104. /* Transition to LEGACY mode */
  105. status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
  106. if (ACPI_FAILURE(status)) {
  107. ACPI_ERROR((AE_INFO,
  108. "Could not exit ACPI mode to legacy mode"));
  109. return_ACPI_STATUS(status);
  110. }
  111. ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
  112. }
  113. return_ACPI_STATUS(status);
  114. }
  115. ACPI_EXPORT_SYMBOL(acpi_disable)
  116. /*******************************************************************************
  117. *
  118. * FUNCTION: acpi_enable_event
  119. *
  120. * PARAMETERS: Event - The fixed eventto be enabled
  121. * Flags - Reserved
  122. *
  123. * RETURN: Status
  124. *
  125. * DESCRIPTION: Enable an ACPI event (fixed)
  126. *
  127. ******************************************************************************/
  128. acpi_status acpi_enable_event(u32 event, u32 flags)
  129. {
  130. acpi_status status = AE_OK;
  131. u32 value;
  132. ACPI_FUNCTION_TRACE(acpi_enable_event);
  133. /* Decode the Fixed Event */
  134. if (event > ACPI_EVENT_MAX) {
  135. return_ACPI_STATUS(AE_BAD_PARAMETER);
  136. }
  137. /*
  138. * Enable the requested fixed event (by writing a one to the
  139. * enable register bit)
  140. */
  141. status =
  142. acpi_set_register(acpi_gbl_fixed_event_info[event].
  143. enable_register_id, 1);
  144. if (ACPI_FAILURE(status)) {
  145. return_ACPI_STATUS(status);
  146. }
  147. /* Make sure that the hardware responded */
  148. status =
  149. acpi_get_register(acpi_gbl_fixed_event_info[event].
  150. enable_register_id, &value);
  151. if (ACPI_FAILURE(status)) {
  152. return_ACPI_STATUS(status);
  153. }
  154. if (value != 1) {
  155. ACPI_ERROR((AE_INFO,
  156. "Could not enable %s event",
  157. acpi_ut_get_event_name(event)));
  158. return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
  159. }
  160. return_ACPI_STATUS(status);
  161. }
  162. ACPI_EXPORT_SYMBOL(acpi_enable_event)
  163. /*******************************************************************************
  164. *
  165. * FUNCTION: acpi_set_gpe_type
  166. *
  167. * PARAMETERS: gpe_device - Parent GPE Device
  168. * gpe_number - GPE level within the GPE block
  169. * Type - New GPE type
  170. *
  171. * RETURN: Status
  172. *
  173. * DESCRIPTION: Set the type of an individual GPE
  174. *
  175. ******************************************************************************/
  176. acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
  177. {
  178. acpi_status status = AE_OK;
  179. struct acpi_gpe_event_info *gpe_event_info;
  180. ACPI_FUNCTION_TRACE(acpi_set_gpe_type);
  181. /* Ensure that we have a valid GPE number */
  182. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  183. if (!gpe_event_info) {
  184. status = AE_BAD_PARAMETER;
  185. goto unlock_and_exit;
  186. }
  187. if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
  188. return_ACPI_STATUS(AE_OK);
  189. }
  190. /* Set the new type (will disable GPE if currently enabled) */
  191. status = acpi_ev_set_gpe_type(gpe_event_info, type);
  192. unlock_and_exit:
  193. return_ACPI_STATUS(status);
  194. }
  195. ACPI_EXPORT_SYMBOL(acpi_set_gpe_type)
  196. /*******************************************************************************
  197. *
  198. * FUNCTION: acpi_enable_gpe
  199. *
  200. * PARAMETERS: gpe_device - Parent GPE Device
  201. * gpe_number - GPE level within the GPE block
  202. * Flags - Just enable, or also wake enable?
  203. * Called from ISR or not
  204. *
  205. * RETURN: Status
  206. *
  207. * DESCRIPTION: Enable an ACPI event (general purpose)
  208. *
  209. ******************************************************************************/
  210. acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  211. {
  212. acpi_status status = AE_OK;
  213. struct acpi_gpe_event_info *gpe_event_info;
  214. ACPI_FUNCTION_TRACE(acpi_enable_gpe);
  215. /* Use semaphore lock if not executing at interrupt level */
  216. if (flags & ACPI_NOT_ISR) {
  217. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  218. if (ACPI_FAILURE(status)) {
  219. return_ACPI_STATUS(status);
  220. }
  221. }
  222. /* Ensure that we have a valid GPE number */
  223. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  224. if (!gpe_event_info) {
  225. status = AE_BAD_PARAMETER;
  226. goto unlock_and_exit;
  227. }
  228. /* Perform the enable */
  229. status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
  230. unlock_and_exit:
  231. if (flags & ACPI_NOT_ISR) {
  232. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  233. }
  234. return_ACPI_STATUS(status);
  235. }
  236. ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
  237. /*******************************************************************************
  238. *
  239. * FUNCTION: acpi_disable_gpe
  240. *
  241. * PARAMETERS: gpe_device - Parent GPE Device
  242. * gpe_number - GPE level within the GPE block
  243. * Flags - Just disable, or also wake disable?
  244. * Called from ISR or not
  245. *
  246. * RETURN: Status
  247. *
  248. * DESCRIPTION: Disable an ACPI event (general purpose)
  249. *
  250. ******************************************************************************/
  251. acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  252. {
  253. acpi_status status = AE_OK;
  254. struct acpi_gpe_event_info *gpe_event_info;
  255. ACPI_FUNCTION_TRACE(acpi_disable_gpe);
  256. /* Use semaphore lock if not executing at interrupt level */
  257. if (flags & ACPI_NOT_ISR) {
  258. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  259. if (ACPI_FAILURE(status)) {
  260. return_ACPI_STATUS(status);
  261. }
  262. }
  263. /* Ensure that we have a valid GPE number */
  264. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  265. if (!gpe_event_info) {
  266. status = AE_BAD_PARAMETER;
  267. goto unlock_and_exit;
  268. }
  269. status = acpi_ev_disable_gpe(gpe_event_info);
  270. unlock_and_exit:
  271. if (flags & ACPI_NOT_ISR) {
  272. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  273. }
  274. return_ACPI_STATUS(status);
  275. }
  276. ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
  277. /*******************************************************************************
  278. *
  279. * FUNCTION: acpi_disable_event
  280. *
  281. * PARAMETERS: Event - The fixed eventto be enabled
  282. * Flags - Reserved
  283. *
  284. * RETURN: Status
  285. *
  286. * DESCRIPTION: Disable an ACPI event (fixed)
  287. *
  288. ******************************************************************************/
  289. acpi_status acpi_disable_event(u32 event, u32 flags)
  290. {
  291. acpi_status status = AE_OK;
  292. u32 value;
  293. ACPI_FUNCTION_TRACE(acpi_disable_event);
  294. /* Decode the Fixed Event */
  295. if (event > ACPI_EVENT_MAX) {
  296. return_ACPI_STATUS(AE_BAD_PARAMETER);
  297. }
  298. /*
  299. * Disable the requested fixed event (by writing a zero to the
  300. * enable register bit)
  301. */
  302. status =
  303. acpi_set_register(acpi_gbl_fixed_event_info[event].
  304. enable_register_id, 0);
  305. if (ACPI_FAILURE(status)) {
  306. return_ACPI_STATUS(status);
  307. }
  308. status =
  309. acpi_get_register(acpi_gbl_fixed_event_info[event].
  310. enable_register_id, &value);
  311. if (ACPI_FAILURE(status)) {
  312. return_ACPI_STATUS(status);
  313. }
  314. if (value != 0) {
  315. ACPI_ERROR((AE_INFO,
  316. "Could not disable %s events",
  317. acpi_ut_get_event_name(event)));
  318. return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
  319. }
  320. return_ACPI_STATUS(status);
  321. }
  322. ACPI_EXPORT_SYMBOL(acpi_disable_event)
  323. /*******************************************************************************
  324. *
  325. * FUNCTION: acpi_clear_event
  326. *
  327. * PARAMETERS: Event - The fixed event to be cleared
  328. *
  329. * RETURN: Status
  330. *
  331. * DESCRIPTION: Clear an ACPI event (fixed)
  332. *
  333. ******************************************************************************/
  334. acpi_status acpi_clear_event(u32 event)
  335. {
  336. acpi_status status = AE_OK;
  337. ACPI_FUNCTION_TRACE(acpi_clear_event);
  338. /* Decode the Fixed Event */
  339. if (event > ACPI_EVENT_MAX) {
  340. return_ACPI_STATUS(AE_BAD_PARAMETER);
  341. }
  342. /*
  343. * Clear the requested fixed event (By writing a one to the
  344. * status register bit)
  345. */
  346. status =
  347. acpi_set_register(acpi_gbl_fixed_event_info[event].
  348. status_register_id, 1);
  349. return_ACPI_STATUS(status);
  350. }
  351. ACPI_EXPORT_SYMBOL(acpi_clear_event)
  352. /*******************************************************************************
  353. *
  354. * FUNCTION: acpi_clear_gpe
  355. *
  356. * PARAMETERS: gpe_device - Parent GPE Device
  357. * gpe_number - GPE level within the GPE block
  358. * Flags - Called from an ISR or not
  359. *
  360. * RETURN: Status
  361. *
  362. * DESCRIPTION: Clear an ACPI event (general purpose)
  363. *
  364. ******************************************************************************/
  365. acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  366. {
  367. acpi_status status = AE_OK;
  368. struct acpi_gpe_event_info *gpe_event_info;
  369. ACPI_FUNCTION_TRACE(acpi_clear_gpe);
  370. /* Use semaphore lock if not executing at interrupt level */
  371. if (flags & ACPI_NOT_ISR) {
  372. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  373. if (ACPI_FAILURE(status)) {
  374. return_ACPI_STATUS(status);
  375. }
  376. }
  377. /* Ensure that we have a valid GPE number */
  378. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  379. if (!gpe_event_info) {
  380. status = AE_BAD_PARAMETER;
  381. goto unlock_and_exit;
  382. }
  383. status = acpi_hw_clear_gpe(gpe_event_info);
  384. unlock_and_exit:
  385. if (flags & ACPI_NOT_ISR) {
  386. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  387. }
  388. return_ACPI_STATUS(status);
  389. }
  390. ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
  391. #ifdef ACPI_FUTURE_USAGE
  392. /*******************************************************************************
  393. *
  394. * FUNCTION: acpi_get_event_status
  395. *
  396. * PARAMETERS: Event - The fixed event
  397. * event_status - Where the current status of the event will
  398. * be returned
  399. *
  400. * RETURN: Status
  401. *
  402. * DESCRIPTION: Obtains and returns the current status of the event
  403. *
  404. ******************************************************************************/
  405. acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
  406. {
  407. acpi_status status = AE_OK;
  408. ACPI_FUNCTION_TRACE(acpi_get_event_status);
  409. if (!event_status) {
  410. return_ACPI_STATUS(AE_BAD_PARAMETER);
  411. }
  412. /* Decode the Fixed Event */
  413. if (event > ACPI_EVENT_MAX) {
  414. return_ACPI_STATUS(AE_BAD_PARAMETER);
  415. }
  416. /* Get the status of the requested fixed event */
  417. status =
  418. acpi_get_register(acpi_gbl_fixed_event_info[event].
  419. status_register_id, event_status);
  420. return_ACPI_STATUS(status);
  421. }
  422. ACPI_EXPORT_SYMBOL(acpi_get_event_status)
  423. /*******************************************************************************
  424. *
  425. * FUNCTION: acpi_get_gpe_status
  426. *
  427. * PARAMETERS: gpe_device - Parent GPE Device
  428. * gpe_number - GPE level within the GPE block
  429. * Flags - Called from an ISR or not
  430. * event_status - Where the current status of the event will
  431. * be returned
  432. *
  433. * RETURN: Status
  434. *
  435. * DESCRIPTION: Get status of an event (general purpose)
  436. *
  437. ******************************************************************************/
  438. acpi_status
  439. acpi_get_gpe_status(acpi_handle gpe_device,
  440. u32 gpe_number, u32 flags, acpi_event_status * event_status)
  441. {
  442. acpi_status status = AE_OK;
  443. struct acpi_gpe_event_info *gpe_event_info;
  444. ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
  445. /* Use semaphore lock if not executing at interrupt level */
  446. if (flags & ACPI_NOT_ISR) {
  447. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  448. if (ACPI_FAILURE(status)) {
  449. return_ACPI_STATUS(status);
  450. }
  451. }
  452. /* Ensure that we have a valid GPE number */
  453. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  454. if (!gpe_event_info) {
  455. status = AE_BAD_PARAMETER;
  456. goto unlock_and_exit;
  457. }
  458. /* Obtain status on the requested GPE number */
  459. status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
  460. unlock_and_exit:
  461. if (flags & ACPI_NOT_ISR) {
  462. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  463. }
  464. return_ACPI_STATUS(status);
  465. }
  466. ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
  467. #endif /* ACPI_FUTURE_USAGE */
  468. /*******************************************************************************
  469. *
  470. * FUNCTION: acpi_install_gpe_block
  471. *
  472. * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
  473. * gpe_block_address - Address and space_iD
  474. * register_count - Number of GPE register pairs in the block
  475. * interrupt_number - H/W interrupt for the block
  476. *
  477. * RETURN: Status
  478. *
  479. * DESCRIPTION: Create and Install a block of GPE registers
  480. *
  481. ******************************************************************************/
  482. acpi_status
  483. acpi_install_gpe_block(acpi_handle gpe_device,
  484. struct acpi_generic_address *gpe_block_address,
  485. u32 register_count, u32 interrupt_number)
  486. {
  487. acpi_status status;
  488. union acpi_operand_object *obj_desc;
  489. struct acpi_namespace_node *node;
  490. struct acpi_gpe_block_info *gpe_block;
  491. ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
  492. if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
  493. return_ACPI_STATUS(AE_BAD_PARAMETER);
  494. }
  495. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  496. if (ACPI_FAILURE(status)) {
  497. return (status);
  498. }
  499. node = acpi_ns_map_handle_to_node(gpe_device);
  500. if (!node) {
  501. status = AE_BAD_PARAMETER;
  502. goto unlock_and_exit;
  503. }
  504. /*
  505. * For user-installed GPE Block Devices, the gpe_block_base_number
  506. * is always zero
  507. */
  508. status =
  509. acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
  510. interrupt_number, &gpe_block);
  511. if (ACPI_FAILURE(status)) {
  512. goto unlock_and_exit;
  513. }
  514. /* Run the _PRW methods and enable the GPEs */
  515. status = acpi_ev_initialize_gpe_block(node, gpe_block);
  516. if (ACPI_FAILURE(status)) {
  517. goto unlock_and_exit;
  518. }
  519. /* Get the device_object attached to the node */
  520. obj_desc = acpi_ns_get_attached_object(node);
  521. if (!obj_desc) {
  522. /* No object, create a new one */
  523. obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
  524. if (!obj_desc) {
  525. status = AE_NO_MEMORY;
  526. goto unlock_and_exit;
  527. }
  528. status =
  529. acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
  530. /* Remove local reference to the object */
  531. acpi_ut_remove_reference(obj_desc);
  532. if (ACPI_FAILURE(status)) {
  533. goto unlock_and_exit;
  534. }
  535. }
  536. /* Install the GPE block in the device_object */
  537. obj_desc->device.gpe_block = gpe_block;
  538. unlock_and_exit:
  539. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  540. return_ACPI_STATUS(status);
  541. }
  542. ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
  543. /*******************************************************************************
  544. *
  545. * FUNCTION: acpi_remove_gpe_block
  546. *
  547. * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
  548. *
  549. * RETURN: Status
  550. *
  551. * DESCRIPTION: Remove a previously installed block of GPE registers
  552. *
  553. ******************************************************************************/
  554. acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
  555. {
  556. union acpi_operand_object *obj_desc;
  557. acpi_status status;
  558. struct acpi_namespace_node *node;
  559. ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
  560. if (!gpe_device) {
  561. return_ACPI_STATUS(AE_BAD_PARAMETER);
  562. }
  563. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  564. if (ACPI_FAILURE(status)) {
  565. return (status);
  566. }
  567. node = acpi_ns_map_handle_to_node(gpe_device);
  568. if (!node) {
  569. status = AE_BAD_PARAMETER;
  570. goto unlock_and_exit;
  571. }
  572. /* Get the device_object attached to the node */
  573. obj_desc = acpi_ns_get_attached_object(node);
  574. if (!obj_desc || !obj_desc->device.gpe_block) {
  575. return_ACPI_STATUS(AE_NULL_OBJECT);
  576. }
  577. /* Delete the GPE block (but not the device_object) */
  578. status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
  579. if (ACPI_SUCCESS(status)) {
  580. obj_desc->device.gpe_block = NULL;
  581. }
  582. unlock_and_exit:
  583. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  584. return_ACPI_STATUS(status);
  585. }
  586. ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)