evxfevnt.c 20 KB

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