utdelete.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*******************************************************************************
  2. *
  3. * Module Name: utdelete - object deletion and reference count utilities
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2017, Intel Corp.
  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 <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acinterp.h"
  45. #include "acnamesp.h"
  46. #include "acevents.h"
  47. #define _COMPONENT ACPI_UTILITIES
  48. ACPI_MODULE_NAME("utdelete")
  49. /* Local prototypes */
  50. static void acpi_ut_delete_internal_obj(union acpi_operand_object *object);
  51. static void
  52. acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action);
  53. /*******************************************************************************
  54. *
  55. * FUNCTION: acpi_ut_delete_internal_obj
  56. *
  57. * PARAMETERS: object - Object to be deleted
  58. *
  59. * RETURN: None
  60. *
  61. * DESCRIPTION: Low level object deletion, after reference counts have been
  62. * updated (All reference counts, including sub-objects!)
  63. *
  64. ******************************************************************************/
  65. static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
  66. {
  67. void *obj_pointer = NULL;
  68. union acpi_operand_object *handler_desc;
  69. union acpi_operand_object *second_desc;
  70. union acpi_operand_object *next_desc;
  71. union acpi_operand_object *start_desc;
  72. union acpi_operand_object **last_obj_ptr;
  73. ACPI_FUNCTION_TRACE_PTR(ut_delete_internal_obj, object);
  74. if (!object) {
  75. return_VOID;
  76. }
  77. /*
  78. * Must delete or free any pointers within the object that are not
  79. * actual ACPI objects (for example, a raw buffer pointer).
  80. */
  81. switch (object->common.type) {
  82. case ACPI_TYPE_STRING:
  83. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  84. "**** String %p, ptr %p\n", object,
  85. object->string.pointer));
  86. /* Free the actual string buffer */
  87. if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
  88. /* But only if it is NOT a pointer into an ACPI table */
  89. obj_pointer = object->string.pointer;
  90. }
  91. break;
  92. case ACPI_TYPE_BUFFER:
  93. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  94. "**** Buffer %p, ptr %p\n", object,
  95. object->buffer.pointer));
  96. /* Free the actual buffer */
  97. if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
  98. /* But only if it is NOT a pointer into an ACPI table */
  99. obj_pointer = object->buffer.pointer;
  100. }
  101. break;
  102. case ACPI_TYPE_PACKAGE:
  103. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  104. " **** Package of count %X\n",
  105. object->package.count));
  106. /*
  107. * Elements of the package are not handled here, they are deleted
  108. * separately
  109. */
  110. /* Free the (variable length) element pointer array */
  111. obj_pointer = object->package.elements;
  112. break;
  113. /*
  114. * These objects have a possible list of notify handlers.
  115. * Device object also may have a GPE block.
  116. */
  117. case ACPI_TYPE_DEVICE:
  118. if (object->device.gpe_block) {
  119. (void)acpi_ev_delete_gpe_block(object->device.
  120. gpe_block);
  121. }
  122. /*lint -fallthrough */
  123. case ACPI_TYPE_PROCESSOR:
  124. case ACPI_TYPE_THERMAL:
  125. /* Walk the address handler list for this object */
  126. handler_desc = object->common_notify.handler;
  127. while (handler_desc) {
  128. next_desc = handler_desc->address_space.next;
  129. acpi_ut_remove_reference(handler_desc);
  130. handler_desc = next_desc;
  131. }
  132. break;
  133. case ACPI_TYPE_MUTEX:
  134. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  135. "***** Mutex %p, OS Mutex %p\n",
  136. object, object->mutex.os_mutex));
  137. if (object == acpi_gbl_global_lock_mutex) {
  138. /* Global Lock has extra semaphore */
  139. (void)
  140. acpi_os_delete_semaphore
  141. (acpi_gbl_global_lock_semaphore);
  142. acpi_gbl_global_lock_semaphore = NULL;
  143. acpi_os_delete_mutex(object->mutex.os_mutex);
  144. acpi_gbl_global_lock_mutex = NULL;
  145. } else {
  146. acpi_ex_unlink_mutex(object);
  147. acpi_os_delete_mutex(object->mutex.os_mutex);
  148. }
  149. break;
  150. case ACPI_TYPE_EVENT:
  151. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  152. "***** Event %p, OS Semaphore %p\n",
  153. object, object->event.os_semaphore));
  154. (void)acpi_os_delete_semaphore(object->event.os_semaphore);
  155. object->event.os_semaphore = NULL;
  156. break;
  157. case ACPI_TYPE_METHOD:
  158. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  159. "***** Method %p\n", object));
  160. /* Delete the method mutex if it exists */
  161. if (object->method.mutex) {
  162. acpi_os_delete_mutex(object->method.mutex->mutex.
  163. os_mutex);
  164. acpi_ut_delete_object_desc(object->method.mutex);
  165. object->method.mutex = NULL;
  166. }
  167. if (object->method.node) {
  168. object->method.node = NULL;
  169. }
  170. break;
  171. case ACPI_TYPE_REGION:
  172. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  173. "***** Region %p\n", object));
  174. /*
  175. * Update address_range list. However, only permanent regions
  176. * are installed in this list. (Not created within a method)
  177. */
  178. if (!(object->region.node->flags & ANOBJ_TEMPORARY)) {
  179. acpi_ut_remove_address_range(object->region.space_id,
  180. object->region.node);
  181. }
  182. second_desc = acpi_ns_get_secondary_object(object);
  183. if (second_desc) {
  184. /*
  185. * Free the region_context if and only if the handler is one of the
  186. * default handlers -- and therefore, we created the context object
  187. * locally, it was not created by an external caller.
  188. */
  189. handler_desc = object->region.handler;
  190. if (handler_desc) {
  191. next_desc =
  192. handler_desc->address_space.region_list;
  193. start_desc = next_desc;
  194. last_obj_ptr =
  195. &handler_desc->address_space.region_list;
  196. /* Remove the region object from the handler list */
  197. while (next_desc) {
  198. if (next_desc == object) {
  199. *last_obj_ptr =
  200. next_desc->region.next;
  201. break;
  202. }
  203. /* Walk the linked list of handlers */
  204. last_obj_ptr = &next_desc->region.next;
  205. next_desc = next_desc->region.next;
  206. /* Prevent infinite loop if list is corrupted */
  207. if (next_desc == start_desc) {
  208. ACPI_ERROR((AE_INFO,
  209. "Circular region list in address handler object %p",
  210. handler_desc));
  211. return_VOID;
  212. }
  213. }
  214. if (handler_desc->address_space.handler_flags &
  215. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
  216. /* Deactivate region and free region context */
  217. if (handler_desc->address_space.setup) {
  218. (void)handler_desc->
  219. address_space.setup(object,
  220. ACPI_REGION_DEACTIVATE,
  221. handler_desc->
  222. address_space.
  223. context,
  224. &second_desc->
  225. extra.
  226. region_context);
  227. }
  228. }
  229. acpi_ut_remove_reference(handler_desc);
  230. }
  231. /* Now we can free the Extra object */
  232. acpi_ut_delete_object_desc(second_desc);
  233. }
  234. break;
  235. case ACPI_TYPE_BUFFER_FIELD:
  236. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  237. "***** Buffer Field %p\n", object));
  238. second_desc = acpi_ns_get_secondary_object(object);
  239. if (second_desc) {
  240. acpi_ut_delete_object_desc(second_desc);
  241. }
  242. break;
  243. case ACPI_TYPE_LOCAL_BANK_FIELD:
  244. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  245. "***** Bank Field %p\n", object));
  246. second_desc = acpi_ns_get_secondary_object(object);
  247. if (second_desc) {
  248. acpi_ut_delete_object_desc(second_desc);
  249. }
  250. break;
  251. default:
  252. break;
  253. }
  254. /* Free any allocated memory (pointer within the object) found above */
  255. if (obj_pointer) {
  256. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  257. "Deleting Object Subptr %p\n", obj_pointer));
  258. ACPI_FREE(obj_pointer);
  259. }
  260. /* Now the object can be safely deleted */
  261. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
  262. object, acpi_ut_get_object_type_name(object)));
  263. acpi_ut_delete_object_desc(object);
  264. return_VOID;
  265. }
  266. /*******************************************************************************
  267. *
  268. * FUNCTION: acpi_ut_delete_internal_object_list
  269. *
  270. * PARAMETERS: obj_list - Pointer to the list to be deleted
  271. *
  272. * RETURN: None
  273. *
  274. * DESCRIPTION: This function deletes an internal object list, including both
  275. * simple objects and package objects
  276. *
  277. ******************************************************************************/
  278. void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
  279. {
  280. union acpi_operand_object **internal_obj;
  281. ACPI_FUNCTION_ENTRY();
  282. /* Walk the null-terminated internal list */
  283. for (internal_obj = obj_list; *internal_obj; internal_obj++) {
  284. acpi_ut_remove_reference(*internal_obj);
  285. }
  286. /* Free the combined parameter pointer list and object array */
  287. ACPI_FREE(obj_list);
  288. return;
  289. }
  290. /*******************************************************************************
  291. *
  292. * FUNCTION: acpi_ut_update_ref_count
  293. *
  294. * PARAMETERS: object - Object whose ref count is to be updated
  295. * action - What to do (REF_INCREMENT or REF_DECREMENT)
  296. *
  297. * RETURN: None. Sets new reference count within the object
  298. *
  299. * DESCRIPTION: Modify the reference count for an internal acpi object
  300. *
  301. ******************************************************************************/
  302. static void
  303. acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
  304. {
  305. u16 original_count;
  306. u16 new_count = 0;
  307. acpi_cpu_flags lock_flags;
  308. ACPI_FUNCTION_NAME(ut_update_ref_count);
  309. if (!object) {
  310. return;
  311. }
  312. /*
  313. * Always get the reference count lock. Note: Interpreter and/or
  314. * Namespace is not always locked when this function is called.
  315. */
  316. lock_flags = acpi_os_acquire_lock(acpi_gbl_reference_count_lock);
  317. original_count = object->common.reference_count;
  318. /* Perform the reference count action (increment, decrement) */
  319. switch (action) {
  320. case REF_INCREMENT:
  321. new_count = original_count + 1;
  322. object->common.reference_count = new_count;
  323. acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
  324. /* The current reference count should never be zero here */
  325. if (!original_count) {
  326. ACPI_WARNING((AE_INFO,
  327. "Obj %p, Reference Count was zero before increment\n",
  328. object));
  329. }
  330. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  331. "Obj %p Type %.2X [%s] Refs %.2X [Incremented]\n",
  332. object, object->common.type,
  333. acpi_ut_get_object_type_name(object),
  334. new_count));
  335. break;
  336. case REF_DECREMENT:
  337. /* The current reference count must be non-zero */
  338. if (original_count) {
  339. new_count = original_count - 1;
  340. object->common.reference_count = new_count;
  341. }
  342. acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
  343. if (!original_count) {
  344. ACPI_WARNING((AE_INFO,
  345. "Obj %p, Reference Count is already zero, cannot decrement\n",
  346. object));
  347. }
  348. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  349. "Obj %p Type %.2X Refs %.2X [Decremented]\n",
  350. object, object->common.type, new_count));
  351. /* Actually delete the object on a reference count of zero */
  352. if (new_count == 0) {
  353. acpi_ut_delete_internal_obj(object);
  354. }
  355. break;
  356. default:
  357. acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
  358. ACPI_ERROR((AE_INFO, "Unknown Reference Count action (0x%X)",
  359. action));
  360. return;
  361. }
  362. /*
  363. * Sanity check the reference count, for debug purposes only.
  364. * (A deleted object will have a huge reference count)
  365. */
  366. if (new_count > ACPI_MAX_REFERENCE_COUNT) {
  367. ACPI_WARNING((AE_INFO,
  368. "Large Reference Count (0x%X) in object %p, Type=0x%.2X",
  369. new_count, object, object->common.type));
  370. }
  371. }
  372. /*******************************************************************************
  373. *
  374. * FUNCTION: acpi_ut_update_object_reference
  375. *
  376. * PARAMETERS: object - Increment ref count for this object
  377. * and all sub-objects
  378. * action - Either REF_INCREMENT or REF_DECREMENT
  379. *
  380. * RETURN: Status
  381. *
  382. * DESCRIPTION: Increment the object reference count
  383. *
  384. * Object references are incremented when:
  385. * 1) An object is attached to a Node (namespace object)
  386. * 2) An object is copied (all subobjects must be incremented)
  387. *
  388. * Object references are decremented when:
  389. * 1) An object is detached from an Node
  390. *
  391. ******************************************************************************/
  392. acpi_status
  393. acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
  394. {
  395. acpi_status status = AE_OK;
  396. union acpi_generic_state *state_list = NULL;
  397. union acpi_operand_object *next_object = NULL;
  398. union acpi_operand_object *prev_object;
  399. union acpi_generic_state *state;
  400. u32 i;
  401. ACPI_FUNCTION_NAME(ut_update_object_reference);
  402. while (object) {
  403. /* Make sure that this isn't a namespace handle */
  404. if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
  405. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  406. "Object %p is NS handle\n", object));
  407. return (AE_OK);
  408. }
  409. /*
  410. * All sub-objects must have their reference count incremented
  411. * also. Different object types have different subobjects.
  412. */
  413. switch (object->common.type) {
  414. case ACPI_TYPE_DEVICE:
  415. case ACPI_TYPE_PROCESSOR:
  416. case ACPI_TYPE_POWER:
  417. case ACPI_TYPE_THERMAL:
  418. /*
  419. * Update the notify objects for these types (if present)
  420. * Two lists, system and device notify handlers.
  421. */
  422. for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
  423. prev_object =
  424. object->common_notify.notify_list[i];
  425. while (prev_object) {
  426. next_object =
  427. prev_object->notify.next[i];
  428. acpi_ut_update_ref_count(prev_object,
  429. action);
  430. prev_object = next_object;
  431. }
  432. }
  433. break;
  434. case ACPI_TYPE_PACKAGE:
  435. /*
  436. * We must update all the sub-objects of the package,
  437. * each of whom may have their own sub-objects.
  438. */
  439. for (i = 0; i < object->package.count; i++) {
  440. /*
  441. * Null package elements are legal and can be simply
  442. * ignored.
  443. */
  444. next_object = object->package.elements[i];
  445. if (!next_object) {
  446. continue;
  447. }
  448. switch (next_object->common.type) {
  449. case ACPI_TYPE_INTEGER:
  450. case ACPI_TYPE_STRING:
  451. case ACPI_TYPE_BUFFER:
  452. /*
  453. * For these very simple sub-objects, we can just
  454. * update the reference count here and continue.
  455. * Greatly increases performance of this operation.
  456. */
  457. acpi_ut_update_ref_count(next_object,
  458. action);
  459. break;
  460. default:
  461. /*
  462. * For complex sub-objects, push them onto the stack
  463. * for later processing (this eliminates recursion.)
  464. */
  465. status =
  466. acpi_ut_create_update_state_and_push
  467. (next_object, action, &state_list);
  468. if (ACPI_FAILURE(status)) {
  469. goto error_exit;
  470. }
  471. break;
  472. }
  473. }
  474. next_object = NULL;
  475. break;
  476. case ACPI_TYPE_BUFFER_FIELD:
  477. next_object = object->buffer_field.buffer_obj;
  478. break;
  479. case ACPI_TYPE_LOCAL_REGION_FIELD:
  480. next_object = object->field.region_obj;
  481. break;
  482. case ACPI_TYPE_LOCAL_BANK_FIELD:
  483. next_object = object->bank_field.bank_obj;
  484. status =
  485. acpi_ut_create_update_state_and_push(object->
  486. bank_field.
  487. region_obj,
  488. action,
  489. &state_list);
  490. if (ACPI_FAILURE(status)) {
  491. goto error_exit;
  492. }
  493. break;
  494. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  495. next_object = object->index_field.index_obj;
  496. status =
  497. acpi_ut_create_update_state_and_push(object->
  498. index_field.
  499. data_obj,
  500. action,
  501. &state_list);
  502. if (ACPI_FAILURE(status)) {
  503. goto error_exit;
  504. }
  505. break;
  506. case ACPI_TYPE_LOCAL_REFERENCE:
  507. /*
  508. * The target of an Index (a package, string, or buffer) or a named
  509. * reference must track changes to the ref count of the index or
  510. * target object.
  511. */
  512. if ((object->reference.class == ACPI_REFCLASS_INDEX) ||
  513. (object->reference.class == ACPI_REFCLASS_NAME)) {
  514. next_object = object->reference.object;
  515. }
  516. break;
  517. case ACPI_TYPE_REGION:
  518. default:
  519. break; /* No subobjects for all other types */
  520. }
  521. /*
  522. * Now we can update the count in the main object. This can only
  523. * happen after we update the sub-objects in case this causes the
  524. * main object to be deleted.
  525. */
  526. acpi_ut_update_ref_count(object, action);
  527. object = NULL;
  528. /* Move on to the next object to be updated */
  529. if (next_object) {
  530. object = next_object;
  531. next_object = NULL;
  532. } else if (state_list) {
  533. state = acpi_ut_pop_generic_state(&state_list);
  534. object = state->update.object;
  535. acpi_ut_delete_generic_state(state);
  536. }
  537. }
  538. return (AE_OK);
  539. error_exit:
  540. ACPI_EXCEPTION((AE_INFO, status,
  541. "Could not update object reference count"));
  542. /* Free any stacked Update State objects */
  543. while (state_list) {
  544. state = acpi_ut_pop_generic_state(&state_list);
  545. acpi_ut_delete_generic_state(state);
  546. }
  547. return (status);
  548. }
  549. /*******************************************************************************
  550. *
  551. * FUNCTION: acpi_ut_add_reference
  552. *
  553. * PARAMETERS: object - Object whose reference count is to be
  554. * incremented
  555. *
  556. * RETURN: None
  557. *
  558. * DESCRIPTION: Add one reference to an ACPI object
  559. *
  560. ******************************************************************************/
  561. void acpi_ut_add_reference(union acpi_operand_object *object)
  562. {
  563. ACPI_FUNCTION_NAME(ut_add_reference);
  564. /* Ensure that we have a valid object */
  565. if (!acpi_ut_valid_internal_object(object)) {
  566. return;
  567. }
  568. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  569. "Obj %p Current Refs=%X [To Be Incremented]\n",
  570. object, object->common.reference_count));
  571. /* Increment the reference count */
  572. (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
  573. return;
  574. }
  575. /*******************************************************************************
  576. *
  577. * FUNCTION: acpi_ut_remove_reference
  578. *
  579. * PARAMETERS: object - Object whose ref count will be decremented
  580. *
  581. * RETURN: None
  582. *
  583. * DESCRIPTION: Decrement the reference count of an ACPI internal object
  584. *
  585. ******************************************************************************/
  586. void acpi_ut_remove_reference(union acpi_operand_object *object)
  587. {
  588. ACPI_FUNCTION_NAME(ut_remove_reference);
  589. /*
  590. * Allow a NULL pointer to be passed in, just ignore it. This saves
  591. * each caller from having to check. Also, ignore NS nodes.
  592. */
  593. if (!object ||
  594. (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
  595. return;
  596. }
  597. /* Ensure that we have a valid object */
  598. if (!acpi_ut_valid_internal_object(object)) {
  599. return;
  600. }
  601. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  602. "Obj %p Current Refs=%X [To Be Decremented]\n",
  603. object, object->common.reference_count));
  604. /*
  605. * Decrement the reference count, and only actually delete the object
  606. * if the reference count becomes 0. (Must also decrement the ref count
  607. * of all subobjects!)
  608. */
  609. (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
  610. return;
  611. }