11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Module Name: dsutils - Dispatcher utilities
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
877848130e53b06c22fe37a7b6acbb82bb3e9bfbaBob Moore * Copyright (C) 2000 - 2012, Intel Corp.
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * All rights reserved.
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Redistribution and use in source and binary forms, with or without
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * modification, are permitted provided that the following conditions
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * are met:
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1. Redistributions of source code must retain the above copyright
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    notice, this list of conditions, and the following disclaimer,
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    without modification.
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2. Redistributions in binary form must reproduce at minimum a disclaimer
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    substantially similar to the "NO WARRANTY" disclaimer below
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    ("Disclaimer") and any redistribution must be conditioned upon
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    including a substantially similar Disclaimer requirement for further
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    binary redistribution.
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3. Neither the names of the above-listed copyright holders nor the names
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    of any contributors may be used to endorse or promote products derived
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    from this software without specific prior written permission.
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alternatively, this software may be distributed under the terms of the
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * GNU General Public License ("GPL") version 2 as published by the Free
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Software Foundation.
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NO WARRANTY
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * POSSIBILITY OF SUCH DAMAGES.
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <acpi/acpi.h>
45e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "accommon.h"
46e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acparser.h"
47e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "amlcode.h"
48e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acdispat.h"
49e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acinterp.h"
50e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acnamesp.h"
51e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acdebug.h"
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _COMPONENT          ACPI_DISPATCHER
544be44fcd3bf648b782f4460fd06dfae6c42ded4bLen BrownACPI_MODULE_NAME("dsutils")
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_clear_implicit_return
591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  walk_state          - Current State
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      None.
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Clear and remove a reference on an implicit return value.  Used
651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              to delete "stale" return values (if enabled, the return value
661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              from every operator is saved at least momentarily, in case the
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              parent method exits.)
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownvoid acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state)
711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
72b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_NAME(ds_clear_implicit_return);
731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Slack must be enabled for this feature
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (!acpi_gbl_enable_interpreter_slack) {
781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return;
791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (walk_state->implicit_return_obj) {
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/*
831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * Delete any "stale" implicit return. However, in
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * complex statements, the implicit return value can be
851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * bubbled up several levels.
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 */
874be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
884be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				  "Removing reference on stale implicit return obj %p\n",
894be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				  walk_state->implicit_return_obj));
901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
914be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		acpi_ut_remove_reference(walk_state->implicit_return_obj);
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		walk_state->implicit_return_obj = NULL;
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef ACPI_NO_METHOD_EXECUTION
971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_do_implicit_return
1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  return_desc         - The return value
1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              walk_state          - Current State
1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              add_reference       - True if a reference should be added to the
1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *                                    return object
1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      TRUE if implicit return enabled, FALSE otherwise
1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Implements the optional "implicit return".  We save the result
1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              of every ASL operator and control method invocation in case the
1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              parent method exit.  Before storing a new return value, we
1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              delete the previous return value.
1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsu8
1164be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
1174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			   struct acpi_walk_state *walk_state, u8 add_reference)
1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
119b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_NAME(ds_do_implicit_return);
1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Slack must be enabled for this feature, and we must
1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * have a valid return object
1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
1254be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	if ((!acpi_gbl_enable_interpreter_slack) || (!return_desc)) {
1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return (FALSE);
1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1304be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  "Result %p will be implicitly returned; Prev=%p\n",
1314be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  return_desc, walk_state->implicit_return_obj));
1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Delete any "stale" implicit return value first. However, in
1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * complex statements, the implicit return value can be
1361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * bubbled up several levels, so we don't clear the value if it
1371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * is the same as the return_desc.
1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (walk_state->implicit_return_obj) {
1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if (walk_state->implicit_return_obj == return_desc) {
1411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			return (TRUE);
1421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
1434be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		acpi_ds_clear_implicit_return(walk_state);
1441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
1451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* Save the implicit return value, add a reference if requested */
1471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	walk_state->implicit_return_obj = return_desc;
1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (add_reference) {
1504be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		acpi_ut_add_reference(return_desc);
1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	return (TRUE);
1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_is_result_used
1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  Op                  - Current Op
1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              walk_state          - Current State
1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      TRUE if result is used, FALSE otherwise
1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Check if a result object will be used by the parent
1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsu8
1704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ds_is_result_used(union acpi_parse_object * op,
1714be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		       struct acpi_walk_state * walk_state)
1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
1734be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	const struct acpi_opcode_info *parent_info;
1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
175b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_TRACE_PTR(ds_is_result_used, op);
1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* Must have both an Op and a Result Object */
1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (!op) {
180b8e4d89357fc434618a59c1047cac72641191805Bob Moore		ACPI_ERROR((AE_INFO, "Null Op"));
18150eca3eb89d73d9f0aa070b126c7ee6a616016abBob Moore		return_UINT8(TRUE);
1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * We know that this operator is not a
1861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Return() operator (would not come here.) The following code is the
1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * optional support for a so-called "implicit return". Some AML code
1881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * assumes that the last value of the method is "implicitly" returned
1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * to the caller. Just save the last result as the return value.
1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * NOTE: this is optional because the ASL language does not actually
1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * support this behavior.
1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
1934be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	(void)acpi_ds_do_implicit_return(walk_state->result_obj, walk_state,
1944be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					 TRUE);
1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Now determine if the parent will use the result
1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 *
1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * If there is no parent, or the parent is a scope_op, we are executing
2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * at the method level. An executing method typically has no parent,
2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * since each method is parsed separately.  A method invoked externally
2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * via execute_control_method has a scope_op as the parent.
2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if ((!op->common.parent) ||
2054be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	    (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
20652fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore
2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* No parent, the return value cannot possibly be used */
2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2094be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
2104be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				  "At Method level, result of [%s] not used\n",
2114be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				  acpi_ps_get_opcode_name(op->common.
2124be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown							  aml_opcode)));
21350eca3eb89d73d9f0aa070b126c7ee6a616016abBob Moore		return_UINT8(FALSE);
2141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
2151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* Get info on the parent. The root_op is AML_SCOPE */
2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2184be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	parent_info =
2194be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	    acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (parent_info->class == AML_CLASS_UNKNOWN) {
221b8e4d89357fc434618a59c1047cac72641191805Bob Moore		ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op));
22250eca3eb89d73d9f0aa070b126c7ee6a616016abBob Moore		return_UINT8(FALSE);
2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Decide what to do with the result based on the parent.  If
2271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * the parent opcode will not use the result, delete the object.
2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Otherwise leave it as is, it will be deleted when it is used
2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * as an operand later.
2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	switch (parent_info->class) {
2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	case AML_CLASS_CONTROL:
2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		switch (op->common.parent->common.aml_opcode) {
2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		case AML_RETURN_OP:
2361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/* Never delete the return value associated with a return opcode */
2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			goto result_used;
2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		case AML_IF_OP:
2421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		case AML_WHILE_OP:
2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/*
2451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * If we are executing the predicate AND this is the predicate op,
2461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * we will use the return value
2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 */
2484be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			if ((walk_state->control_state->common.state ==
2494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			     ACPI_CONTROL_PREDICATE_EXECUTING)
2504be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    && (walk_state->control_state->control.
2514be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				predicate_op == op)) {
2521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				goto result_used;
2531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			}
2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			break;
2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		default:
2571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/* Ignore other control opcodes */
2581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			break;
2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* The general control opcode returns no result */
2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		goto result_not_used;
2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	case AML_CLASS_CREATE:
2661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/*
2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * These opcodes allow term_arg(s) as operands and therefore
2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * the operands can be method calls.  The result is used.
2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 */
2711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		goto result_used;
2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	case AML_CLASS_NAMED_OBJECT:
2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2754be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		if ((op->common.parent->common.aml_opcode == AML_REGION_OP) ||
2764be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP)
2774be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    || (op->common.parent->common.aml_opcode == AML_PACKAGE_OP)
2784be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    || (op->common.parent->common.aml_opcode ==
2794be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			AML_VAR_PACKAGE_OP)
2804be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    || (op->common.parent->common.aml_opcode == AML_BUFFER_OP)
2814be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    || (op->common.parent->common.aml_opcode ==
282ef805d956320ffa36d068673d5c5eb2a7d13209bLin Ming			AML_INT_EVAL_SUBTREE_OP)
283ef805d956320ffa36d068673d5c5eb2a7d13209bLin Ming		    || (op->common.parent->common.aml_opcode ==
284ef805d956320ffa36d068673d5c5eb2a7d13209bLin Ming			AML_BANK_FIELD_OP)) {
2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/*
2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * These opcodes allow term_arg(s) as operands and therefore
2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * the operands can be method calls.  The result is used.
2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 */
2891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			goto result_used;
2901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		goto result_not_used;
2931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	default:
2951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/*
2971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * In all other cases. the parent will actually use the return
2981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * object, so keep it.
2991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 */
3001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		goto result_used;
3011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
3021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3034be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown      result_used:
3044be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
3054be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  "Result of [%s] used by Parent [%s] Op=%p\n",
3064be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  acpi_ps_get_opcode_name(op->common.aml_opcode),
3074be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  acpi_ps_get_opcode_name(op->common.parent->common.
3084be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown						  aml_opcode), op));
3091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
31050eca3eb89d73d9f0aa070b126c7ee6a616016abBob Moore	return_UINT8(TRUE);
3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3124be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown      result_not_used:
3134be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
3144be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  "Result of [%s] not used by Parent [%s] Op=%p\n",
3154be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  acpi_ps_get_opcode_name(op->common.aml_opcode),
3164be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			  acpi_ps_get_opcode_name(op->common.parent->common.
3174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown						  aml_opcode), op));
3181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
31950eca3eb89d73d9f0aa070b126c7ee6a616016abBob Moore	return_UINT8(FALSE);
3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_delete_result_if_not_used
3251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  Op              - Current parse Op
3271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              result_obj      - Result of the operation
3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              walk_state      - Current state
3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      Status
3311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Used after interpretation of an opcode.  If there is an internal
3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              result descriptor, check if the parent opcode will actually use
3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              this result.  If not, delete the result now so that it will
3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              not become orphaned.
3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid
3404be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
3414be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				  union acpi_operand_object *result_obj,
3424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				  struct acpi_walk_state *walk_state)
3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
3444be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	union acpi_operand_object *obj_desc;
3454be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	acpi_status status;
3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
347b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_TRACE_PTR(ds_delete_result_if_not_used, result_obj);
3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (!op) {
350b8e4d89357fc434618a59c1047cac72641191805Bob Moore		ACPI_ERROR((AE_INFO, "Null Op"));
3511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return_VOID;
3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
3531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (!result_obj) {
3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return_VOID;
3561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
3571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3584be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	if (!acpi_ds_is_result_used(op, walk_state)) {
35952fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore
3601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Must pop the result stack (obj_desc should be equal to result_obj) */
3611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3624be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		status = acpi_ds_result_pop(&obj_desc, walk_state);
3634be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		if (ACPI_SUCCESS(status)) {
3644be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			acpi_ut_remove_reference(result_obj);
3651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
3661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
3671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	return_VOID;
3691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
3701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
3721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_resolve_operands
3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  walk_state          - Current walk state with operands on stack
3761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      Status
3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Resolve all operands to their values.  Used to prepare
3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              arguments to a control method invocation (a call from one
3811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              method to another.)
3821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
3841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3854be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state)
3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
3874be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	u32 i;
3884be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	acpi_status status = AE_OK;
3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
390b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_TRACE_PTR(ds_resolve_operands, walk_state);
3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Attempt to resolve each of the valid operands
3941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * Method arguments are passed by reference, not by value.  This means
3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * that the actual objects are passed, not copies of the objects.
3961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
3971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	for (i = 0; i < walk_state->num_operands; i++) {
3984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		status =
3994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    acpi_ex_resolve_to_value(&walk_state->operands[i],
4004be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					     walk_state);
4014be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		if (ACPI_FAILURE(status)) {
4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			break;
4031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
4041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
4051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4064be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	return_ACPI_STATUS(status);
4071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
4081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
4101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_clear_operands
4121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  walk_state          - Current walk state with operands on stack
4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      None
4161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Clear all operands on the current walk state operand stack.
4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
4201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4214be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownvoid acpi_ds_clear_operands(struct acpi_walk_state *walk_state)
4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
4234be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	u32 i;
4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
425b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_TRACE_PTR(ds_clear_operands, walk_state);
4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* Remove a reference on each operand on the stack */
4281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	for (i = 0; i < walk_state->num_operands; i++) {
4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/*
4311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * Remove a reference to all operands, including both
4321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * "Arguments" and "Targets".
4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 */
4344be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		acpi_ut_remove_reference(walk_state->operands[i]);
4351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		walk_state->operands[i] = NULL;
4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
4371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	walk_state->num_operands = 0;
4391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	return_VOID;
4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
4421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
4441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_create_operand
4461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  walk_state      - Current walk state
4481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              Arg             - Parse object for the argument
4491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              arg_index       - Which argument (zero based)
4501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      Status
4521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Translate a parse tree object that is an argument to an AML
4541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              opcode to the equivalent interpreter object.  This may include
4551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              looking up a name or entering a new name into the internal
4561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              namespace.
4571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
4591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status
4614be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ds_create_operand(struct acpi_walk_state *walk_state,
4624be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		       union acpi_parse_object *arg, u32 arg_index)
4631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
4644be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	acpi_status status = AE_OK;
4654be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	char *name_string;
4664be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	u32 name_length;
4674be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	union acpi_operand_object *obj_desc;
4684be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	union acpi_parse_object *parent_op;
4694be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	u16 opcode;
4704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	acpi_interpreter_mode interpreter_mode;
4714be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	const struct acpi_opcode_info *op_info;
4721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
473b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_TRACE_PTR(ds_create_operand, arg);
4741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* A valid name must be looked up in the namespace */
4761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
4784e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	    (arg->common.value.string) &&
4794e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	    !(arg->common.flags & ACPI_PARSEOP_IN_STACK)) {
4804be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n",
4814be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				  arg));
4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Get the entire name string from the AML stream */
4841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4854be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		status =
4864be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    acpi_ex_get_name_string(ACPI_TYPE_ANY,
4874be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					    arg->common.value.buffer,
4884be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					    &name_string, &name_length);
4891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4904be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		if (ACPI_FAILURE(status)) {
4914be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			return_ACPI_STATUS(status);
4921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
4931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* All prefixes have been handled, and the name is in name_string */
4951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/*
4971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * Special handling for buffer_field declarations. This is a deferred
4981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * opcode that unfortunately defines the field name as the last
4991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * parameter instead of the first.  We get here when we are performing
5001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * the deferred execution, so the actual name of the field is already
5011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * in the namespace.  We don't want to attempt to look it up again
5021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * because we may be executing in a different scope than where the
5031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * actual opcode exists.
5041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 */
5051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((walk_state->deferred_node) &&
5064be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		    (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD)
50752fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore		    && (arg_index ==
50852fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore			(u32) ((walk_state->opcode ==
50952fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore				AML_CREATE_FIELD_OP) ? 3 : 2))) {
5104be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			obj_desc =
5114be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    ACPI_CAST_PTR(union acpi_operand_object,
5124be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					  walk_state->deferred_node);
5131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			status = AE_OK;
5144be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		} else {	/* All other opcodes */
5154be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown
5161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/*
5171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * Differentiate between a namespace "create" operation
5181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
5191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * IMODE_EXECUTE) in order to support the creation of
5201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * namespace objects during the execution of control methods.
5211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 */
5221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			parent_op = arg->common.parent;
5234be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			op_info =
5244be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    acpi_ps_get_opcode_info(parent_op->common.
5254be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown						    aml_opcode);
5264be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			if ((op_info->flags & AML_NSNODE)
5274be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    && (parent_op->common.aml_opcode !=
5284be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				AML_INT_METHODCALL_OP)
5294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    && (parent_op->common.aml_opcode != AML_REGION_OP)
5304be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    && (parent_op->common.aml_opcode !=
5314be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				AML_INT_NAMEPATH_OP)) {
53252fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore
5331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				/* Enter name into namespace if not found */
5341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				interpreter_mode = ACPI_IMODE_LOAD_PASS2;
5364be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			} else {
5371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				/* Return a failure if name not found */
5381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				interpreter_mode = ACPI_IMODE_EXECUTE;
5401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			}
5411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			status =
5434be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    acpi_ns_lookup(walk_state->scope_info, name_string,
5444be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					   ACPI_TYPE_ANY, interpreter_mode,
5454be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					   ACPI_NS_SEARCH_PARENT |
5464be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					   ACPI_NS_DONT_OPEN_SCOPE, walk_state,
5474be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					   ACPI_CAST_INDIRECT_PTR(struct
5484be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown								  acpi_namespace_node,
5494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown								  &obj_desc));
5501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/*
5511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * The only case where we pass through (ignore) a NOT_FOUND
5521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * error is for the cond_ref_of opcode.
5531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 */
5541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			if (status == AE_NOT_FOUND) {
5554be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				if (parent_op->common.aml_opcode ==
5564be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				    AML_COND_REF_OF_OP) {
5571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					/*
5581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 * For the Conditional Reference op, it's OK if
5591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 * the name is not found;  We just need a way to
5601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 * indicate this to the interpreter, set the
5611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 * object to the root
5621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 */
563fd3509436fde38d4c854bf5a6b83d2c779904f8eLen Brown					obj_desc = ACPI_CAST_PTR(union
564fd3509436fde38d4c854bf5a6b83d2c779904f8eLen Brown								 acpi_operand_object,
565fd3509436fde38d4c854bf5a6b83d2c779904f8eLen Brown								 acpi_gbl_root_node);
5661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					status = AE_OK;
5674be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				} else {
5681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					/*
5691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 * We just plain didn't find it -- which is a
5701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 * very serious error at this point
5711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 */
5721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					status = AE_AML_NAME_NOT_FOUND;
5731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				}
5741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			}
5751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5764be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			if (ACPI_FAILURE(status)) {
577b8e4d89357fc434618a59c1047cac72641191805Bob Moore				ACPI_ERROR_NAMESPACE(name_string, status);
5781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			}
5791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
5801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Free the namestring created above */
5821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5838313524a0d466f451a62709aaedf988d8257b21cBob Moore		ACPI_FREE(name_string);
5841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Check status from the lookup */
5861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5874be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		if (ACPI_FAILURE(status)) {
5884be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			return_ACPI_STATUS(status);
5891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
5901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Put the resulting object onto the current object stack */
5921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5934be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		status = acpi_ds_obj_stack_push(obj_desc, walk_state);
5944be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		if (ACPI_FAILURE(status)) {
5954be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			return_ACPI_STATUS(status);
5961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
5974be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
5984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				   (obj_desc, walk_state));
5994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	} else {
6001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Check for null name case */
6011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6024e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
6034e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		    !(arg->common.flags & ACPI_PARSEOP_IN_STACK)) {
6041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/*
6051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * If the name is null, this means that this is an
6061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * optional result parameter that was not specified
6071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * in the original ASL.  Create a Zero Constant for a
6081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * placeholder.  (Store to a constant is a Noop.)
6091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 */
6104be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			opcode = AML_ZERO_OP;	/* Has no arguments! */
6111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6124be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
6134be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					  "Null namepath: Arg=%p\n", arg));
6144be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		} else {
6151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			opcode = arg->common.aml_opcode;
6161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
6171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Get the object type of the argument */
6191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6204be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		op_info = acpi_ps_get_opcode_info(opcode);
6211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if (op_info->object_type == ACPI_TYPE_INVALID) {
6224be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
6231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
6241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6254e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		if ((op_info->flags & AML_HAS_RETVAL)
6264e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		    || (arg->common.flags & ACPI_PARSEOP_IN_STACK)) {
6274be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
62850eca3eb89d73d9f0aa070b126c7ee6a616016abBob Moore					  "Argument previously created, already stacked\n"));
6291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6304be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
6314be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					   (walk_state->
6324be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown					    operands[walk_state->num_operands -
6334be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown						     1], walk_state));
6341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/*
6361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * Use value that was already previously returned
6371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 * by the evaluation of this argument
6381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 */
639773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore			status = acpi_ds_result_pop(&obj_desc, walk_state);
6404be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			if (ACPI_FAILURE(status)) {
6411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				/*
6421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				 * Only error is underflow, and this indicates
6431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				 * a missing or null operand!
6441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds				 */
645b8e4d89357fc434618a59c1047cac72641191805Bob Moore				ACPI_EXCEPTION((AE_INFO, status,
646b8e4d89357fc434618a59c1047cac72641191805Bob Moore						"Missing or null operand"));
6474be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				return_ACPI_STATUS(status);
6481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			}
6494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		} else {
6501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/* Create an ACPI_INTERNAL_OBJECT for the argument */
6511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6524be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			obj_desc =
6534be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    acpi_ut_create_internal_object(op_info->
6544be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown							   object_type);
6551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			if (!obj_desc) {
6564be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				return_ACPI_STATUS(AE_NO_MEMORY);
6571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			}
6581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			/* Initialize the new object */
6601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6614be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			status =
6624be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			    acpi_ds_init_object_from_op(walk_state, arg, opcode,
6634be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown							&obj_desc);
6644be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			if (ACPI_FAILURE(status)) {
6654be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				acpi_ut_delete_object_desc(obj_desc);
6664be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				return_ACPI_STATUS(status);
6671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			}
6681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
6691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Put the operand object on the object stack */
6711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6724be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		status = acpi_ds_obj_stack_push(obj_desc, walk_state);
6734be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		if (ACPI_FAILURE(status)) {
6744be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			return_ACPI_STATUS(status);
6751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
6761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6774be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown		ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
6784be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown				   (obj_desc, walk_state));
6791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
6801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6814be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	return_ACPI_STATUS(AE_OK);
6821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
6831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*******************************************************************************
6851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
6861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION:    acpi_ds_create_operands
6871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
6881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS:  walk_state          - Current state
6891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              first_arg           - First argument of a parser argument tree
6901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
6911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN:      Status
6921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
6931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Convert an operator's arguments from a parse tree format to
6941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              namespace objects and place those argument object on the object
6951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *              stack in preparation for evaluation by the interpreter.
6961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
6971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/
6981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
6991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status
7004be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ds_create_operands(struct acpi_walk_state *walk_state,
7014be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown			union acpi_parse_object *first_arg)
7021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
7034be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	acpi_status status = AE_OK;
7044be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	union acpi_parse_object *arg;
705773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore	union acpi_parse_object *arguments[ACPI_OBJ_NUM_OPERANDS];
706b7f9f04228eae2cf5adc2ffeb494d4970a8dd8a5Bob Moore	u32 arg_count = 0;
707b7f9f04228eae2cf5adc2ffeb494d4970a8dd8a5Bob Moore	u32 index = walk_state->num_operands;
708b7f9f04228eae2cf5adc2ffeb494d4970a8dd8a5Bob Moore	u32 i;
7091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
710b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore	ACPI_FUNCTION_TRACE_PTR(ds_create_operands, first_arg);
7111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
712773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore	/* Get all arguments in the list */
7131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
7141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	arg = first_arg;
7151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	while (arg) {
716773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		if (index >= ACPI_OBJ_NUM_OPERANDS) {
717773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore			return_ACPI_STATUS(AE_BAD_DATA);
7181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
7191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
720773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		arguments[index] = arg;
721773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		walk_state->operands[index] = NULL;
7221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
7231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* Move on to next argument, if any */
7241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
7251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		arg = arg->common.next;
7261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		arg_count++;
727773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		index++;
728773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore	}
729773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
730773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore	index--;
731773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
732773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore	/* It is the appropriate order to get objects from the Result stack */
733773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
734773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore	for (i = 0; i < arg_count; i++) {
735773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		arg = arguments[index];
736773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
737773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		/* Force the filling of the operand stack in inverse order */
738773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
739b7f9f04228eae2cf5adc2ffeb494d4970a8dd8a5Bob Moore		walk_state->operand_index = (u8) index;
740773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
741773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		status = acpi_ds_create_operand(walk_state, arg, index);
742773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		if (ACPI_FAILURE(status)) {
743773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore			goto cleanup;
744773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		}
745773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
746773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		index--;
747773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore
748773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore		ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
749b27d65975c252ff774edff8e01f0a9fd46d8ab62Bob Moore				  "Arg #%u (%p) done, Arg1=%p\n", index, arg,
750773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore				  first_arg));
7511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
7521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
7534be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	return_ACPI_STATUS(status);
7541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
7554be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown      cleanup:
7561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/*
7571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * We must undo everything done above; meaning that we must
7581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * pop everything off of the operand stack and delete those
7591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * objects
7601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
761773069d48030e670cf2032a13ddf16a2e0034df3Bob Moore	acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state);
7621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
763b27d65975c252ff774edff8e01f0a9fd46d8ab62Bob Moore	ACPI_EXCEPTION((AE_INFO, status, "While creating Arg %u", index));
7644be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown	return_ACPI_STATUS(status);
7651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
7664e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
7674e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore/*****************************************************************************
7684e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *
7694e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore * FUNCTION:    acpi_ds_evaluate_name_path
7704e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *
7714e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore * PARAMETERS:  walk_state      - Current state of the parse tree walk,
7724e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *                                the opcode of current operation should be
7734e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *                                AML_INT_NAMEPATH_OP
7744e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *
7754e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore * RETURN:      Status
7764e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *
7774e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore * DESCRIPTION: Translate the -name_path- parse tree object to the equivalent
7784e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *              interpreter object, convert it to value, if needed, duplicate
7794e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *              it, if needed, and push it onto the current result stack.
7804e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore *
7814e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore ****************************************************************************/
7824e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
7834e3156b183aa087bc19804b3295c7c1a71f64752Bob Mooreacpi_status acpi_ds_evaluate_name_path(struct acpi_walk_state *walk_state)
7844e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore{
7854e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	acpi_status status = AE_OK;
7864e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	union acpi_parse_object *op = walk_state->op;
7874e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	union acpi_operand_object **operand = &walk_state->operands[0];
7884e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	union acpi_operand_object *new_obj_desc;
7894e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	u8 type;
7904e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
7914e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	ACPI_FUNCTION_TRACE_PTR(ds_evaluate_name_path, walk_state);
7924e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
7934e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if (!op->common.parent) {
7944e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
7954e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		/* This happens after certain exception processing */
7964e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
7974e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		goto exit;
7984e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
7994e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8004e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
8014e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	    (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP) ||
8024e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	    (op->common.parent->common.aml_opcode == AML_REF_OF_OP)) {
8034e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8044e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		/* TBD: Should we specify this feature as a bit of op_info->Flags of these opcodes? */
8054e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8064e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		goto exit;
8074e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
8084e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8094e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	status = acpi_ds_create_operand(walk_state, op, 0);
8104e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if (ACPI_FAILURE(status)) {
8114e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		goto exit;
8124e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
8134e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8144e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if (op->common.flags & ACPI_PARSEOP_TARGET) {
8154e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		new_obj_desc = *operand;
8164e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		goto push_result;
8174e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
8184e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8193371c19c294a4cb3649aa4e84606be8a1d999e61Bob Moore	type = (*operand)->common.type;
8204e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8214e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	status = acpi_ex_resolve_to_value(operand, walk_state);
8224e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if (ACPI_FAILURE(status)) {
8234e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		goto exit;
8244e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
8254e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8264e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if (type == ACPI_TYPE_INTEGER) {
8274e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8284e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		/* It was incremented by acpi_ex_resolve_to_value */
8294e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8304e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		acpi_ut_remove_reference(*operand);
8314e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8324e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		status =
8334e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		    acpi_ut_copy_iobject_to_iobject(*operand, &new_obj_desc,
8344e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore						    walk_state);
8354e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		if (ACPI_FAILURE(status)) {
8364e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore			goto exit;
8374e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		}
8384e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	} else {
8394e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		/*
8404e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		 * The object either was anew created or is
8414e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		 * a Namespace node - don't decrement it.
8424e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		 */
8434e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		new_obj_desc = *operand;
8444e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
8454e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8464e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	/* Cleanup for name-path operand */
8474e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8484e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	status = acpi_ds_obj_stack_pop(1, walk_state);
8494e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if (ACPI_FAILURE(status)) {
8504e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		walk_state->result_obj = new_obj_desc;
8514e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		goto exit;
8524e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
8534e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8544e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore      push_result:
8554e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8564e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	walk_state->result_obj = new_obj_desc;
8574e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8584e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	status = acpi_ds_result_push(walk_state->result_obj, walk_state);
8594e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	if (ACPI_SUCCESS(status)) {
8604e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8614e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		/* Force to take it from stack */
8624e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8634e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore		op->common.flags |= ACPI_PARSEOP_IN_STACK;
8644e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	}
8654e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8664e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore      exit:
8674e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore
8684e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore	return_ACPI_STATUS(status);
8694e3156b183aa087bc19804b3295c7c1a71f64752Bob Moore}
870