evxfevnt.c 19 KB

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