Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: utdelete - object deletion and reference count utilities |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
Len Brown | 75a44ce | 2008-04-23 23:00:13 -0400 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2008, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
| 45 | #include <acpi/acinterp.h> |
| 46 | #include <acpi/acnamesp.h> |
| 47 | #include <acpi/acevents.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | #define _COMPONENT ACPI_UTILITIES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("utdelete") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | /* Local prototypes */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 53 | static void acpi_ut_delete_internal_obj(union acpi_operand_object *object); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 54 | |
| 55 | static void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | /******************************************************************************* |
| 59 | * |
| 60 | * FUNCTION: acpi_ut_delete_internal_obj |
| 61 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 62 | * PARAMETERS: Object - Object to be deleted |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | * |
| 64 | * RETURN: None |
| 65 | * |
| 66 | * DESCRIPTION: Low level object deletion, after reference counts have been |
| 67 | * updated (All reference counts, including sub-objects!) |
| 68 | * |
| 69 | ******************************************************************************/ |
| 70 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 71 | static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 73 | void *obj_pointer = NULL; |
| 74 | union acpi_operand_object *handler_desc; |
| 75 | union acpi_operand_object *second_desc; |
| 76 | union acpi_operand_object *next_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 78 | ACPI_FUNCTION_TRACE_PTR(ut_delete_internal_obj, object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
| 80 | if (!object) { |
| 81 | return_VOID; |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | * Must delete or free any pointers within the object that are not |
| 86 | * actual ACPI objects (for example, a raw buffer pointer). |
| 87 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | switch (ACPI_GET_OBJECT_TYPE(object)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | case ACPI_TYPE_STRING: |
| 90 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 91 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 92 | "**** String %p, ptr %p\n", object, |
| 93 | object->string.pointer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | /* Free the actual string buffer */ |
| 96 | |
| 97 | if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* But only if it is NOT a pointer into an ACPI table */ |
| 100 | |
| 101 | obj_pointer = object->string.pointer; |
| 102 | } |
| 103 | break; |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | case ACPI_TYPE_BUFFER: |
| 106 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 107 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 108 | "**** Buffer %p, ptr %p\n", object, |
| 109 | object->buffer.pointer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
| 111 | /* Free the actual buffer */ |
| 112 | |
| 113 | if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | /* But only if it is NOT a pointer into an ACPI table */ |
| 116 | |
| 117 | obj_pointer = object->buffer.pointer; |
| 118 | } |
| 119 | break; |
| 120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | case ACPI_TYPE_PACKAGE: |
| 122 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 123 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 124 | " **** Package of count %X\n", |
| 125 | object->package.count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * Elements of the package are not handled here, they are deleted |
| 129 | * separately |
| 130 | */ |
| 131 | |
| 132 | /* Free the (variable length) element pointer array */ |
| 133 | |
| 134 | obj_pointer = object->package.elements; |
| 135 | break; |
| 136 | |
Bob Moore | 2843ae7 | 2008-07-04 10:41:41 +0800 | [diff] [blame] | 137 | /* |
| 138 | * These objects have a possible list of notify handlers. |
| 139 | * Device object also may have a GPE block. |
| 140 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | case ACPI_TYPE_DEVICE: |
| 142 | |
| 143 | if (object->device.gpe_block) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 144 | (void)acpi_ev_delete_gpe_block(object->device. |
| 145 | gpe_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Bob Moore | 2843ae7 | 2008-07-04 10:41:41 +0800 | [diff] [blame] | 148 | /*lint -fallthrough */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
Bob Moore | 2843ae7 | 2008-07-04 10:41:41 +0800 | [diff] [blame] | 150 | case ACPI_TYPE_PROCESSOR: |
| 151 | case ACPI_TYPE_THERMAL: |
| 152 | |
| 153 | /* Walk the notify handler list for this object */ |
| 154 | |
| 155 | handler_desc = object->common_notify.handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | while (handler_desc) { |
| 157 | next_desc = handler_desc->address_space.next; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 158 | acpi_ut_remove_reference(handler_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | handler_desc = next_desc; |
| 160 | } |
| 161 | break; |
| 162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | case ACPI_TYPE_MUTEX: |
| 164 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 165 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 166 | "***** Mutex %p, OS Mutex %p\n", |
| 167 | object, object->mutex.os_mutex)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
Bob Moore | ba886cd | 2008-04-10 19:06:37 +0400 | [diff] [blame] | 169 | if (object == acpi_gbl_global_lock_mutex) { |
Bob Moore | c81da66 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 170 | |
| 171 | /* Global Lock has extra semaphore */ |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 172 | |
| 173 | (void) |
| 174 | acpi_os_delete_semaphore |
| 175 | (acpi_gbl_global_lock_semaphore); |
| 176 | acpi_gbl_global_lock_semaphore = NULL; |
Bob Moore | c81da66 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 177 | |
| 178 | acpi_os_delete_mutex(object->mutex.os_mutex); |
| 179 | acpi_gbl_global_lock_mutex = NULL; |
| 180 | } else { |
Len Brown | 262a7a2 | 2007-05-09 23:01:59 -0400 | [diff] [blame] | 181 | acpi_ex_unlink_mutex(object); |
Bob Moore | c81da66 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 182 | acpi_os_delete_mutex(object->mutex.os_mutex); |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 183 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | break; |
| 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | case ACPI_TYPE_EVENT: |
| 187 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 188 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 189 | "***** Event %p, OS Semaphore %p\n", |
| 190 | object, object->event.os_semaphore)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 192 | (void)acpi_os_delete_semaphore(object->event.os_semaphore); |
| 193 | object->event.os_semaphore = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | break; |
| 195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | case ACPI_TYPE_METHOD: |
| 197 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 198 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 199 | "***** Method %p\n", object)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 201 | /* Delete the method mutex if it exists */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 203 | if (object->method.mutex) { |
| 204 | acpi_os_delete_mutex(object->method.mutex->mutex. |
| 205 | os_mutex); |
| 206 | acpi_ut_delete_object_desc(object->method.mutex); |
| 207 | object->method.mutex = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } |
| 209 | break; |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | case ACPI_TYPE_REGION: |
| 212 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 214 | "***** Region %p\n", object)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 216 | second_desc = acpi_ns_get_secondary_object(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | if (second_desc) { |
| 218 | /* |
| 219 | * Free the region_context if and only if the handler is one of the |
| 220 | * default handlers -- and therefore, we created the context object |
| 221 | * locally, it was not created by an external caller. |
| 222 | */ |
| 223 | handler_desc = object->region.handler; |
| 224 | if (handler_desc) { |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 225 | if (handler_desc->address_space.handler_flags & |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 227 | |
| 228 | /* Deactivate region and free region context */ |
| 229 | |
| 230 | if (handler_desc->address_space.setup) { |
| 231 | (void)handler_desc-> |
| 232 | address_space.setup(object, |
| 233 | ACPI_REGION_DEACTIVATE, |
| 234 | handler_desc-> |
| 235 | address_space. |
| 236 | context, |
| 237 | &second_desc-> |
| 238 | extra. |
| 239 | region_context); |
| 240 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 243 | acpi_ut_remove_reference(handler_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /* Now we can free the Extra object */ |
| 247 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 248 | acpi_ut_delete_object_desc(second_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | break; |
| 251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | case ACPI_TYPE_BUFFER_FIELD: |
| 253 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 254 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 255 | "***** Buffer Field %p\n", object)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 257 | second_desc = acpi_ns_get_secondary_object(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | if (second_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 259 | acpi_ut_delete_object_desc(second_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
| 261 | break; |
| 262 | |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 263 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 264 | |
| 265 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 266 | "***** Bank Field %p\n", object)); |
| 267 | |
| 268 | second_desc = acpi_ns_get_secondary_object(object); |
| 269 | if (second_desc) { |
| 270 | acpi_ut_delete_object_desc(second_desc); |
| 271 | } |
| 272 | break; |
| 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | default: |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | /* Free any allocated memory (pointer within the object) found above */ |
| 279 | |
| 280 | if (obj_pointer) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 281 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 282 | "Deleting Object Subptr %p\n", obj_pointer)); |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 283 | ACPI_FREE(obj_pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | /* Now the object can be safely deleted */ |
| 287 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 288 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", |
| 289 | object, acpi_ut_get_object_type_name(object))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 291 | acpi_ut_delete_object_desc(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | return_VOID; |
| 293 | } |
| 294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | /******************************************************************************* |
| 296 | * |
| 297 | * FUNCTION: acpi_ut_delete_internal_object_list |
| 298 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 299 | * PARAMETERS: obj_list - Pointer to the list to be deleted |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | * |
| 301 | * RETURN: None |
| 302 | * |
| 303 | * DESCRIPTION: This function deletes an internal object list, including both |
| 304 | * simple objects and package objects |
| 305 | * |
| 306 | ******************************************************************************/ |
| 307 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 308 | void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 310 | union acpi_operand_object **internal_obj; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 312 | ACPI_FUNCTION_TRACE(ut_delete_internal_object_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
| 314 | /* Walk the null-terminated internal list */ |
| 315 | |
| 316 | for (internal_obj = obj_list; *internal_obj; internal_obj++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 317 | acpi_ut_remove_reference(*internal_obj); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /* Free the combined parameter pointer list and object array */ |
| 321 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 322 | ACPI_FREE(obj_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | return_VOID; |
| 324 | } |
| 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | /******************************************************************************* |
| 327 | * |
| 328 | * FUNCTION: acpi_ut_update_ref_count |
| 329 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 330 | * PARAMETERS: Object - Object whose ref count is to be updated |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | * Action - What to do |
| 332 | * |
| 333 | * RETURN: New ref count |
| 334 | * |
| 335 | * DESCRIPTION: Modify the ref count and return it. |
| 336 | * |
| 337 | ******************************************************************************/ |
| 338 | |
| 339 | static void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 342 | u16 count; |
| 343 | u16 new_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 345 | ACPI_FUNCTION_NAME(ut_update_ref_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
| 347 | if (!object) { |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | count = object->common.reference_count; |
| 352 | new_count = count; |
| 353 | |
| 354 | /* |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 355 | * Perform the reference count action (increment, decrement, force delete) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | */ |
| 357 | switch (action) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | case REF_INCREMENT: |
| 359 | |
| 360 | new_count++; |
| 361 | object->common.reference_count = new_count; |
| 362 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 363 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 364 | "Obj %p Refs=%X, [Incremented]\n", |
| 365 | object, new_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | break; |
| 367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | case REF_DECREMENT: |
| 369 | |
| 370 | if (count < 1) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 371 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 372 | "Obj %p Refs=%X, can't decrement! (Set to 0)\n", |
| 373 | object, new_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
| 375 | new_count = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 376 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | new_count--; |
| 378 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 379 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 380 | "Obj %p Refs=%X, [Decremented]\n", |
| 381 | object, new_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | } |
| 383 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 384 | if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) { |
| 385 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 386 | "Method Obj %p Refs=%X, [Decremented]\n", |
| 387 | object, new_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | object->common.reference_count = new_count; |
| 391 | if (new_count == 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 392 | acpi_ut_delete_internal_obj(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | break; |
| 395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | case REF_FORCE_DELETE: |
| 397 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 398 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 399 | "Obj %p Refs=%X, Force delete! (Set to 0)\n", |
| 400 | object, count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
| 402 | new_count = 0; |
| 403 | object->common.reference_count = new_count; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 404 | acpi_ut_delete_internal_obj(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | break; |
| 406 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | default: |
| 408 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 409 | ACPI_ERROR((AE_INFO, "Unknown action (%X)", action)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | break; |
| 411 | } |
| 412 | |
| 413 | /* |
| 414 | * Sanity check the reference count, for debug purposes only. |
| 415 | * (A deleted object will have a huge reference count) |
| 416 | */ |
| 417 | if (count > ACPI_MAX_REFERENCE_COUNT) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 418 | ACPI_WARNING((AE_INFO, |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 419 | "Large Reference Count (%X) in object %p", count, |
| 420 | object)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | } |
| 423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | /******************************************************************************* |
| 425 | * |
| 426 | * FUNCTION: acpi_ut_update_object_reference |
| 427 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 428 | * PARAMETERS: Object - Increment ref count for this object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | * and all sub-objects |
| 430 | * Action - Either REF_INCREMENT or REF_DECREMENT or |
| 431 | * REF_FORCE_DELETE |
| 432 | * |
| 433 | * RETURN: Status |
| 434 | * |
| 435 | * DESCRIPTION: Increment the object reference count |
| 436 | * |
| 437 | * Object references are incremented when: |
| 438 | * 1) An object is attached to a Node (namespace object) |
| 439 | * 2) An object is copied (all subobjects must be incremented) |
| 440 | * |
| 441 | * Object references are decremented when: |
| 442 | * 1) An object is detached from an Node |
| 443 | * |
| 444 | ******************************************************************************/ |
| 445 | |
| 446 | acpi_status |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 447 | acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 449 | acpi_status status = AE_OK; |
| 450 | union acpi_generic_state *state_list = NULL; |
| 451 | union acpi_operand_object *next_object = NULL; |
| 452 | union acpi_generic_state *state; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 453 | u32 i; |
David Shaohua Li | 4c3ffbd | 2005-07-14 00:00:00 -0400 | [diff] [blame] | 454 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 455 | ACPI_FUNCTION_TRACE_PTR(ut_update_object_reference, object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 457 | while (object) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 458 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 459 | /* Make sure that this isn't a namespace handle */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 461 | if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) { |
| 462 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 463 | "Object %p is NS handle\n", object)); |
| 464 | return_ACPI_STATUS(AE_OK); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 465 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
| 467 | /* |
| 468 | * All sub-objects must have their reference count incremented also. |
| 469 | * Different object types have different subobjects. |
| 470 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 471 | switch (ACPI_GET_OBJECT_TYPE(object)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | case ACPI_TYPE_DEVICE: |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 473 | case ACPI_TYPE_PROCESSOR: |
| 474 | case ACPI_TYPE_POWER: |
| 475 | case ACPI_TYPE_THERMAL: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 477 | /* Update the notify objects for these types (if present) */ |
| 478 | |
| 479 | acpi_ut_update_ref_count(object->common_notify. |
| 480 | system_notify, action); |
| 481 | acpi_ut_update_ref_count(object->common_notify. |
| 482 | device_notify, action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | break; |
| 484 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | case ACPI_TYPE_PACKAGE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | /* |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 487 | * We must update all the sub-objects of the package, |
| 488 | * each of whom may have their own sub-objects. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | */ |
| 490 | for (i = 0; i < object->package.count; i++) { |
| 491 | /* |
| 492 | * Push each element onto the stack for later processing. |
| 493 | * Note: There can be null elements within the package, |
| 494 | * these are simply ignored |
| 495 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 496 | status = |
| 497 | acpi_ut_create_update_state_and_push |
| 498 | (object->package.elements[i], action, |
| 499 | &state_list); |
| 500 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | goto error_exit; |
| 502 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | } |
| 504 | break; |
| 505 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | case ACPI_TYPE_BUFFER_FIELD: |
| 507 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 508 | next_object = object->buffer_field.buffer_obj; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | break; |
| 510 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 512 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 513 | next_object = object->field.region_obj; |
| 514 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | |
| 516 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 517 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 518 | next_object = object->bank_field.bank_obj; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 519 | status = |
| 520 | acpi_ut_create_update_state_and_push(object-> |
| 521 | bank_field. |
| 522 | region_obj, |
| 523 | action, |
| 524 | &state_list); |
| 525 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | goto error_exit; |
| 527 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | break; |
| 529 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 531 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 532 | next_object = object->index_field.index_obj; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 533 | status = |
| 534 | acpi_ut_create_update_state_and_push(object-> |
| 535 | index_field. |
| 536 | data_obj, |
| 537 | action, |
| 538 | &state_list); |
| 539 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | goto error_exit; |
| 541 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | break; |
| 543 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | case ACPI_TYPE_LOCAL_REFERENCE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | /* |
Bob Moore | 9e41d93 | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 546 | * The target of an Index (a package, string, or buffer) or a named |
| 547 | * reference must track changes to the ref count of the index or |
| 548 | * target object. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | */ |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame^] | 550 | if ((object->reference.class == ACPI_REFCLASS_INDEX) || |
| 551 | (object->reference.class == ACPI_REFCLASS_NAME)) { |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 552 | next_object = object->reference.object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | } |
| 554 | break; |
| 555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | case ACPI_TYPE_REGION: |
| 557 | default: |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 558 | break; /* No subobjects for all other types */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | /* |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 562 | * Now we can update the count in the main object. This can only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | * happen after we update the sub-objects in case this causes the |
| 564 | * main object to be deleted. |
| 565 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 566 | acpi_ut_update_ref_count(object, action); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 567 | object = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | |
| 569 | /* Move on to the next object to be updated */ |
| 570 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 571 | if (next_object) { |
| 572 | object = next_object; |
| 573 | next_object = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 574 | } else if (state_list) { |
| 575 | state = acpi_ut_pop_generic_state(&state_list); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 576 | object = state->update.object; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 577 | acpi_ut_delete_generic_state(state); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 578 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | } |
| 580 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 581 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 583 | error_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 585 | ACPI_EXCEPTION((AE_INFO, status, |
| 586 | "Could not update object reference count")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 588 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | /******************************************************************************* |
| 592 | * |
| 593 | * FUNCTION: acpi_ut_add_reference |
| 594 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 595 | * PARAMETERS: Object - Object whose reference count is to be |
| 596 | * incremented |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | * |
| 598 | * RETURN: None |
| 599 | * |
| 600 | * DESCRIPTION: Add one reference to an ACPI object |
| 601 | * |
| 602 | ******************************************************************************/ |
| 603 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 604 | void acpi_ut_add_reference(union acpi_operand_object *object) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | { |
| 606 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 607 | ACPI_FUNCTION_TRACE_PTR(ut_add_reference, object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
| 609 | /* Ensure that we have a valid object */ |
| 610 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 611 | if (!acpi_ut_valid_internal_object(object)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | return_VOID; |
| 613 | } |
| 614 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 615 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 616 | "Obj %p Current Refs=%X [To Be Incremented]\n", |
| 617 | object, object->common.reference_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
| 619 | /* Increment the reference count */ |
| 620 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 621 | (void)acpi_ut_update_object_reference(object, REF_INCREMENT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | return_VOID; |
| 623 | } |
| 624 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | /******************************************************************************* |
| 626 | * |
| 627 | * FUNCTION: acpi_ut_remove_reference |
| 628 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 629 | * PARAMETERS: Object - Object whose ref count will be decremented |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | * |
| 631 | * RETURN: None |
| 632 | * |
| 633 | * DESCRIPTION: Decrement the reference count of an ACPI internal object |
| 634 | * |
| 635 | ******************************************************************************/ |
| 636 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 637 | void acpi_ut_remove_reference(union acpi_operand_object *object) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | { |
| 639 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 640 | ACPI_FUNCTION_TRACE_PTR(ut_remove_reference, object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | |
| 642 | /* |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 643 | * Allow a NULL pointer to be passed in, just ignore it. This saves |
| 644 | * each caller from having to check. Also, ignore NS nodes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | * |
| 646 | */ |
| 647 | if (!object || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 648 | (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | return_VOID; |
| 650 | } |
| 651 | |
| 652 | /* Ensure that we have a valid object */ |
| 653 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 654 | if (!acpi_ut_valid_internal_object(object)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | return_VOID; |
| 656 | } |
| 657 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 658 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 659 | "Obj %p Current Refs=%X [To Be Decremented]\n", |
| 660 | object, object->common.reference_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | |
| 662 | /* |
| 663 | * Decrement the reference count, and only actually delete the object |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 664 | * if the reference count becomes 0. (Must also decrement the ref count |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | * of all subobjects!) |
| 666 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 667 | (void)acpi_ut_update_object_reference(object, REF_DECREMENT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | return_VOID; |
| 669 | } |