evxfevnt.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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_REPORT_WARNING(("No FADT information present!\n"));
  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_REPORT_ERROR(("Could not transition to ACPI mode\n"));
  76. return_ACPI_STATUS(status);
  77. }
  78. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  79. "Transition to ACPI mode successful\n"));
  80. }
  81. return_ACPI_STATUS(status);
  82. }
  83. /*******************************************************************************
  84. *
  85. * FUNCTION: acpi_disable
  86. *
  87. * PARAMETERS: None
  88. *
  89. * RETURN: Status
  90. *
  91. * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
  92. *
  93. ******************************************************************************/
  94. acpi_status acpi_disable(void)
  95. {
  96. acpi_status status = AE_OK;
  97. ACPI_FUNCTION_TRACE("acpi_disable");
  98. if (!acpi_gbl_FADT) {
  99. ACPI_REPORT_WARNING(("No FADT information present!\n"));
  100. return_ACPI_STATUS(AE_NO_ACPI_TABLES);
  101. }
  102. if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
  103. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  104. "System is already in legacy (non-ACPI) mode\n"));
  105. } else {
  106. /* Transition to LEGACY mode */
  107. status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
  108. if (ACPI_FAILURE(status)) {
  109. ACPI_REPORT_ERROR(("Could not exit ACPI mode to legacy mode"));
  110. return_ACPI_STATUS(status);
  111. }
  112. ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
  113. }
  114. return_ACPI_STATUS(status);
  115. }
  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, ACPI_MTX_LOCK);
  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, ACPI_MTX_LOCK);
  151. if (ACPI_FAILURE(status)) {
  152. return_ACPI_STATUS(status);
  153. }
  154. if (value != 1) {
  155. ACPI_REPORT_ERROR(("Could not enable %s event\n",
  156. acpi_ut_get_event_name(event)));
  157. return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
  158. }
  159. return_ACPI_STATUS(status);
  160. }
  161. EXPORT_SYMBOL(acpi_enable_event);
  162. /*******************************************************************************
  163. *
  164. * FUNCTION: acpi_set_gpe_type
  165. *
  166. * PARAMETERS: gpe_device - Parent GPE Device
  167. * gpe_number - GPE level within the GPE block
  168. * Type - New GPE type
  169. *
  170. * RETURN: Status
  171. *
  172. * DESCRIPTION: Set the type of an individual GPE
  173. *
  174. ******************************************************************************/
  175. acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
  176. {
  177. acpi_status status = AE_OK;
  178. struct acpi_gpe_event_info *gpe_event_info;
  179. ACPI_FUNCTION_TRACE("acpi_set_gpe_type");
  180. /* Ensure that we have a valid GPE number */
  181. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  182. if (!gpe_event_info) {
  183. status = AE_BAD_PARAMETER;
  184. goto unlock_and_exit;
  185. }
  186. if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
  187. return_ACPI_STATUS(AE_OK);
  188. }
  189. /* Set the new type (will disable GPE if currently enabled) */
  190. status = acpi_ev_set_gpe_type(gpe_event_info, type);
  191. unlock_and_exit:
  192. return_ACPI_STATUS(status);
  193. }
  194. EXPORT_SYMBOL(acpi_set_gpe_type);
  195. /*******************************************************************************
  196. *
  197. * FUNCTION: acpi_enable_gpe
  198. *
  199. * PARAMETERS: gpe_device - Parent GPE Device
  200. * gpe_number - GPE level within the GPE block
  201. * Flags - Just enable, or also wake enable?
  202. * Called from ISR or not
  203. *
  204. * RETURN: Status
  205. *
  206. * DESCRIPTION: Enable an ACPI event (general purpose)
  207. *
  208. ******************************************************************************/
  209. acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  210. {
  211. acpi_status status = AE_OK;
  212. struct acpi_gpe_event_info *gpe_event_info;
  213. ACPI_FUNCTION_TRACE("acpi_enable_gpe");
  214. /* Use semaphore lock if not executing at interrupt level */
  215. if (flags & ACPI_NOT_ISR) {
  216. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  217. if (ACPI_FAILURE(status)) {
  218. return_ACPI_STATUS(status);
  219. }
  220. }
  221. /* Ensure that we have a valid GPE number */
  222. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  223. if (!gpe_event_info) {
  224. status = AE_BAD_PARAMETER;
  225. goto unlock_and_exit;
  226. }
  227. /* Perform the enable */
  228. status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
  229. unlock_and_exit:
  230. if (flags & ACPI_NOT_ISR) {
  231. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  232. }
  233. return_ACPI_STATUS(status);
  234. }
  235. EXPORT_SYMBOL(acpi_enable_gpe);
  236. /*******************************************************************************
  237. *
  238. * FUNCTION: acpi_disable_gpe
  239. *
  240. * PARAMETERS: gpe_device - Parent GPE Device
  241. * gpe_number - GPE level within the GPE block
  242. * Flags - Just disable, or also wake disable?
  243. * Called from ISR or not
  244. *
  245. * RETURN: Status
  246. *
  247. * DESCRIPTION: Disable an ACPI event (general purpose)
  248. *
  249. ******************************************************************************/
  250. acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  251. {
  252. acpi_status status = AE_OK;
  253. struct acpi_gpe_event_info *gpe_event_info;
  254. ACPI_FUNCTION_TRACE("acpi_disable_gpe");
  255. /* Use semaphore lock if not executing at interrupt level */
  256. if (flags & ACPI_NOT_ISR) {
  257. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  258. if (ACPI_FAILURE(status)) {
  259. return_ACPI_STATUS(status);
  260. }
  261. }
  262. /* Ensure that we have a valid GPE number */
  263. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  264. if (!gpe_event_info) {
  265. status = AE_BAD_PARAMETER;
  266. goto unlock_and_exit;
  267. }
  268. status = acpi_ev_disable_gpe(gpe_event_info);
  269. unlock_and_exit:
  270. if (flags & ACPI_NOT_ISR) {
  271. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  272. }
  273. return_ACPI_STATUS(status);
  274. }
  275. /*******************************************************************************
  276. *
  277. * FUNCTION: acpi_disable_event
  278. *
  279. * PARAMETERS: Event - The fixed eventto be enabled
  280. * Flags - Reserved
  281. *
  282. * RETURN: Status
  283. *
  284. * DESCRIPTION: Disable an ACPI event (fixed)
  285. *
  286. ******************************************************************************/
  287. acpi_status acpi_disable_event(u32 event, u32 flags)
  288. {
  289. acpi_status status = AE_OK;
  290. u32 value;
  291. ACPI_FUNCTION_TRACE("acpi_disable_event");
  292. /* Decode the Fixed Event */
  293. if (event > ACPI_EVENT_MAX) {
  294. return_ACPI_STATUS(AE_BAD_PARAMETER);
  295. }
  296. /*
  297. * Disable the requested fixed event (by writing a zero to the
  298. * enable register bit)
  299. */
  300. status =
  301. acpi_set_register(acpi_gbl_fixed_event_info[event].
  302. enable_register_id, 0, ACPI_MTX_LOCK);
  303. if (ACPI_FAILURE(status)) {
  304. return_ACPI_STATUS(status);
  305. }
  306. status =
  307. acpi_get_register(acpi_gbl_fixed_event_info[event].
  308. enable_register_id, &value, ACPI_MTX_LOCK);
  309. if (ACPI_FAILURE(status)) {
  310. return_ACPI_STATUS(status);
  311. }
  312. if (value != 0) {
  313. ACPI_REPORT_ERROR(("Could not disable %s events\n",
  314. acpi_ut_get_event_name(event)));
  315. return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
  316. }
  317. return_ACPI_STATUS(status);
  318. }
  319. EXPORT_SYMBOL(acpi_disable_event);
  320. /*******************************************************************************
  321. *
  322. * FUNCTION: acpi_clear_event
  323. *
  324. * PARAMETERS: Event - The fixed event to be cleared
  325. *
  326. * RETURN: Status
  327. *
  328. * DESCRIPTION: Clear an ACPI event (fixed)
  329. *
  330. ******************************************************************************/
  331. acpi_status acpi_clear_event(u32 event)
  332. {
  333. acpi_status status = AE_OK;
  334. ACPI_FUNCTION_TRACE("acpi_clear_event");
  335. /* Decode the Fixed Event */
  336. if (event > ACPI_EVENT_MAX) {
  337. return_ACPI_STATUS(AE_BAD_PARAMETER);
  338. }
  339. /*
  340. * Clear the requested fixed event (By writing a one to the
  341. * status register bit)
  342. */
  343. status =
  344. acpi_set_register(acpi_gbl_fixed_event_info[event].
  345. status_register_id, 1, ACPI_MTX_LOCK);
  346. return_ACPI_STATUS(status);
  347. }
  348. EXPORT_SYMBOL(acpi_clear_event);
  349. /*******************************************************************************
  350. *
  351. * FUNCTION: acpi_clear_gpe
  352. *
  353. * PARAMETERS: gpe_device - Parent GPE Device
  354. * gpe_number - GPE level within the GPE block
  355. * Flags - Called from an ISR or not
  356. *
  357. * RETURN: Status
  358. *
  359. * DESCRIPTION: Clear an ACPI event (general purpose)
  360. *
  361. ******************************************************************************/
  362. acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  363. {
  364. acpi_status status = AE_OK;
  365. struct acpi_gpe_event_info *gpe_event_info;
  366. ACPI_FUNCTION_TRACE("acpi_clear_gpe");
  367. /* Use semaphore lock if not executing at interrupt level */
  368. if (flags & ACPI_NOT_ISR) {
  369. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  370. if (ACPI_FAILURE(status)) {
  371. return_ACPI_STATUS(status);
  372. }
  373. }
  374. /* Ensure that we have a valid GPE number */
  375. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  376. if (!gpe_event_info) {
  377. status = AE_BAD_PARAMETER;
  378. goto unlock_and_exit;
  379. }
  380. status = acpi_hw_clear_gpe(gpe_event_info);
  381. unlock_and_exit:
  382. if (flags & ACPI_NOT_ISR) {
  383. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  384. }
  385. return_ACPI_STATUS(status);
  386. }
  387. #ifdef ACPI_FUTURE_USAGE
  388. /*******************************************************************************
  389. *
  390. * FUNCTION: acpi_get_event_status
  391. *
  392. * PARAMETERS: Event - The fixed event
  393. * event_status - Where the current status of the event will
  394. * be returned
  395. *
  396. * RETURN: Status
  397. *
  398. * DESCRIPTION: Obtains and returns the current status of the event
  399. *
  400. ******************************************************************************/
  401. acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
  402. {
  403. acpi_status status = AE_OK;
  404. ACPI_FUNCTION_TRACE("acpi_get_event_status");
  405. if (!event_status) {
  406. return_ACPI_STATUS(AE_BAD_PARAMETER);
  407. }
  408. /* Decode the Fixed Event */
  409. if (event > ACPI_EVENT_MAX) {
  410. return_ACPI_STATUS(AE_BAD_PARAMETER);
  411. }
  412. /* Get the status of the requested fixed event */
  413. status =
  414. acpi_get_register(acpi_gbl_fixed_event_info[event].
  415. status_register_id, event_status, ACPI_MTX_LOCK);
  416. return_ACPI_STATUS(status);
  417. }
  418. /*******************************************************************************
  419. *
  420. * FUNCTION: acpi_get_gpe_status
  421. *
  422. * PARAMETERS: gpe_device - Parent GPE Device
  423. * gpe_number - GPE level within the GPE block
  424. * Flags - Called from an ISR or not
  425. * event_status - Where the current status of the event will
  426. * be returned
  427. *
  428. * RETURN: Status
  429. *
  430. * DESCRIPTION: Get status of an event (general purpose)
  431. *
  432. ******************************************************************************/
  433. acpi_status
  434. acpi_get_gpe_status(acpi_handle gpe_device,
  435. u32 gpe_number, u32 flags, acpi_event_status * event_status)
  436. {
  437. acpi_status status = AE_OK;
  438. struct acpi_gpe_event_info *gpe_event_info;
  439. ACPI_FUNCTION_TRACE("acpi_get_gpe_status");
  440. /* Use semaphore lock if not executing at interrupt level */
  441. if (flags & ACPI_NOT_ISR) {
  442. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  443. if (ACPI_FAILURE(status)) {
  444. return_ACPI_STATUS(status);
  445. }
  446. }
  447. /* Ensure that we have a valid GPE number */
  448. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  449. if (!gpe_event_info) {
  450. status = AE_BAD_PARAMETER;
  451. goto unlock_and_exit;
  452. }
  453. /* Obtain status on the requested GPE number */
  454. status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
  455. unlock_and_exit:
  456. if (flags & ACPI_NOT_ISR) {
  457. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  458. }
  459. return_ACPI_STATUS(status);
  460. }
  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. 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. EXPORT_SYMBOL(acpi_remove_gpe_block);