evxfevnt.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /******************************************************************************
  2. *
  3. * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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_DEBUG_PRINT((ACPI_DB_WARN,
  66. "No FADT information present!\n"));
  67. return_ACPI_STATUS(AE_NO_ACPI_TABLES);
  68. }
  69. if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
  70. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  71. "System is already in ACPI mode\n"));
  72. } else {
  73. /* Transition to ACPI mode */
  74. status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
  75. if (ACPI_FAILURE(status)) {
  76. ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n"));
  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_DEBUG_PRINT((ACPI_DB_WARN,
  101. "No FADT information present!\n"));
  102. return_ACPI_STATUS(AE_NO_ACPI_TABLES);
  103. }
  104. if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
  105. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  106. "System is already in legacy (non-ACPI) mode\n"));
  107. } else {
  108. /* Transition to LEGACY mode */
  109. status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
  110. if (ACPI_FAILURE(status)) {
  111. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  112. "Could not exit ACPI mode to legacy mode"));
  113. return_ACPI_STATUS(status);
  114. }
  115. ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
  116. }
  117. return_ACPI_STATUS(status);
  118. }
  119. /*******************************************************************************
  120. *
  121. * FUNCTION: acpi_enable_event
  122. *
  123. * PARAMETERS: Event - The fixed eventto be enabled
  124. * Flags - Reserved
  125. *
  126. * RETURN: Status
  127. *
  128. * DESCRIPTION: Enable an ACPI event (fixed)
  129. *
  130. ******************************************************************************/
  131. acpi_status acpi_enable_event(u32 event, u32 flags)
  132. {
  133. acpi_status status = AE_OK;
  134. u32 value;
  135. ACPI_FUNCTION_TRACE("acpi_enable_event");
  136. /* Decode the Fixed Event */
  137. if (event > ACPI_EVENT_MAX) {
  138. return_ACPI_STATUS(AE_BAD_PARAMETER);
  139. }
  140. /*
  141. * Enable the requested fixed event (by writing a one to the
  142. * enable register bit)
  143. */
  144. status =
  145. acpi_set_register(acpi_gbl_fixed_event_info[event].
  146. enable_register_id, 1, ACPI_MTX_LOCK);
  147. if (ACPI_FAILURE(status)) {
  148. return_ACPI_STATUS(status);
  149. }
  150. /* Make sure that the hardware responded */
  151. status =
  152. acpi_get_register(acpi_gbl_fixed_event_info[event].
  153. enable_register_id, &value, ACPI_MTX_LOCK);
  154. if (ACPI_FAILURE(status)) {
  155. return_ACPI_STATUS(status);
  156. }
  157. if (value != 1) {
  158. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  159. "Could not enable %s event\n",
  160. acpi_ut_get_event_name(event)));
  161. return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
  162. }
  163. return_ACPI_STATUS(status);
  164. }
  165. EXPORT_SYMBOL(acpi_enable_event);
  166. /*******************************************************************************
  167. *
  168. * FUNCTION: acpi_set_gpe_type
  169. *
  170. * PARAMETERS: gpe_device - Parent GPE Device
  171. * gpe_number - GPE level within the GPE block
  172. * Type - New GPE type
  173. *
  174. * RETURN: Status
  175. *
  176. * DESCRIPTION: Set the type of an individual GPE
  177. *
  178. ******************************************************************************/
  179. acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
  180. {
  181. acpi_status status = AE_OK;
  182. struct acpi_gpe_event_info *gpe_event_info;
  183. ACPI_FUNCTION_TRACE("acpi_set_gpe_type");
  184. /* Ensure that we have a valid GPE number */
  185. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  186. if (!gpe_event_info) {
  187. status = AE_BAD_PARAMETER;
  188. goto unlock_and_exit;
  189. }
  190. if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
  191. return_ACPI_STATUS(AE_OK);
  192. }
  193. /* Set the new type (will disable GPE if currently enabled) */
  194. status = acpi_ev_set_gpe_type(gpe_event_info, type);
  195. unlock_and_exit:
  196. return_ACPI_STATUS(status);
  197. }
  198. EXPORT_SYMBOL(acpi_set_gpe_type);
  199. /*******************************************************************************
  200. *
  201. * FUNCTION: acpi_enable_gpe
  202. *
  203. * PARAMETERS: gpe_device - Parent GPE Device
  204. * gpe_number - GPE level within the GPE block
  205. * Flags - Just enable, or also wake enable?
  206. * Called from ISR or not
  207. *
  208. * RETURN: Status
  209. *
  210. * DESCRIPTION: Enable an ACPI event (general purpose)
  211. *
  212. ******************************************************************************/
  213. acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  214. {
  215. acpi_status status = AE_OK;
  216. struct acpi_gpe_event_info *gpe_event_info;
  217. ACPI_FUNCTION_TRACE("acpi_enable_gpe");
  218. /* Use semaphore lock if not executing at interrupt level */
  219. if (flags & ACPI_NOT_ISR) {
  220. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  221. if (ACPI_FAILURE(status)) {
  222. return_ACPI_STATUS(status);
  223. }
  224. }
  225. /* Ensure that we have a valid GPE number */
  226. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  227. if (!gpe_event_info) {
  228. status = AE_BAD_PARAMETER;
  229. goto unlock_and_exit;
  230. }
  231. /* Perform the enable */
  232. status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
  233. unlock_and_exit:
  234. if (flags & ACPI_NOT_ISR) {
  235. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  236. }
  237. return_ACPI_STATUS(status);
  238. }
  239. EXPORT_SYMBOL(acpi_enable_gpe);
  240. /*******************************************************************************
  241. *
  242. * FUNCTION: acpi_disable_gpe
  243. *
  244. * PARAMETERS: gpe_device - Parent GPE Device
  245. * gpe_number - GPE level within the GPE block
  246. * Flags - Just disable, or also wake disable?
  247. * Called from ISR or not
  248. *
  249. * RETURN: Status
  250. *
  251. * DESCRIPTION: Disable an ACPI event (general purpose)
  252. *
  253. ******************************************************************************/
  254. acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  255. {
  256. acpi_status status = AE_OK;
  257. struct acpi_gpe_event_info *gpe_event_info;
  258. ACPI_FUNCTION_TRACE("acpi_disable_gpe");
  259. /* Use semaphore lock if not executing at interrupt level */
  260. if (flags & ACPI_NOT_ISR) {
  261. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  262. if (ACPI_FAILURE(status)) {
  263. return_ACPI_STATUS(status);
  264. }
  265. }
  266. /* Ensure that we have a valid GPE number */
  267. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  268. if (!gpe_event_info) {
  269. status = AE_BAD_PARAMETER;
  270. goto unlock_and_exit;
  271. }
  272. status = acpi_ev_disable_gpe(gpe_event_info);
  273. unlock_and_exit:
  274. if (flags & ACPI_NOT_ISR) {
  275. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  276. }
  277. return_ACPI_STATUS(status);
  278. }
  279. /*******************************************************************************
  280. *
  281. * FUNCTION: acpi_disable_event
  282. *
  283. * PARAMETERS: Event - The fixed eventto be enabled
  284. * Flags - Reserved
  285. *
  286. * RETURN: Status
  287. *
  288. * DESCRIPTION: Disable an ACPI event (fixed)
  289. *
  290. ******************************************************************************/
  291. acpi_status acpi_disable_event(u32 event, u32 flags)
  292. {
  293. acpi_status status = AE_OK;
  294. u32 value;
  295. ACPI_FUNCTION_TRACE("acpi_disable_event");
  296. /* Decode the Fixed Event */
  297. if (event > ACPI_EVENT_MAX) {
  298. return_ACPI_STATUS(AE_BAD_PARAMETER);
  299. }
  300. /*
  301. * Disable the requested fixed event (by writing a zero to the
  302. * enable register bit)
  303. */
  304. status =
  305. acpi_set_register(acpi_gbl_fixed_event_info[event].
  306. enable_register_id, 0, ACPI_MTX_LOCK);
  307. if (ACPI_FAILURE(status)) {
  308. return_ACPI_STATUS(status);
  309. }
  310. status =
  311. acpi_get_register(acpi_gbl_fixed_event_info[event].
  312. enable_register_id, &value, ACPI_MTX_LOCK);
  313. if (ACPI_FAILURE(status)) {
  314. return_ACPI_STATUS(status);
  315. }
  316. if (value != 0) {
  317. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  318. "Could not disable %s events\n",
  319. acpi_ut_get_event_name(event)));
  320. return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
  321. }
  322. return_ACPI_STATUS(status);
  323. }
  324. EXPORT_SYMBOL(acpi_disable_event);
  325. /*******************************************************************************
  326. *
  327. * FUNCTION: acpi_clear_event
  328. *
  329. * PARAMETERS: Event - The fixed event to be cleared
  330. *
  331. * RETURN: Status
  332. *
  333. * DESCRIPTION: Clear an ACPI event (fixed)
  334. *
  335. ******************************************************************************/
  336. acpi_status acpi_clear_event(u32 event)
  337. {
  338. acpi_status status = AE_OK;
  339. ACPI_FUNCTION_TRACE("acpi_clear_event");
  340. /* Decode the Fixed Event */
  341. if (event > ACPI_EVENT_MAX) {
  342. return_ACPI_STATUS(AE_BAD_PARAMETER);
  343. }
  344. /*
  345. * Clear the requested fixed event (By writing a one to the
  346. * status register bit)
  347. */
  348. status =
  349. acpi_set_register(acpi_gbl_fixed_event_info[event].
  350. status_register_id, 1, ACPI_MTX_LOCK);
  351. return_ACPI_STATUS(status);
  352. }
  353. EXPORT_SYMBOL(acpi_clear_event);
  354. /*******************************************************************************
  355. *
  356. * FUNCTION: acpi_clear_gpe
  357. *
  358. * PARAMETERS: gpe_device - Parent GPE Device
  359. * gpe_number - GPE level within the GPE block
  360. * Flags - Called from an ISR or not
  361. *
  362. * RETURN: Status
  363. *
  364. * DESCRIPTION: Clear an ACPI event (general purpose)
  365. *
  366. ******************************************************************************/
  367. acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
  368. {
  369. acpi_status status = AE_OK;
  370. struct acpi_gpe_event_info *gpe_event_info;
  371. ACPI_FUNCTION_TRACE("acpi_clear_gpe");
  372. /* Use semaphore lock if not executing at interrupt level */
  373. if (flags & ACPI_NOT_ISR) {
  374. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  375. if (ACPI_FAILURE(status)) {
  376. return_ACPI_STATUS(status);
  377. }
  378. }
  379. /* Ensure that we have a valid GPE number */
  380. gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
  381. if (!gpe_event_info) {
  382. status = AE_BAD_PARAMETER;
  383. goto unlock_and_exit;
  384. }
  385. status = acpi_hw_clear_gpe(gpe_event_info);
  386. unlock_and_exit:
  387. if (flags & ACPI_NOT_ISR) {
  388. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  389. }
  390. return_ACPI_STATUS(status);
  391. }
  392. #ifdef ACPI_FUTURE_USAGE
  393. /*******************************************************************************
  394. *
  395. * FUNCTION: acpi_get_event_status
  396. *
  397. * PARAMETERS: Event - The fixed event
  398. * event_status - Where the current status of the event will
  399. * be returned
  400. *
  401. * RETURN: Status
  402. *
  403. * DESCRIPTION: Obtains and returns the current status of the event
  404. *
  405. ******************************************************************************/
  406. acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
  407. {
  408. acpi_status status = AE_OK;
  409. ACPI_FUNCTION_TRACE("acpi_get_event_status");
  410. if (!event_status) {
  411. return_ACPI_STATUS(AE_BAD_PARAMETER);
  412. }
  413. /* Decode the Fixed Event */
  414. if (event > ACPI_EVENT_MAX) {
  415. return_ACPI_STATUS(AE_BAD_PARAMETER);
  416. }
  417. /* Get the status of the requested fixed event */
  418. status =
  419. acpi_get_register(acpi_gbl_fixed_event_info[event].
  420. status_register_id, event_status, ACPI_MTX_LOCK);
  421. return_ACPI_STATUS(status);
  422. }
  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. #endif /* ACPI_FUTURE_USAGE */
  467. /*******************************************************************************
  468. *
  469. * FUNCTION: acpi_install_gpe_block
  470. *
  471. * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
  472. * gpe_block_address - Address and space_iD
  473. * register_count - Number of GPE register pairs in the block
  474. * interrupt_number - H/W interrupt for the block
  475. *
  476. * RETURN: Status
  477. *
  478. * DESCRIPTION: Create and Install a block of GPE registers
  479. *
  480. ******************************************************************************/
  481. acpi_status
  482. acpi_install_gpe_block(acpi_handle gpe_device,
  483. struct acpi_generic_address *gpe_block_address,
  484. u32 register_count, u32 interrupt_number)
  485. {
  486. acpi_status status;
  487. union acpi_operand_object *obj_desc;
  488. struct acpi_namespace_node *node;
  489. struct acpi_gpe_block_info *gpe_block;
  490. ACPI_FUNCTION_TRACE("acpi_install_gpe_block");
  491. if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
  492. return_ACPI_STATUS(AE_BAD_PARAMETER);
  493. }
  494. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  495. if (ACPI_FAILURE(status)) {
  496. return (status);
  497. }
  498. node = acpi_ns_map_handle_to_node(gpe_device);
  499. if (!node) {
  500. status = AE_BAD_PARAMETER;
  501. goto unlock_and_exit;
  502. }
  503. /*
  504. * For user-installed GPE Block Devices, the gpe_block_base_number
  505. * is always zero
  506. */
  507. status =
  508. acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
  509. interrupt_number, &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);