evxfevnt.c 20 KB

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