blob: 3db950f5d5a028422d5e33d6a3443406a5ea40fc [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 Moore4a90c7e2006-01-13 16:22:00 -05008 * Copyright (C) 2000 - 2006, R. Byron Moore
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>
45#include <acpi/acnamesp.h>
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define _COMPONENT ACPI_NAMESPACE
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("nsalloc")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Robert Moore44f6c012005-04-18 22:49:35 -040050/* Local prototypes */
Len Brown4be44fc2005-08-05 00:44:28 -040051static void acpi_ns_remove_reference(struct acpi_namespace_node *node);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53/*******************************************************************************
54 *
55 * FUNCTION: acpi_ns_create_node
56 *
Robert Moore44f6c012005-04-18 22:49:35 -040057 * PARAMETERS: Name - Name of the new node (4 char ACPI name)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 *
Robert Moore44f6c012005-04-18 22:49:35 -040059 * RETURN: New namespace node (Null on failure)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 *
61 * DESCRIPTION: Create a namespace node
62 *
63 ******************************************************************************/
64
Len Brown4be44fc2005-08-05 00:44:28 -040065struct acpi_namespace_node *acpi_ns_create_node(u32 name)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
Len Brown4be44fc2005-08-05 00:44:28 -040067 struct acpi_namespace_node *node;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Len Brown4be44fc2005-08-05 00:44:28 -040069 ACPI_FUNCTION_TRACE("ns_create_node");
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Len Brown4be44fc2005-08-05 00:44:28 -040071 node = ACPI_MEM_CALLOCATE(sizeof(struct acpi_namespace_node));
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
Len Brown4be44fc2005-08-05 00:44:28 -040078 node->name.integer = name;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 node->reference_count = 1;
Len Brown4be44fc2005-08-05 00:44:28 -040080 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Len Brown4be44fc2005-08-05 00:44:28 -040082 return_PTR(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083}
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085/*******************************************************************************
86 *
87 * FUNCTION: acpi_ns_delete_node
88 *
89 * PARAMETERS: Node - Node to be deleted
90 *
91 * RETURN: None
92 *
93 * DESCRIPTION: Delete a namespace node
94 *
95 ******************************************************************************/
96
Len Brown4be44fc2005-08-05 00:44:28 -040097void acpi_ns_delete_node(struct acpi_namespace_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
Len Brown4be44fc2005-08-05 00:44:28 -040099 struct acpi_namespace_node *parent_node;
100 struct acpi_namespace_node *prev_node;
101 struct acpi_namespace_node *next_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Len Brown4be44fc2005-08-05 00:44:28 -0400103 ACPI_FUNCTION_TRACE_PTR("ns_delete_node", node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Len Brown4be44fc2005-08-05 00:44:28 -0400105 parent_node = acpi_ns_get_parent_node(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107 prev_node = NULL;
108 next_node = parent_node->child;
109
110 /* Find the node that is the previous peer in the parent's child list */
111
112 while (next_node != node) {
113 prev_node = next_node;
114 next_node = prev_node->peer;
115 }
116
117 if (prev_node) {
118 /* Node is not first child, unlink it */
119
120 prev_node->peer = next_node->peer;
121 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
122 prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
123 }
Len Brown4be44fc2005-08-05 00:44:28 -0400124 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 /* Node is first child (has no previous peer) */
126
127 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
128 /* No peers at all */
129
130 parent_node->child = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400131 } else { /* Link peer list to parent */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133 parent_node->child = next_node->peer;
134 }
135 }
136
Len Brown4be44fc2005-08-05 00:44:28 -0400137 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139 /*
140 * Detach an object if there is one then delete the node
141 */
Len Brown4be44fc2005-08-05 00:44:28 -0400142 acpi_ns_detach_object(node);
143 ACPI_MEM_FREE(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 return_VOID;
145}
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147/*******************************************************************************
148 *
149 * FUNCTION: acpi_ns_install_node
150 *
151 * PARAMETERS: walk_state - Current state of the walk
152 * parent_node - The parent of the new Node
153 * Node - The new Node to install
154 * Type - ACPI object type of the new Node
155 *
156 * RETURN: None
157 *
158 * DESCRIPTION: Initialize a new namespace node and install it amongst
159 * its peers.
160 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700161 * Note: Current namespace lookup is linear search. This appears
162 * to be sufficient as namespace searches consume only a small
163 * fraction of the execution time of the ACPI subsystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 *
165 ******************************************************************************/
166
Len Brown4be44fc2005-08-05 00:44:28 -0400167void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */
168 struct acpi_namespace_node *node, /* New Child */
169 acpi_object_type type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170{
Len Brown4be44fc2005-08-05 00:44:28 -0400171 acpi_owner_id owner_id = 0;
172 struct acpi_namespace_node *child_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Len Brown4be44fc2005-08-05 00:44:28 -0400174 ACPI_FUNCTION_TRACE("ns_install_node");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
176 /*
177 * Get the owner ID from the Walk state
178 * The owner ID is used to track table deletion and
179 * deletion of objects created by methods
180 */
181 if (walk_state) {
182 owner_id = walk_state->owner_id;
183 }
184
185 /* Link the new entry into the parent and existing children */
186
187 child_node = parent_node->child;
188 if (!child_node) {
189 parent_node->child = node;
190 node->flags |= ANOBJ_END_OF_PEER_LIST;
191 node->peer = parent_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400192 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
194 child_node = child_node->peer;
195 }
196
197 child_node->peer = node;
198
199 /* Clear end-of-list flag */
200
201 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
Robert Moore0c9938c2005-07-29 15:15:00 -0700202 node->flags |= ANOBJ_END_OF_PEER_LIST;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 node->peer = parent_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 }
205
206 /* Init the new entry */
207
208 node->owner_id = owner_id;
209 node->type = (u8) type;
210
Len Brown4be44fc2005-08-05 00:44:28 -0400211 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
212 "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
213 acpi_ut_get_node_name(node),
214 acpi_ut_get_type_name(node->type), node, owner_id,
215 acpi_ut_get_node_name(parent_node),
216 acpi_ut_get_type_name(parent_node->type),
217 parent_node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 /*
220 * Increment the reference count(s) of all parents up to
221 * the root!
222 */
Len Brown4be44fc2005-08-05 00:44:28 -0400223 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 node->reference_count++;
225 }
226
227 return_VOID;
228}
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230/*******************************************************************************
231 *
232 * FUNCTION: acpi_ns_delete_children
233 *
234 * PARAMETERS: parent_node - Delete this objects children
235 *
236 * RETURN: None.
237 *
238 * DESCRIPTION: Delete all children of the parent object. In other words,
239 * deletes a "scope".
240 *
241 ******************************************************************************/
242
Len Brown4be44fc2005-08-05 00:44:28 -0400243void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244{
Len Brown4be44fc2005-08-05 00:44:28 -0400245 struct acpi_namespace_node *child_node;
246 struct acpi_namespace_node *next_node;
247 struct acpi_namespace_node *node;
248 u8 flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Len Brown4be44fc2005-08-05 00:44:28 -0400250 ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
252 if (!parent_node) {
253 return_VOID;
254 }
255
256 /* If no children, all done! */
257
258 child_node = parent_node->child;
259 if (!child_node) {
260 return_VOID;
261 }
262
263 /*
264 * Deallocate all children at this level
265 */
266 do {
267 /* Get the things we need */
268
Len Brown4be44fc2005-08-05 00:44:28 -0400269 next_node = child_node->peer;
270 flags = child_node->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272 /* Grandchildren should have all been deleted already */
273
274 if (child_node->child) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500275 ACPI_REPORT_ERROR(("Found a grandchild! P=%p C=%p\n",
276 parent_node, child_node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 }
278
279 /* Now we can free this child object */
280
Len Brown4be44fc2005-08-05 00:44:28 -0400281 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Len Brown4be44fc2005-08-05 00:44:28 -0400283 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
284 "Object %p, Remaining %X\n", child_node,
285 acpi_gbl_current_node_count));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
287 /*
288 * Detach an object if there is one, then free the child node
289 */
Len Brown4be44fc2005-08-05 00:44:28 -0400290 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
292 /*
293 * Decrement the reference count(s) of all parents up to
294 * the root! (counts were incremented when the node was created)
295 */
296 node = child_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400297 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 node->reference_count--;
299 }
300
301 /* There should be only one reference remaining on this node */
302
303 if (child_node->reference_count != 1) {
Len Brown4be44fc2005-08-05 00:44:28 -0400304 ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 }
306
307 /* Now we can delete the node */
308
Len Brown4be44fc2005-08-05 00:44:28 -0400309 ACPI_MEM_FREE(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
311 /* And move on to the next child in the list */
312
313 child_node = next_node;
314
315 } while (!(flags & ANOBJ_END_OF_PEER_LIST));
316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 /* Clear the parent's child pointer */
318
319 parent_node->child = NULL;
320
321 return_VOID;
322}
323
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324/*******************************************************************************
325 *
326 * FUNCTION: acpi_ns_delete_namespace_subtree
327 *
328 * PARAMETERS: parent_node - Root of the subtree to be deleted
329 *
330 * RETURN: None.
331 *
332 * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
333 * stored within the subtree.
334 *
335 ******************************************************************************/
336
Len Brown4be44fc2005-08-05 00:44:28 -0400337void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338{
Len Brown4be44fc2005-08-05 00:44:28 -0400339 struct acpi_namespace_node *child_node = NULL;
340 u32 level = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341
Len Brown4be44fc2005-08-05 00:44:28 -0400342 ACPI_FUNCTION_TRACE("ns_delete_namespace_subtree");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
344 if (!parent_node) {
345 return_VOID;
346 }
347
348 /*
349 * Traverse the tree of objects until we bubble back up
350 * to where we started.
351 */
352 while (level > 0) {
353 /* Get the next node in this scope (NULL if none) */
354
Len Brown4be44fc2005-08-05 00:44:28 -0400355 child_node = acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
356 child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 if (child_node) {
358 /* Found a child node - detach any attached object */
359
Len Brown4be44fc2005-08-05 00:44:28 -0400360 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
362 /* Check if this node has any children */
363
Len Brown4be44fc2005-08-05 00:44:28 -0400364 if (acpi_ns_get_next_node
365 (ACPI_TYPE_ANY, child_node, NULL)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 /*
367 * There is at least one child of this node,
368 * visit the node
369 */
370 level++;
371 parent_node = child_node;
372 child_node = NULL;
373 }
Len Brown4be44fc2005-08-05 00:44:28 -0400374 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 /*
376 * No more children of this parent node.
377 * Move up to the grandparent.
378 */
379 level--;
380
381 /*
382 * Now delete all of the children of this parent
383 * all at the same time.
384 */
Len Brown4be44fc2005-08-05 00:44:28 -0400385 acpi_ns_delete_children(parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
387 /* New "last child" is this parent node */
388
389 child_node = parent_node;
390
391 /* Move up the tree to the grandparent */
392
Len Brown4be44fc2005-08-05 00:44:28 -0400393 parent_node = acpi_ns_get_parent_node(parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 }
395 }
396
397 return_VOID;
398}
399
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400/*******************************************************************************
401 *
402 * FUNCTION: acpi_ns_remove_reference
403 *
404 * PARAMETERS: Node - Named node whose reference count is to be
405 * decremented
406 *
407 * RETURN: None.
408 *
409 * DESCRIPTION: Remove a Node reference. Decrements the reference count
410 * of all parent Nodes up to the root. Any node along
411 * the way that reaches zero references is freed.
412 *
413 ******************************************************************************/
414
Len Brown4be44fc2005-08-05 00:44:28 -0400415static void acpi_ns_remove_reference(struct acpi_namespace_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416{
Len Brown4be44fc2005-08-05 00:44:28 -0400417 struct acpi_namespace_node *parent_node;
418 struct acpi_namespace_node *this_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
Len Brown4be44fc2005-08-05 00:44:28 -0400420 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
422 /*
423 * Decrement the reference count(s) of this node and all
424 * nodes up to the root, Delete anything with zero remaining references.
425 */
426 this_node = node;
427 while (this_node) {
428 /* Prepare to move up to parent */
429
Len Brown4be44fc2005-08-05 00:44:28 -0400430 parent_node = acpi_ns_get_parent_node(this_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432 /* Decrement the reference count on this node */
433
434 this_node->reference_count--;
435
436 /* Delete the node if no more references */
437
438 if (!this_node->reference_count) {
439 /* Delete all children and delete the node */
440
Len Brown4be44fc2005-08-05 00:44:28 -0400441 acpi_ns_delete_children(this_node);
442 acpi_ns_delete_node(this_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 }
444
445 this_node = parent_node;
446 }
447}
448
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449/*******************************************************************************
450 *
451 * FUNCTION: acpi_ns_delete_namespace_by_owner
452 *
453 * PARAMETERS: owner_id - All nodes with this owner will be deleted
454 *
455 * RETURN: Status
456 *
457 * DESCRIPTION: Delete entries within the namespace that are owned by a
458 * specific ID. Used to delete entire ACPI tables. All
459 * reference counts are updated.
460 *
461 ******************************************************************************/
462
Len Brown4be44fc2005-08-05 00:44:28 -0400463void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464{
Len Brown4be44fc2005-08-05 00:44:28 -0400465 struct acpi_namespace_node *child_node;
466 struct acpi_namespace_node *deletion_node;
467 u32 level;
468 struct acpi_namespace_node *parent_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
Len Brown4be44fc2005-08-05 00:44:28 -0400470 ACPI_FUNCTION_TRACE_U32("ns_delete_namespace_by_owner", owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Robert Moore0c9938c2005-07-29 15:15:00 -0700472 if (owner_id == 0) {
473 return_VOID;
474 }
475
Len Brown4be44fc2005-08-05 00:44:28 -0400476 parent_node = acpi_gbl_root_node;
477 child_node = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 deletion_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400479 level = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
481 /*
482 * Traverse the tree of nodes until we bubble back up
483 * to where we started.
484 */
485 while (level > 0) {
486 /*
487 * Get the next child of this parent node. When child_node is NULL,
488 * the first child of the parent is returned
489 */
Len Brown4be44fc2005-08-05 00:44:28 -0400490 child_node =
491 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
492 child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
494 if (deletion_node) {
Len Brown4be44fc2005-08-05 00:44:28 -0400495 acpi_ns_remove_reference(deletion_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 deletion_node = NULL;
497 }
498
499 if (child_node) {
500 if (child_node->owner_id == owner_id) {
501 /* Found a matching child node - detach any attached object */
502
Len Brown4be44fc2005-08-05 00:44:28 -0400503 acpi_ns_detach_object(child_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 }
505
506 /* Check if this node has any children */
507
Len Brown4be44fc2005-08-05 00:44:28 -0400508 if (acpi_ns_get_next_node
509 (ACPI_TYPE_ANY, child_node, NULL)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 /*
511 * There is at least one child of this node,
512 * visit the node
513 */
514 level++;
515 parent_node = child_node;
516 child_node = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400517 } else if (child_node->owner_id == owner_id) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 deletion_node = child_node;
519 }
Len Brown4be44fc2005-08-05 00:44:28 -0400520 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 /*
522 * No more children of this parent node.
523 * Move up to the grandparent.
524 */
525 level--;
526 if (level != 0) {
527 if (parent_node->owner_id == owner_id) {
528 deletion_node = parent_node;
529 }
530 }
531
532 /* New "last child" is this parent node */
533
534 child_node = parent_node;
535
536 /* Move up the tree to the grandparent */
537
Len Brown4be44fc2005-08-05 00:44:28 -0400538 parent_node = acpi_ns_get_parent_node(parent_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 }
540 }
541
542 return_VOID;
543}