evxfevnt.c 19 KB

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