blob: aceb93111967f35a7f0a335c4bcb2798c4d56304 [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/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, 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 *
99 * DESCRIPTION: Delete a namespace node
100 *
101 ******************************************************************************/
102
Len Brown4be44fc2005-08-05 00:44:28 -0400103void acpi_ns_delete_node(struct acpi_namespace_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
Len Brown4be44fc2005-08-05 00:44:28 -0400105 struct acpi_namespace_node *parent_node;
106 struct acpi_namespace_node *prev_node;
107 struct acpi_namespace_node *next_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
Bob Mooreb229cf92006-04-21 17:15:00 -0400109 ACPI_FUNCTION_TRACE_PTR(ns_delete_node, node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Len Brown4be44fc2005-08-05 00:44:28 -0400111 parent_node = acpi_ns_get_parent_node(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113 prev_node = NULL;
114 next_node = parent_node->child;
115
116 /* Find the node that is the previous peer in the parent's child list */
117
118 while (next_node != node) {
119 prev_node = next_node;
120 next_node = prev_node->peer;
121 }
122
123 if (prev_node) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 /* Node is not first child, unlink it */
126
127 prev_node->peer = next_node->peer;
128 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
129 prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
130 }
Len Brown4be44fc2005-08-05 00:44:28 -0400131 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 /* Node is first child (has no previous peer) */
133
134 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 /* No peers at all */
137
138 parent_node->child = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400139 } else { /* Link peer list to parent */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141 parent_node->child = next_node->peer;
142 }
143 }
144
Len Brown4be44fc2005-08-05 00:44:28 -0400145 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Bob Moored4913dc2009-03-06 10:05:18 +0800147 /* Detach an object if there is one, then delete the node */
148
Len Brown4be44fc2005-08-05 00:44:28 -0400149 acpi_ns_detach_object(node);
Bob Moore616861242006-03-17 16:44:00 -0500150 (void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 return_VOID;
152}
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154/*******************************************************************************
155 *
156 * FUNCTION: acpi_ns_install_node
157 *
158 * PARAMETERS: walk_state - Current state of the walk
159 * parent_node - The parent of the new Node
160 * Node - The new Node to install
161 * Type - ACPI object type of the new Node
162 *
163 * RETURN: None
164 *
165 * DESCRIPTION: Initialize a new namespace node and install it amongst
166 * its peers.
167 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700168 * Note: Current namespace lookup is linear search. This appears
169 * to be sufficient as namespace searches consume only a small
170 * fraction of the execution time of the ACPI subsystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 *
172 ******************************************************************************/
173
Len Brown4be44fc2005-08-05 00:44:28 -0400174void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */
175 struct acpi_namespace_node *node, /* New Child */
176 acpi_object_type type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
Len Brown4be44fc2005-08-05 00:44:28 -0400178 acpi_owner_id owner_id = 0;
179 struct acpi_namespace_node *child_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
Bob Mooreb229cf92006-04-21 17:15:00 -0400181 ACPI_FUNCTION_TRACE(ns_install_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183 /*
Bob Moored4913dc2009-03-06 10:05:18 +0800184 * Get the owner ID from the Walk state. The owner ID is used to track
185 * table deletion and deletion of objects created by methods.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 */
187 if (walk_state) {
188 owner_id = walk_state->owner_id;
189 }
190
191 /* Link the new entry into the parent and existing children */
192
193 child_node = parent_node->child;
194 if (!child_node) {
195 parent_node->child = node;
196 node->flags |= ANOBJ_END_OF_PEER_LIST;
197 node->peer = parent_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400198 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
200 child_node = child_node->peer;
201 }
202
203 child_node->peer = node;
204
205 /* Clear end-of-list flag */
206
207 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
Robert Moore0c9938c2005-07-29 15:15:00 -0700208 node->flags |= ANOBJ_END_OF_PEER_LIST;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 node->peer = parent_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 }
211
212 /* Init the new entry */
213
214 node->owner_id = owner_id;
215 node->type = (u8) type;
216
Len Brown4be44fc2005-08-05 00:44:28 -0400217 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
218 "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
219 acpi_ut_get_node_name(node),
220 acpi_ut_get_type_name(node->type), node, owner_id,
221 acpi_ut_get_node_name(parent_node),
222 acpi_ut_get_type_name(parent_node->type),
223 parent_node));
Bob Moore793c2382006-03-31 00:00:00 -0500224
225 return_VOID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226}
227
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228/*******************************************************************************
229 *
230 * FUNCTION: acpi_ns_delete_children
231 *
232 * PARAMETERS: parent_node - Delete this objects children
233 *
234 * RETURN: None.
235 *
236 * DESCRIPTION: Delete all children of the parent object. In other words,
237 * deletes a "scope".
238 *
239 ******************************************************************************/
240
Len Brown4be44fc2005-08-05 00:44:28 -0400241void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242{
Len Brown4be44fc2005-08-05 00:44:28 -0400243 struct acpi_namespace_node *child_node;
244 struct acpi_namespace_node *next_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400245 u8 flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Bob Mooreb229cf92006-04-21 17:15:00 -0400247 ACPI_FUNCTION_TRACE_PTR(ns_delete_children, parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249 if (!parent_node) {
250 return_VOID;
251 }
252
253 /* If no children, all done! */
254
255 child_node = parent_node->child;
256 if (!child_node) {
257 return_VOID;
258 }
259
Bob Moored4913dc2009-03-06 10:05:18 +0800260 /* Deallocate all children at this level */
261
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 do {
Bob Moore52fc0b02006-10-02 00:00:00 -0400263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 /* Get the things we need */
265
Len Brown4be44fc2005-08-05 00:44:28 -0400266 next_node = child_node->peer;
267 flags = child_node->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269 /* Grandchildren should have all been deleted already */
270
271 if (child_node->child) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500272 ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p",
273 parent_node, child_node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 }
275
276 /* Now we can free this child object */
277
Len Brown4be44fc2005-08-05 00:44:28 -0400278 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Len Brown4be44fc2005-08-05 00:44:28 -0400280 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
281 "Object %p, Remaining %X\n", child_node,
282 acpi_gbl_current_node_count));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Bob Moored4913dc2009-03-06 10:05:18 +0800284 /* Detach an object if there is one, then free the child node */
285
Len Brown4be44fc2005-08-05 00:44:28 -0400286 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 /* Now we can delete the node */
289
Bob Moore616861242006-03-17 16:44:00 -0500290 (void)acpi_os_release_object(acpi_gbl_namespace_cache,
291 child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293 /* And move on to the next child in the list */
294
295 child_node = next_node;
296
297 } while (!(flags & ANOBJ_END_OF_PEER_LIST));
298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 /* Clear the parent's child pointer */
300
301 parent_node->child = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 return_VOID;
303}
304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305/*******************************************************************************
306 *
307 * FUNCTION: acpi_ns_delete_namespace_subtree
308 *
309 * PARAMETERS: parent_node - Root of the subtree to be deleted
310 *
311 * RETURN: None.
312 *
313 * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
314 * stored within the subtree.
315 *
316 ******************************************************************************/
317
Len Brown4be44fc2005-08-05 00:44:28 -0400318void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319{
Len Brown4be44fc2005-08-05 00:44:28 -0400320 struct acpi_namespace_node *child_node = NULL;
321 u32 level = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
Bob Mooreb229cf92006-04-21 17:15:00 -0400323 ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
325 if (!parent_node) {
326 return_VOID;
327 }
328
329 /*
330 * Traverse the tree of objects until we bubble back up
331 * to where we started.
332 */
333 while (level > 0) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400334
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 /* Get the next node in this scope (NULL if none) */
336
Bob Moore616861242006-03-17 16:44:00 -0500337 child_node =
338 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
339 child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 if (child_node) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 /* Found a child node - detach any attached object */
343
Len Brown4be44fc2005-08-05 00:44:28 -0400344 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346 /* Check if this node has any children */
347
Len Brown4be44fc2005-08-05 00:44:28 -0400348 if (acpi_ns_get_next_node
349 (ACPI_TYPE_ANY, child_node, NULL)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /*
351 * There is at least one child of this node,
352 * visit the node
353 */
354 level++;
355 parent_node = child_node;
356 child_node = NULL;
357 }
Len Brown4be44fc2005-08-05 00:44:28 -0400358 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 /*
360 * No more children of this parent node.
361 * Move up to the grandparent.
362 */
363 level--;
364
365 /*
366 * Now delete all of the children of this parent
367 * all at the same time.
368 */
Len Brown4be44fc2005-08-05 00:44:28 -0400369 acpi_ns_delete_children(parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370
371 /* New "last child" is this parent node */
372
373 child_node = parent_node;
374
375 /* Move up the tree to the grandparent */
376
Len Brown4be44fc2005-08-05 00:44:28 -0400377 parent_node = acpi_ns_get_parent_node(parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 }
379 }
380
381 return_VOID;
382}
383
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384/*******************************************************************************
385 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 * FUNCTION: acpi_ns_delete_namespace_by_owner
387 *
388 * PARAMETERS: owner_id - All nodes with this owner will be deleted
389 *
390 * RETURN: Status
391 *
392 * DESCRIPTION: Delete entries within the namespace that are owned by a
393 * specific ID. Used to delete entire ACPI tables. All
394 * reference counts are updated.
395 *
Bob Mooref6dd9222006-07-07 20:44:38 -0400396 * MUTEX: Locks namespace during deletion walk.
397 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 ******************************************************************************/
399
Len Brown4be44fc2005-08-05 00:44:28 -0400400void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401{
Len Brown4be44fc2005-08-05 00:44:28 -0400402 struct acpi_namespace_node *child_node;
403 struct acpi_namespace_node *deletion_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400404 struct acpi_namespace_node *parent_node;
Bob Mooref6dd9222006-07-07 20:44:38 -0400405 u32 level;
406 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
Bob Mooreb229cf92006-04-21 17:15:00 -0400408 ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
Robert Moore0c9938c2005-07-29 15:15:00 -0700410 if (owner_id == 0) {
411 return_VOID;
412 }
413
Bob Mooref6dd9222006-07-07 20:44:38 -0400414 /* Lock namespace for possible update */
415
416 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
417 if (ACPI_FAILURE(status)) {
418 return_VOID;
419 }
420
Bob Moore616861242006-03-17 16:44:00 -0500421 deletion_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400422 parent_node = acpi_gbl_root_node;
423 child_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400424 level = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
426 /*
427 * Traverse the tree of nodes until we bubble back up
428 * to where we started.
429 */
430 while (level > 0) {
431 /*
432 * Get the next child of this parent node. When child_node is NULL,
433 * the first child of the parent is returned
434 */
Len Brown4be44fc2005-08-05 00:44:28 -0400435 child_node =
436 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
437 child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
439 if (deletion_node) {
Bob Moore616861242006-03-17 16:44:00 -0500440 acpi_ns_delete_children(deletion_node);
441 acpi_ns_delete_node(deletion_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 deletion_node = NULL;
443 }
444
445 if (child_node) {
446 if (child_node->owner_id == owner_id) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400447
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 /* Found a matching child node - detach any attached object */
449
Len Brown4be44fc2005-08-05 00:44:28 -0400450 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 }
452
453 /* Check if this node has any children */
454
Len Brown4be44fc2005-08-05 00:44:28 -0400455 if (acpi_ns_get_next_node
456 (ACPI_TYPE_ANY, child_node, NULL)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 /*
458 * There is at least one child of this node,
459 * visit the node
460 */
461 level++;
462 parent_node = child_node;
463 child_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400464 } else if (child_node->owner_id == owner_id) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 deletion_node = child_node;
466 }
Len Brown4be44fc2005-08-05 00:44:28 -0400467 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 /*
469 * No more children of this parent node.
470 * Move up to the grandparent.
471 */
472 level--;
473 if (level != 0) {
474 if (parent_node->owner_id == owner_id) {
475 deletion_node = parent_node;
476 }
477 }
478
479 /* New "last child" is this parent node */
480
481 child_node = parent_node;
482
483 /* Move up the tree to the grandparent */
484
Len Brown4be44fc2005-08-05 00:44:28 -0400485 parent_node = acpi_ns_get_parent_node(parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 }
487 }
488
Bob Mooref6dd9222006-07-07 20:44:38 -0400489 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 return_VOID;
491}