xref: /minix3/minix/drivers/power/acpi/namespace/nswalk.c (revision 29492bb71c7148a089a5afafa0c99409161218df)
1433d6423SLionel Sambuc /******************************************************************************
2433d6423SLionel Sambuc  *
3433d6423SLionel Sambuc  * Module Name: nswalk - Functions for walking the ACPI namespace
4433d6423SLionel Sambuc  *
5433d6423SLionel Sambuc  *****************************************************************************/
6433d6423SLionel Sambuc 
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek  * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc  * All rights reserved.
10433d6423SLionel Sambuc  *
11*29492bb7SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek  * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek  * are met:
14*29492bb7SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek  *    notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek  *    without modification.
17*29492bb7SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek  *    substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek  *    ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek  *    including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek  *    binary redistribution.
22*29492bb7SDavid van Moolenbroek  * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek  *    of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek  *    from this software without specific prior written permission.
25433d6423SLionel Sambuc  *
26*29492bb7SDavid van Moolenbroek  * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek  * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek  * Software Foundation.
29433d6423SLionel Sambuc  *
30*29492bb7SDavid van Moolenbroek  * NO WARRANTY
31*29492bb7SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek  * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek  */
43433d6423SLionel Sambuc 
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acnamesp.h"
47433d6423SLionel Sambuc 
48433d6423SLionel Sambuc 
49433d6423SLionel Sambuc #define _COMPONENT          ACPI_NAMESPACE
50433d6423SLionel Sambuc         ACPI_MODULE_NAME    ("nswalk")
51433d6423SLionel Sambuc 
52433d6423SLionel Sambuc 
53433d6423SLionel Sambuc /*******************************************************************************
54433d6423SLionel Sambuc  *
55433d6423SLionel Sambuc  * FUNCTION:    AcpiNsGetNextNode
56433d6423SLionel Sambuc  *
57433d6423SLionel Sambuc  * PARAMETERS:  ParentNode          - Parent node whose children we are
58433d6423SLionel Sambuc  *                                    getting
59433d6423SLionel Sambuc  *              ChildNode           - Previous child that was found.
60433d6423SLionel Sambuc  *                                    The NEXT child will be returned
61433d6423SLionel Sambuc  *
62433d6423SLionel Sambuc  * RETURN:      ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
63433d6423SLionel Sambuc  *                                    none is found.
64433d6423SLionel Sambuc  *
65433d6423SLionel Sambuc  * DESCRIPTION: Return the next peer node within the namespace. If Handle
66433d6423SLionel Sambuc  *              is valid, Scope is ignored. Otherwise, the first node
67433d6423SLionel Sambuc  *              within Scope is returned.
68433d6423SLionel Sambuc  *
69433d6423SLionel Sambuc  ******************************************************************************/
70433d6423SLionel Sambuc 
71433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *
AcpiNsGetNextNode(ACPI_NAMESPACE_NODE * ParentNode,ACPI_NAMESPACE_NODE * ChildNode)72433d6423SLionel Sambuc AcpiNsGetNextNode (
73433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *ParentNode,
74433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *ChildNode)
75433d6423SLionel Sambuc {
76433d6423SLionel Sambuc     ACPI_FUNCTION_ENTRY ();
77433d6423SLionel Sambuc 
78433d6423SLionel Sambuc 
79433d6423SLionel Sambuc     if (!ChildNode)
80433d6423SLionel Sambuc     {
81433d6423SLionel Sambuc         /* It's really the parent's _scope_ that we want */
82433d6423SLionel Sambuc 
83433d6423SLionel Sambuc         return (ParentNode->Child);
84433d6423SLionel Sambuc     }
85433d6423SLionel Sambuc 
86433d6423SLionel Sambuc     /* Otherwise just return the next peer */
87433d6423SLionel Sambuc 
88433d6423SLionel Sambuc     return (ChildNode->Peer);
89433d6423SLionel Sambuc }
90433d6423SLionel Sambuc 
91433d6423SLionel Sambuc 
92433d6423SLionel Sambuc /*******************************************************************************
93433d6423SLionel Sambuc  *
94433d6423SLionel Sambuc  * FUNCTION:    AcpiNsGetNextNodeTyped
95433d6423SLionel Sambuc  *
96433d6423SLionel Sambuc  * PARAMETERS:  Type                - Type of node to be searched for
97433d6423SLionel Sambuc  *              ParentNode          - Parent node whose children we are
98433d6423SLionel Sambuc  *                                    getting
99433d6423SLionel Sambuc  *              ChildNode           - Previous child that was found.
100433d6423SLionel Sambuc  *                                    The NEXT child will be returned
101433d6423SLionel Sambuc  *
102433d6423SLionel Sambuc  * RETURN:      ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
103433d6423SLionel Sambuc  *                                    none is found.
104433d6423SLionel Sambuc  *
105433d6423SLionel Sambuc  * DESCRIPTION: Return the next peer node within the namespace. If Handle
106433d6423SLionel Sambuc  *              is valid, Scope is ignored. Otherwise, the first node
107433d6423SLionel Sambuc  *              within Scope is returned.
108433d6423SLionel Sambuc  *
109433d6423SLionel Sambuc  ******************************************************************************/
110433d6423SLionel Sambuc 
111433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *
AcpiNsGetNextNodeTyped(ACPI_OBJECT_TYPE Type,ACPI_NAMESPACE_NODE * ParentNode,ACPI_NAMESPACE_NODE * ChildNode)112433d6423SLionel Sambuc AcpiNsGetNextNodeTyped (
113433d6423SLionel Sambuc     ACPI_OBJECT_TYPE        Type,
114433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *ParentNode,
115433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *ChildNode)
116433d6423SLionel Sambuc {
117433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *NextNode = NULL;
118433d6423SLionel Sambuc 
119433d6423SLionel Sambuc 
120433d6423SLionel Sambuc     ACPI_FUNCTION_ENTRY ();
121433d6423SLionel Sambuc 
122433d6423SLionel Sambuc 
123433d6423SLionel Sambuc     NextNode = AcpiNsGetNextNode (ParentNode, ChildNode);
124433d6423SLionel Sambuc 
125433d6423SLionel Sambuc     /* If any type is OK, we are done */
126433d6423SLionel Sambuc 
127433d6423SLionel Sambuc     if (Type == ACPI_TYPE_ANY)
128433d6423SLionel Sambuc     {
129433d6423SLionel Sambuc         /* NextNode is NULL if we are at the end-of-list */
130433d6423SLionel Sambuc 
131433d6423SLionel Sambuc         return (NextNode);
132433d6423SLionel Sambuc     }
133433d6423SLionel Sambuc 
134433d6423SLionel Sambuc     /* Must search for the node -- but within this scope only */
135433d6423SLionel Sambuc 
136433d6423SLionel Sambuc     while (NextNode)
137433d6423SLionel Sambuc     {
138433d6423SLionel Sambuc         /* If type matches, we are done */
139433d6423SLionel Sambuc 
140433d6423SLionel Sambuc         if (NextNode->Type == Type)
141433d6423SLionel Sambuc         {
142433d6423SLionel Sambuc             return (NextNode);
143433d6423SLionel Sambuc         }
144433d6423SLionel Sambuc 
145433d6423SLionel Sambuc         /* Otherwise, move on to the next peer node */
146433d6423SLionel Sambuc 
147433d6423SLionel Sambuc         NextNode = NextNode->Peer;
148433d6423SLionel Sambuc     }
149433d6423SLionel Sambuc 
150433d6423SLionel Sambuc     /* Not found */
151433d6423SLionel Sambuc 
152433d6423SLionel Sambuc     return (NULL);
153433d6423SLionel Sambuc }
154433d6423SLionel Sambuc 
155433d6423SLionel Sambuc 
156433d6423SLionel Sambuc /*******************************************************************************
157433d6423SLionel Sambuc  *
158433d6423SLionel Sambuc  * FUNCTION:    AcpiNsWalkNamespace
159433d6423SLionel Sambuc  *
160433d6423SLionel Sambuc  * PARAMETERS:  Type                - ACPI_OBJECT_TYPE to search for
161433d6423SLionel Sambuc  *              StartNode           - Handle in namespace where search begins
162433d6423SLionel Sambuc  *              MaxDepth            - Depth to which search is to reach
163433d6423SLionel Sambuc  *              Flags               - Whether to unlock the NS before invoking
164433d6423SLionel Sambuc  *                                    the callback routine
165*29492bb7SDavid van Moolenbroek  *              DescendingCallback  - Called during tree descent
166433d6423SLionel Sambuc  *                                    when an object of "Type" is found
167*29492bb7SDavid van Moolenbroek  *              AscendingCallback   - Called during tree ascent
168433d6423SLionel Sambuc  *                                    when an object of "Type" is found
169433d6423SLionel Sambuc  *              Context             - Passed to user function(s) above
170433d6423SLionel Sambuc  *              ReturnValue         - from the UserFunction if terminated
171433d6423SLionel Sambuc  *                                    early. Otherwise, returns NULL.
172433d6423SLionel Sambuc  * RETURNS:     Status
173433d6423SLionel Sambuc  *
174433d6423SLionel Sambuc  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
175433d6423SLionel Sambuc  *              starting (and ending) at the node specified by StartHandle.
176433d6423SLionel Sambuc  *              The callback function is called whenever a node that matches
177433d6423SLionel Sambuc  *              the type parameter is found. If the callback function returns
178433d6423SLionel Sambuc  *              a non-zero value, the search is terminated immediately and
179433d6423SLionel Sambuc  *              this value is returned to the caller.
180433d6423SLionel Sambuc  *
181433d6423SLionel Sambuc  *              The point of this procedure is to provide a generic namespace
182433d6423SLionel Sambuc  *              walk routine that can be called from multiple places to
183433d6423SLionel Sambuc  *              provide multiple services; the callback function(s) can be
184433d6423SLionel Sambuc  *              tailored to each task, whether it is a print function,
185433d6423SLionel Sambuc  *              a compare function, etc.
186433d6423SLionel Sambuc  *
187433d6423SLionel Sambuc  ******************************************************************************/
188433d6423SLionel Sambuc 
189433d6423SLionel Sambuc ACPI_STATUS
AcpiNsWalkNamespace(ACPI_OBJECT_TYPE Type,ACPI_HANDLE StartNode,UINT32 MaxDepth,UINT32 Flags,ACPI_WALK_CALLBACK DescendingCallback,ACPI_WALK_CALLBACK AscendingCallback,void * Context,void ** ReturnValue)190433d6423SLionel Sambuc AcpiNsWalkNamespace (
191433d6423SLionel Sambuc     ACPI_OBJECT_TYPE        Type,
192433d6423SLionel Sambuc     ACPI_HANDLE             StartNode,
193433d6423SLionel Sambuc     UINT32                  MaxDepth,
194433d6423SLionel Sambuc     UINT32                  Flags,
195*29492bb7SDavid van Moolenbroek     ACPI_WALK_CALLBACK      DescendingCallback,
196*29492bb7SDavid van Moolenbroek     ACPI_WALK_CALLBACK      AscendingCallback,
197433d6423SLionel Sambuc     void                    *Context,
198433d6423SLionel Sambuc     void                    **ReturnValue)
199433d6423SLionel Sambuc {
200433d6423SLionel Sambuc     ACPI_STATUS             Status;
201433d6423SLionel Sambuc     ACPI_STATUS             MutexStatus;
202433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *ChildNode;
203433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *ParentNode;
204433d6423SLionel Sambuc     ACPI_OBJECT_TYPE        ChildType;
205433d6423SLionel Sambuc     UINT32                  Level;
206433d6423SLionel Sambuc     BOOLEAN                 NodePreviouslyVisited = FALSE;
207433d6423SLionel Sambuc 
208433d6423SLionel Sambuc 
209433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (NsWalkNamespace);
210433d6423SLionel Sambuc 
211433d6423SLionel Sambuc 
212433d6423SLionel Sambuc     /* Special case for the namespace Root Node */
213433d6423SLionel Sambuc 
214433d6423SLionel Sambuc     if (StartNode == ACPI_ROOT_OBJECT)
215433d6423SLionel Sambuc     {
216433d6423SLionel Sambuc         StartNode = AcpiGbl_RootNode;
217433d6423SLionel Sambuc     }
218433d6423SLionel Sambuc 
219433d6423SLionel Sambuc     /* Null child means "get first node" */
220433d6423SLionel Sambuc 
221433d6423SLionel Sambuc     ParentNode  = StartNode;
222433d6423SLionel Sambuc     ChildNode   = AcpiNsGetNextNode (ParentNode, NULL);
223433d6423SLionel Sambuc     ChildType   = ACPI_TYPE_ANY;
224433d6423SLionel Sambuc     Level       = 1;
225433d6423SLionel Sambuc 
226433d6423SLionel Sambuc     /*
227433d6423SLionel Sambuc      * Traverse the tree of nodes until we bubble back up to where we
228433d6423SLionel Sambuc      * started. When Level is zero, the loop is done because we have
229433d6423SLionel Sambuc      * bubbled up to (and passed) the original parent handle (StartEntry)
230433d6423SLionel Sambuc      */
231433d6423SLionel Sambuc     while (Level > 0 && ChildNode)
232433d6423SLionel Sambuc     {
233433d6423SLionel Sambuc         Status = AE_OK;
234433d6423SLionel Sambuc 
235433d6423SLionel Sambuc         /* Found next child, get the type if we are not searching for ANY */
236433d6423SLionel Sambuc 
237433d6423SLionel Sambuc         if (Type != ACPI_TYPE_ANY)
238433d6423SLionel Sambuc         {
239433d6423SLionel Sambuc             ChildType = ChildNode->Type;
240433d6423SLionel Sambuc         }
241433d6423SLionel Sambuc 
242433d6423SLionel Sambuc         /*
243433d6423SLionel Sambuc          * Ignore all temporary namespace nodes (created during control
244433d6423SLionel Sambuc          * method execution) unless told otherwise. These temporary nodes
245433d6423SLionel Sambuc          * can cause a race condition because they can be deleted during
246433d6423SLionel Sambuc          * the execution of the user function (if the namespace is
247433d6423SLionel Sambuc          * unlocked before invocation of the user function.) Only the
248433d6423SLionel Sambuc          * debugger namespace dump will examine the temporary nodes.
249433d6423SLionel Sambuc          */
250433d6423SLionel Sambuc         if ((ChildNode->Flags & ANOBJ_TEMPORARY) &&
251433d6423SLionel Sambuc             !(Flags & ACPI_NS_WALK_TEMP_NODES))
252433d6423SLionel Sambuc         {
253433d6423SLionel Sambuc             Status = AE_CTRL_DEPTH;
254433d6423SLionel Sambuc         }
255433d6423SLionel Sambuc 
256433d6423SLionel Sambuc         /* Type must match requested type */
257433d6423SLionel Sambuc 
258433d6423SLionel Sambuc         else if (ChildType == Type)
259433d6423SLionel Sambuc         {
260433d6423SLionel Sambuc             /*
261433d6423SLionel Sambuc              * Found a matching node, invoke the user callback function.
262433d6423SLionel Sambuc              * Unlock the namespace if flag is set.
263433d6423SLionel Sambuc              */
264433d6423SLionel Sambuc             if (Flags & ACPI_NS_WALK_UNLOCK)
265433d6423SLionel Sambuc             {
266433d6423SLionel Sambuc                 MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
267433d6423SLionel Sambuc                 if (ACPI_FAILURE (MutexStatus))
268433d6423SLionel Sambuc                 {
269433d6423SLionel Sambuc                     return_ACPI_STATUS (MutexStatus);
270433d6423SLionel Sambuc                 }
271433d6423SLionel Sambuc             }
272433d6423SLionel Sambuc 
273433d6423SLionel Sambuc             /*
274*29492bb7SDavid van Moolenbroek              * Invoke the user function, either descending, ascending,
275433d6423SLionel Sambuc              * or both.
276433d6423SLionel Sambuc              */
277433d6423SLionel Sambuc             if (!NodePreviouslyVisited)
278433d6423SLionel Sambuc             {
279*29492bb7SDavid van Moolenbroek                 if (DescendingCallback)
280433d6423SLionel Sambuc                 {
281*29492bb7SDavid van Moolenbroek                     Status = DescendingCallback (ChildNode, Level,
282433d6423SLionel Sambuc                                 Context, ReturnValue);
283433d6423SLionel Sambuc                 }
284433d6423SLionel Sambuc             }
285433d6423SLionel Sambuc             else
286433d6423SLionel Sambuc             {
287*29492bb7SDavid van Moolenbroek                 if (AscendingCallback)
288433d6423SLionel Sambuc                 {
289*29492bb7SDavid van Moolenbroek                     Status = AscendingCallback (ChildNode, Level,
290433d6423SLionel Sambuc                                 Context, ReturnValue);
291433d6423SLionel Sambuc                 }
292433d6423SLionel Sambuc             }
293433d6423SLionel Sambuc 
294433d6423SLionel Sambuc             if (Flags & ACPI_NS_WALK_UNLOCK)
295433d6423SLionel Sambuc             {
296433d6423SLionel Sambuc                 MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
297433d6423SLionel Sambuc                 if (ACPI_FAILURE (MutexStatus))
298433d6423SLionel Sambuc                 {
299433d6423SLionel Sambuc                     return_ACPI_STATUS (MutexStatus);
300433d6423SLionel Sambuc                 }
301433d6423SLionel Sambuc             }
302433d6423SLionel Sambuc 
303433d6423SLionel Sambuc             switch (Status)
304433d6423SLionel Sambuc             {
305433d6423SLionel Sambuc             case AE_OK:
306433d6423SLionel Sambuc             case AE_CTRL_DEPTH:
307433d6423SLionel Sambuc 
308433d6423SLionel Sambuc                 /* Just keep going */
309433d6423SLionel Sambuc                 break;
310433d6423SLionel Sambuc 
311433d6423SLionel Sambuc             case AE_CTRL_TERMINATE:
312433d6423SLionel Sambuc 
313433d6423SLionel Sambuc                 /* Exit now, with OK status */
314433d6423SLionel Sambuc 
315433d6423SLionel Sambuc                 return_ACPI_STATUS (AE_OK);
316433d6423SLionel Sambuc 
317433d6423SLionel Sambuc             default:
318433d6423SLionel Sambuc 
319433d6423SLionel Sambuc                 /* All others are valid exceptions */
320433d6423SLionel Sambuc 
321433d6423SLionel Sambuc                 return_ACPI_STATUS (Status);
322433d6423SLionel Sambuc             }
323433d6423SLionel Sambuc         }
324433d6423SLionel Sambuc 
325433d6423SLionel Sambuc         /*
326433d6423SLionel Sambuc          * Depth first search: Attempt to go down another level in the
327433d6423SLionel Sambuc          * namespace if we are allowed to. Don't go any further if we have
328433d6423SLionel Sambuc          * reached the caller specified maximum depth or if the user
329433d6423SLionel Sambuc          * function has specified that the maximum depth has been reached.
330433d6423SLionel Sambuc          */
331433d6423SLionel Sambuc         if (!NodePreviouslyVisited &&
332433d6423SLionel Sambuc             (Level < MaxDepth) &&
333433d6423SLionel Sambuc             (Status != AE_CTRL_DEPTH))
334433d6423SLionel Sambuc         {
335433d6423SLionel Sambuc             if (ChildNode->Child)
336433d6423SLionel Sambuc             {
337433d6423SLionel Sambuc                 /* There is at least one child of this node, visit it */
338433d6423SLionel Sambuc 
339433d6423SLionel Sambuc                 Level++;
340433d6423SLionel Sambuc                 ParentNode = ChildNode;
341433d6423SLionel Sambuc                 ChildNode = AcpiNsGetNextNode (ParentNode, NULL);
342433d6423SLionel Sambuc                 continue;
343433d6423SLionel Sambuc             }
344433d6423SLionel Sambuc         }
345433d6423SLionel Sambuc 
346433d6423SLionel Sambuc         /* No more children, re-visit this node */
347433d6423SLionel Sambuc 
348433d6423SLionel Sambuc         if (!NodePreviouslyVisited)
349433d6423SLionel Sambuc         {
350433d6423SLionel Sambuc             NodePreviouslyVisited = TRUE;
351433d6423SLionel Sambuc             continue;
352433d6423SLionel Sambuc         }
353433d6423SLionel Sambuc 
354433d6423SLionel Sambuc         /* No more children, visit peers */
355433d6423SLionel Sambuc 
356433d6423SLionel Sambuc         ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
357433d6423SLionel Sambuc         if (ChildNode)
358433d6423SLionel Sambuc         {
359433d6423SLionel Sambuc             NodePreviouslyVisited = FALSE;
360433d6423SLionel Sambuc         }
361433d6423SLionel Sambuc 
362433d6423SLionel Sambuc         /* No peers, re-visit parent */
363433d6423SLionel Sambuc 
364433d6423SLionel Sambuc         else
365433d6423SLionel Sambuc         {
366433d6423SLionel Sambuc             /*
367433d6423SLionel Sambuc              * No more children of this node (AcpiNsGetNextNode failed), go
368433d6423SLionel Sambuc              * back upwards in the namespace tree to the node's parent.
369433d6423SLionel Sambuc              */
370433d6423SLionel Sambuc             Level--;
371433d6423SLionel Sambuc             ChildNode = ParentNode;
372433d6423SLionel Sambuc             ParentNode = ParentNode->Parent;
373433d6423SLionel Sambuc 
374433d6423SLionel Sambuc             NodePreviouslyVisited = TRUE;
375433d6423SLionel Sambuc         }
376433d6423SLionel Sambuc     }
377433d6423SLionel Sambuc 
378433d6423SLionel Sambuc     /* Complete walk, not terminated by user function */
379433d6423SLionel Sambuc 
380433d6423SLionel Sambuc     return_ACPI_STATUS (AE_OK);
381433d6423SLionel Sambuc }
382