blob: 8d3a43a061ab1214662b37932958c24ab4c26bd6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: nsalloc - Namespace allocation and deletion utilities
4 *
5 ******************************************************************************/
6
7/*
Bob Moorea8357b02010-01-22 19:07:36 +08008 * Copyright (C) 2000 - 2010, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acnamesp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define _COMPONENT ACPI_NAMESPACE
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("nsalloc")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051/*******************************************************************************
52 *
53 * FUNCTION: acpi_ns_create_node
54 *
Robert Moore44f6c012005-04-18 22:49:35 -040055 * PARAMETERS: Name - Name of the new node (4 char ACPI name)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 *
Robert Moore44f6c012005-04-18 22:49:35 -040057 * RETURN: New namespace node (Null on failure)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 *
59 * DESCRIPTION: Create a namespace node
60 *
61 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -040062struct acpi_namespace_node *acpi_ns_create_node(u32 name)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
Len Brown4be44fc2005-08-05 00:44:28 -040064 struct acpi_namespace_node *node;
Valery A. Podrezovafbb9e62007-02-02 19:48:23 +030065#ifdef ACPI_DBG_TRACK_ALLOCATIONS
66 u32 temp;
67#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Bob Mooreb229cf92006-04-21 17:15:00 -040069 ACPI_FUNCTION_TRACE(ns_create_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Bob Moore616861242006-03-17 16:44:00 -050071 node = acpi_os_acquire_object(acpi_gbl_namespace_cache);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 if (!node) {
Len Brown4be44fc2005-08-05 00:44:28 -040073 return_PTR(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75
Len Brown4be44fc2005-08-05 00:44:28 -040076 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Valery A. Podrezovafbb9e62007-02-02 19:48:23 +030078#ifdef ACPI_DBG_TRACK_ALLOCATIONS
Bob Moored4913dc2009-03-06 10:05:18 +080079 temp = acpi_gbl_ns_node_list->total_allocated -
Valery A. Podrezovafbb9e62007-02-02 19:48:23 +030080 acpi_gbl_ns_node_list->total_freed;
81 if (temp > acpi_gbl_ns_node_list->max_occupied) {
82 acpi_gbl_ns_node_list->max_occupied = temp;
83 }
84#endif
85
Len Brown4be44fc2005-08-05 00:44:28 -040086 node->name.integer = name;
Len Brown4be44fc2005-08-05 00:44:28 -040087 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);
Len Brown4be44fc2005-08-05 00:44:28 -040088 return_PTR(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091/*******************************************************************************
92 *
93 * FUNCTION: acpi_ns_delete_node
94 *
95 * PARAMETERS: Node - Node to be deleted
96 *
97 * RETURN: None
98 *
Bob Moore8e4319c2009-06-29 13:43:27 +080099 * DESCRIPTION: Delete a namespace node. All node deletions must come through
100 * here. Detaches any attached objects, including any attached
101 * data. If a handler is associated with attached data, it is
102 * invoked before the node is deleted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 *
104 ******************************************************************************/
105
Len Brown4be44fc2005-08-05 00:44:28 -0400106void acpi_ns_delete_node(struct acpi_namespace_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107{
Bob Moore8e4319c2009-06-29 13:43:27 +0800108 union acpi_operand_object *obj_desc;
109
110 ACPI_FUNCTION_NAME(ns_delete_node);
111
112 /* Detach an object if there is one */
113
114 acpi_ns_detach_object(node);
115
116 /*
117 * Delete an attached data object if present (an object that was created
118 * and attached via acpi_attach_data). Note: After any normal object is
119 * detached above, the only possible remaining object is a data object.
120 */
121 obj_desc = node->object;
122 if (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) {
123
124 /* Invoke the attached data deletion handler if present */
125
126 if (obj_desc->data.handler) {
127 obj_desc->data.handler(node, obj_desc->data.pointer);
128 }
129
130 acpi_ut_remove_reference(obj_desc);
131 }
132
133 /* Now we can delete the node */
134
135 (void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
136
137 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
138 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n",
139 node, acpi_gbl_current_node_count));
140}
141
142/*******************************************************************************
143 *
144 * FUNCTION: acpi_ns_remove_node
145 *
146 * PARAMETERS: Node - Node to be removed/deleted
147 *
148 * RETURN: None
149 *
150 * DESCRIPTION: Remove (unlink) and delete a namespace node
151 *
152 ******************************************************************************/
153
154void acpi_ns_remove_node(struct acpi_namespace_node *node)
155{
Len Brown4be44fc2005-08-05 00:44:28 -0400156 struct acpi_namespace_node *parent_node;
157 struct acpi_namespace_node *prev_node;
158 struct acpi_namespace_node *next_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Bob Moore8e4319c2009-06-29 13:43:27 +0800160 ACPI_FUNCTION_TRACE_PTR(ns_remove_node, node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800162 parent_node = node->parent;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164 prev_node = NULL;
165 next_node = parent_node->child;
166
167 /* Find the node that is the previous peer in the parent's child list */
168
169 while (next_node != node) {
170 prev_node = next_node;
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800171 next_node = next_node->peer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 }
173
174 if (prev_node) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 /* Node is not first child, unlink it */
177
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800178 prev_node->peer = node->peer;
Len Brown4be44fc2005-08-05 00:44:28 -0400179 } else {
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800180 /*
181 * Node is first child (has no previous peer).
182 * Link peer list to parent
183 */
184 parent_node->child = node->peer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 }
186
Bob Moore8e4319c2009-06-29 13:43:27 +0800187 /* Delete the node and any attached objects */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Bob Moore8e4319c2009-06-29 13:43:27 +0800189 acpi_ns_delete_node(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 return_VOID;
191}
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193/*******************************************************************************
194 *
195 * FUNCTION: acpi_ns_install_node
196 *
197 * PARAMETERS: walk_state - Current state of the walk
198 * parent_node - The parent of the new Node
199 * Node - The new Node to install
200 * Type - ACPI object type of the new Node
201 *
202 * RETURN: None
203 *
204 * DESCRIPTION: Initialize a new namespace node and install it amongst
205 * its peers.
206 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700207 * Note: Current namespace lookup is linear search. This appears
208 * to be sufficient as namespace searches consume only a small
209 * fraction of the execution time of the ACPI subsystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 *
211 ******************************************************************************/
212
Len Brown4be44fc2005-08-05 00:44:28 -0400213void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */
214 struct acpi_namespace_node *node, /* New Child */
215 acpi_object_type type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216{
Len Brown4be44fc2005-08-05 00:44:28 -0400217 acpi_owner_id owner_id = 0;
218 struct acpi_namespace_node *child_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Bob Mooreb229cf92006-04-21 17:15:00 -0400220 ACPI_FUNCTION_TRACE(ns_install_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222 /*
Bob Moored4913dc2009-03-06 10:05:18 +0800223 * Get the owner ID from the Walk state. The owner ID is used to track
224 * table deletion and deletion of objects created by methods.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 */
226 if (walk_state) {
227 owner_id = walk_state->owner_id;
228 }
229
230 /* Link the new entry into the parent and existing children */
231
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800232 node->peer = NULL;
233 node->parent = parent_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 child_node = parent_node->child;
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 if (!child_node) {
237 parent_node->child = node;
Len Brown4be44fc2005-08-05 00:44:28 -0400238 } else {
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800239 /* Add node to the end of the peer list */
240
241 while (child_node->peer) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 child_node = child_node->peer;
243 }
244
245 child_node->peer = node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 }
247
248 /* Init the new entry */
249
250 node->owner_id = owner_id;
251 node->type = (u8) type;
252
Len Brown4be44fc2005-08-05 00:44:28 -0400253 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
254 "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
255 acpi_ut_get_node_name(node),
256 acpi_ut_get_type_name(node->type), node, owner_id,
257 acpi_ut_get_node_name(parent_node),
258 acpi_ut_get_type_name(parent_node->type),
259 parent_node));
Bob Moore793c2382006-03-31 00:00:00 -0500260
261 return_VOID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262}
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264/*******************************************************************************
265 *
266 * FUNCTION: acpi_ns_delete_children
267 *
268 * PARAMETERS: parent_node - Delete this objects children
269 *
270 * RETURN: None.
271 *
272 * DESCRIPTION: Delete all children of the parent object. In other words,
273 * deletes a "scope".
274 *
275 ******************************************************************************/
276
Len Brown4be44fc2005-08-05 00:44:28 -0400277void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278{
Len Brown4be44fc2005-08-05 00:44:28 -0400279 struct acpi_namespace_node *next_node;
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800280 struct acpi_namespace_node *node_to_delete;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Bob Mooreb229cf92006-04-21 17:15:00 -0400282 ACPI_FUNCTION_TRACE_PTR(ns_delete_children, parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
284 if (!parent_node) {
285 return_VOID;
286 }
287
Bob Moored4913dc2009-03-06 10:05:18 +0800288 /* Deallocate all children at this level */
289
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800290 next_node = parent_node->child;
291 while (next_node) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293 /* Grandchildren should have all been deleted already */
294
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800295 if (next_node->child) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500296 ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p",
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800297 parent_node, next_node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 }
299
Bob Moore8e4319c2009-06-29 13:43:27 +0800300 /*
301 * Delete this child node and move on to the next child in the list.
302 * No need to unlink the node since we are deleting the entire branch.
303 */
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800304 node_to_delete = next_node;
305 next_node = next_node->peer;
306 acpi_ns_delete_node(node_to_delete);
307 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 /* Clear the parent's child pointer */
310
311 parent_node->child = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 return_VOID;
313}
314
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315/*******************************************************************************
316 *
317 * FUNCTION: acpi_ns_delete_namespace_subtree
318 *
319 * PARAMETERS: parent_node - Root of the subtree to be deleted
320 *
321 * RETURN: None.
322 *
323 * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
324 * stored within the subtree.
325 *
326 ******************************************************************************/
327
Len Brown4be44fc2005-08-05 00:44:28 -0400328void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329{
Len Brown4be44fc2005-08-05 00:44:28 -0400330 struct acpi_namespace_node *child_node = NULL;
331 u32 level = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Bob Mooreb229cf92006-04-21 17:15:00 -0400333 ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
335 if (!parent_node) {
336 return_VOID;
337 }
338
339 /*
340 * Traverse the tree of objects until we bubble back up
341 * to where we started.
342 */
343 while (level > 0) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400344
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 /* Get the next node in this scope (NULL if none) */
346
Bob Moore8c725bf2009-05-21 10:27:51 +0800347 child_node = acpi_ns_get_next_node(parent_node, child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 if (child_node) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /* Found a child node - detach any attached object */
351
Len Brown4be44fc2005-08-05 00:44:28 -0400352 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 /* Check if this node has any children */
355
Bob Moore8c725bf2009-05-21 10:27:51 +0800356 if (child_node->child) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 /*
358 * There is at least one child of this node,
359 * visit the node
360 */
361 level++;
362 parent_node = child_node;
363 child_node = NULL;
364 }
Len Brown4be44fc2005-08-05 00:44:28 -0400365 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 /*
367 * No more children of this parent node.
368 * Move up to the grandparent.
369 */
370 level--;
371
372 /*
373 * Now delete all of the children of this parent
374 * all at the same time.
375 */
Len Brown4be44fc2005-08-05 00:44:28 -0400376 acpi_ns_delete_children(parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378 /* New "last child" is this parent node */
379
380 child_node = parent_node;
381
382 /* Move up the tree to the grandparent */
383
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800384 parent_node = parent_node->parent;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 }
386 }
387
388 return_VOID;
389}
390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391/*******************************************************************************
392 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 * FUNCTION: acpi_ns_delete_namespace_by_owner
394 *
395 * PARAMETERS: owner_id - All nodes with this owner will be deleted
396 *
397 * RETURN: Status
398 *
399 * DESCRIPTION: Delete entries within the namespace that are owned by a
400 * specific ID. Used to delete entire ACPI tables. All
401 * reference counts are updated.
402 *
Bob Mooref6dd9222006-07-07 20:44:38 -0400403 * MUTEX: Locks namespace during deletion walk.
404 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 ******************************************************************************/
406
Len Brown4be44fc2005-08-05 00:44:28 -0400407void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
Len Brown4be44fc2005-08-05 00:44:28 -0400409 struct acpi_namespace_node *child_node;
410 struct acpi_namespace_node *deletion_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400411 struct acpi_namespace_node *parent_node;
Bob Mooref6dd9222006-07-07 20:44:38 -0400412 u32 level;
413 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
Bob Mooreb229cf92006-04-21 17:15:00 -0400415 ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Robert Moore0c9938c2005-07-29 15:15:00 -0700417 if (owner_id == 0) {
418 return_VOID;
419 }
420
Bob Mooref6dd9222006-07-07 20:44:38 -0400421 /* Lock namespace for possible update */
422
423 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
424 if (ACPI_FAILURE(status)) {
425 return_VOID;
426 }
427
Bob Moore616861242006-03-17 16:44:00 -0500428 deletion_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400429 parent_node = acpi_gbl_root_node;
430 child_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400431 level = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
433 /*
434 * Traverse the tree of nodes until we bubble back up
435 * to where we started.
436 */
437 while (level > 0) {
438 /*
439 * Get the next child of this parent node. When child_node is NULL,
440 * the first child of the parent is returned
441 */
Bob Moore8c725bf2009-05-21 10:27:51 +0800442 child_node = acpi_ns_get_next_node(parent_node, child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
444 if (deletion_node) {
Bob Moore616861242006-03-17 16:44:00 -0500445 acpi_ns_delete_children(deletion_node);
Bob Moore8e4319c2009-06-29 13:43:27 +0800446 acpi_ns_remove_node(deletion_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 deletion_node = NULL;
448 }
449
450 if (child_node) {
451 if (child_node->owner_id == owner_id) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400452
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 /* Found a matching child node - detach any attached object */
454
Len Brown4be44fc2005-08-05 00:44:28 -0400455 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 }
457
458 /* Check if this node has any children */
459
Bob Moore8c725bf2009-05-21 10:27:51 +0800460 if (child_node->child) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 /*
462 * There is at least one child of this node,
463 * visit the node
464 */
465 level++;
466 parent_node = child_node;
467 child_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400468 } else if (child_node->owner_id == owner_id) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 deletion_node = child_node;
470 }
Len Brown4be44fc2005-08-05 00:44:28 -0400471 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 /*
473 * No more children of this parent node.
474 * Move up to the grandparent.
475 */
476 level--;
477 if (level != 0) {
478 if (parent_node->owner_id == owner_id) {
479 deletion_node = parent_node;
480 }
481 }
482
483 /* New "last child" is this parent node */
484
485 child_node = parent_node;
486
487 /* Move up the tree to the grandparent */
488
Alexey Starikovskiyc45b5c02010-05-26 11:53:07 +0800489 parent_node = parent_node->parent;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 }
491 }
492
Bob Mooref6dd9222006-07-07 20:44:38 -0400493 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 return_VOID;
495}