summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-01-09 00:13:17 -0500
committerLen Brown <len.brown@intel.com>2009-01-09 03:30:47 -0500
commit95b482a8d31116f3f5c2a5089569393234d06385 (patch)
treef32aec8673a285a9d188948be97af3034ee06e93 /drivers/acpi/namespace
parent6620e0c49f577454b772fb381543d60ae53eb885 (diff)
ACPICA: create acpica/ directory
also, delete sleep/ and delete ACPI_CFLAGS from Makefile Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/namespace')
-rw-r--r--drivers/acpi/namespace/Makefile12
-rw-r--r--drivers/acpi/namespace/nsaccess.c676
-rw-r--r--drivers/acpi/namespace/nsalloc.c497
-rw-r--r--drivers/acpi/namespace/nsdump.c709
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c141
-rw-r--r--drivers/acpi/namespace/nseval.c278
-rw-r--r--drivers/acpi/namespace/nsinit.c593
-rw-r--r--drivers/acpi/namespace/nsload.c315
-rw-r--r--drivers/acpi/namespace/nsnames.c265
-rw-r--r--drivers/acpi/namespace/nsobject.c441
-rw-r--r--drivers/acpi/namespace/nsparse.c204
-rw-r--r--drivers/acpi/namespace/nspredef.c1065
-rw-r--r--drivers/acpi/namespace/nssearch.c415
-rw-r--r--drivers/acpi/namespace/nsutils.c997
-rw-r--r--drivers/acpi/namespace/nswalk.c296
-rw-r--r--drivers/acpi/namespace/nsxfeval.c812
-rw-r--r--drivers/acpi/namespace/nsxfname.c360
-rw-r--r--drivers/acpi/namespace/nsxfobj.c287
18 files changed, 0 insertions, 8363 deletions
diff --git a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
deleted file mode 100644
index 371a2daf837..00000000000
--- a/drivers/acpi/namespace/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Makefile for all Linux ACPI interpreter subdirectories
-#
-
-obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \
- nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
- nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
- nsparse.o nspredef.o
-
-obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
-
-EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
deleted file mode 100644
index 7954640e69c..00000000000
--- a/drivers/acpi/namespace/nsaccess.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/amlcode.h>
-#include <acpi/acnamesp.h>
-#include <acpi/acdispat.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsaccess")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_root_initialize
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Allocate and initialize the default root named objects
- *
- * MUTEX: Locks namespace for entire execution
- *
- ******************************************************************************/
-acpi_status acpi_ns_root_initialize(void)
-{
- acpi_status status;
- const struct acpi_predefined_names *init_val = NULL;
- struct acpi_namespace_node *new_node;
- union acpi_operand_object *obj_desc;
- acpi_string val = NULL;
-
- ACPI_FUNCTION_TRACE(ns_root_initialize);
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /*
- * The global root ptr is initially NULL, so a non-NULL value indicates
- * that acpi_ns_root_initialize() has already been called; just return.
- */
- if (acpi_gbl_root_node) {
- status = AE_OK;
- goto unlock_and_exit;
- }
-
- /*
- * Tell the rest of the subsystem that the root is initialized
- * (This is OK because the namespace is locked)
- */
- acpi_gbl_root_node = &acpi_gbl_root_node_struct;
-
- /* Enter the pre-defined names in the name table */
-
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "Entering predefined entries into namespace\n"));
-
- for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
-
- /* _OSI is optional for now, will be permanent later */
-
- if (!ACPI_STRCMP(init_val->name, "_OSI")
- && !acpi_gbl_create_osi_method) {
- continue;
- }
-
- status = acpi_ns_lookup(NULL, init_val->name, init_val->type,
- ACPI_IMODE_LOAD_PASS2,
- ACPI_NS_NO_UPSEARCH, NULL, &new_node);
-
- if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */
- ACPI_EXCEPTION((AE_INFO, status,
- "Could not create predefined name %s",
- init_val->name));
- }
-
- /*
- * Name entered successfully.
- * If entry in pre_defined_names[] specifies an
- * initial value, create the initial value.
- */
- if (init_val->val) {
- status = acpi_os_predefined_override(init_val, &val);
- if (ACPI_FAILURE(status)) {
- ACPI_ERROR((AE_INFO,
- "Could not override predefined %s",
- init_val->name));
- }
-
- if (!val) {
- val = init_val->val;
- }
-
- /*
- * Entry requests an initial value, allocate a
- * descriptor for it.
- */
- obj_desc =
- acpi_ut_create_internal_object(init_val->type);
- if (!obj_desc) {
- status = AE_NO_MEMORY;
- goto unlock_and_exit;
- }
-
- /*
- * Convert value string from table entry to
- * internal representation. Only types actually
- * used for initial values are implemented here.
- */
- switch (init_val->type) {
- case ACPI_TYPE_METHOD:
- obj_desc->method.param_count =
- (u8) ACPI_TO_INTEGER(val);
- obj_desc->common.flags |= AOPOBJ_DATA_VALID;
-
-#if defined (ACPI_ASL_COMPILER)
-
- /* Save the parameter count for the i_aSL compiler */
-
- new_node->value = obj_desc->method.param_count;
-#else
- /* Mark this as a very SPECIAL method */
-
- obj_desc->method.method_flags =
- AML_METHOD_INTERNAL_ONLY;
- obj_desc->method.implementation =
- acpi_ut_osi_implementation;
-#endif
- break;
-
- case ACPI_TYPE_INTEGER:
-
- obj_desc->integer.value = ACPI_TO_INTEGER(val);
- break;
-
- case ACPI_TYPE_STRING:
-
- /*
- * Build an object around the static string
- */
- obj_desc->string.length =
- (u32) ACPI_STRLEN(val);
- obj_desc->string.pointer = val;
- obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
- break;
-
- case ACPI_TYPE_MUTEX:
-
- obj_desc->mutex.node = new_node;
- obj_desc->mutex.sync_level =
- (u8) (ACPI_TO_INTEGER(val) - 1);
-
- /* Create a mutex */
-
- status =
- acpi_os_create_mutex(&obj_desc->mutex.
- os_mutex);
- if (ACPI_FAILURE(status)) {
- acpi_ut_remove_reference(obj_desc);
- goto unlock_and_exit;
- }
-
- /* Special case for ACPI Global Lock */
-
- if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
- acpi_gbl_global_lock_mutex = obj_desc;
-
- /* Create additional counting semaphore for global lock */
-
- status =
- acpi_os_create_semaphore(1, 0,
- &acpi_gbl_global_lock_semaphore);
- if (ACPI_FAILURE(status)) {
- acpi_ut_remove_reference
- (obj_desc);
- goto unlock_and_exit;
- }
- }
- break;
-
- default:
-
- ACPI_ERROR((AE_INFO,
- "Unsupported initial type value %X",
- init_val->type));
- acpi_ut_remove_reference(obj_desc);
- obj_desc = NULL;
- continue;
- }
-
- /* Store pointer to value descriptor in the Node */
-
- status = acpi_ns_attach_object(new_node, obj_desc,
- ACPI_GET_OBJECT_TYPE
- (obj_desc));
-
- /* Remove local reference to the object */
-
- acpi_ut_remove_reference(obj_desc);
- }
- }
-
- unlock_and_exit:
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
-
- /* Save a handle to "_GPE", it is always present */
-
- if (ACPI_SUCCESS(status)) {
- status = acpi_ns_get_node(NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
- &acpi_gbl_fadt_gpe_device);
- }
-
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_lookup
- *
- * PARAMETERS: scope_info - Current scope info block
- * Pathname - Search pathname, in internal format
- * (as represented in the AML stream)
- * Type - Type associated with name
- * interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
- * Flags - Flags describing the search restrictions
- * walk_state - Current state of the walk
- * return_node - Where the Node is placed (if found
- * or created successfully)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Find or enter the passed name in the name space.
- * Log an error if name not found in Exec mode.
- *
- * MUTEX: Assumes namespace is locked.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_lookup(union acpi_generic_state *scope_info,
- char *pathname,
- acpi_object_type type,
- acpi_interpreter_mode interpreter_mode,
- u32 flags,
- struct acpi_walk_state *walk_state,
- struct acpi_namespace_node **return_node)
-{
- acpi_status status;
- char *path = pathname;
- struct acpi_namespace_node *prefix_node;
- struct acpi_namespace_node *current_node = NULL;
- struct acpi_namespace_node *this_node = NULL;
- u32 num_segments;
- u32 num_carats;
- acpi_name simple_name;
- acpi_object_type type_to_check_for;
- acpi_object_type this_search_type;
- u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
- u32 local_flags;
-
- ACPI_FUNCTION_TRACE(ns_lookup);
-
- if (!return_node) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT);
- *return_node = ACPI_ENTRY_NOT_FOUND;
- acpi_gbl_ns_lookup_count++;
-
- if (!acpi_gbl_root_node) {
- return_ACPI_STATUS(AE_NO_NAMESPACE);
- }
-
- /*
- * Get the prefix scope.
- * A null scope means use the root scope
- */
- if ((!scope_info) || (!scope_info->scope.node)) {
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Null scope prefix, using root node (%p)\n",
- acpi_gbl_root_node));
-
- prefix_node = acpi_gbl_root_node;
- } else {
- prefix_node = scope_info->scope.node;
- if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
- ACPI_DESC_TYPE_NAMED) {
- ACPI_ERROR((AE_INFO, "%p is not a namespace node [%s]",
- prefix_node,
- acpi_ut_get_descriptor_name(prefix_node)));
- return_ACPI_STATUS(AE_AML_INTERNAL);
- }
-
- if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
- /*
- * This node might not be a actual "scope" node (such as a
- * Device/Method, etc.) It could be a Package or other object node.
- * Backup up the tree to find the containing scope node.
- */
- while (!acpi_ns_opens_scope(prefix_node->type) &&
- prefix_node->type != ACPI_TYPE_ANY) {
- prefix_node =
- acpi_ns_get_parent_node(prefix_node);
- }
- }
- }
-
- /* Save type TBD: may be no longer necessary */
-
- type_to_check_for = type;
-
- /*
- * Begin examination of the actual pathname
- */
- if (!pathname) {
-
- /* A Null name_path is allowed and refers to the root */
-
- num_segments = 0;
- this_node = acpi_gbl_root_node;
- path = "";
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Null Pathname (Zero segments), Flags=%X\n",
- flags));
- } else {
- /*
- * Name pointer is valid (and must be in internal name format)
- *
- * Check for scope prefixes:
- *
- * As represented in the AML stream, a namepath consists of an
- * optional scope prefix followed by a name segment part.
- *
- * If present, the scope prefix is either a Root Prefix (in
- * which case the name is fully qualified), or one or more
- * Parent Prefixes (in which case the name's scope is relative
- * to the current scope).
- */
- if (*path == (u8) AML_ROOT_PREFIX) {
-
- /* Pathname is fully qualified, start from the root */
-
- this_node = acpi_gbl_root_node;
- search_parent_flag = ACPI_NS_NO_UPSEARCH;
-
- /* Point to name segment part */
-
- path++;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Path is absolute from root [%p]\n",
- this_node));
- } else {
- /* Pathname is relative to current scope, start there */
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Searching relative to prefix scope [%4.4s] (%p)\n",
- acpi_ut_get_node_name(prefix_node),
- prefix_node));
-
- /*
- * Handle multiple Parent Prefixes (carat) by just getting
- * the parent node for each prefix instance.
- */
- this_node = prefix_node;
- num_carats = 0;
- while (*path == (u8) AML_PARENT_PREFIX) {
-
- /* Name is fully qualified, no search rules apply */
-
- search_parent_flag = ACPI_NS_NO_UPSEARCH;
- /*
- * Point past this prefix to the name segment
- * part or the next Parent Prefix
- */
- path++;
-
- /* Backup to the parent node */
-
- num_carats++;
- this_node = acpi_ns_get_parent_node(this_node);
- if (!this_node) {
-
- /* Current scope has no parent scope */
-
- ACPI_ERROR((AE_INFO,
- "ACPI path has too many parent prefixes (^) - reached beyond root node"));
- return_ACPI_STATUS(AE_NOT_FOUND);
- }
- }
-
- if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Search scope is [%4.4s], path has %d carat(s)\n",
- acpi_ut_get_node_name
- (this_node), num_carats));
- }
- }
-
- /*
- * Determine the number of ACPI name segments in this pathname.
- *
- * The segment part consists of either:
- * - A Null name segment (0)
- * - A dual_name_prefix followed by two 4-byte name segments
- * - A multi_name_prefix followed by a byte indicating the
- * number of segments and the segments themselves.
- * - A single 4-byte name segment
- *
- * Examine the name prefix opcode, if any, to determine the number of
- * segments.
- */
- switch (*path) {
- case 0:
- /*
- * Null name after a root or parent prefixes. We already
- * have the correct target node and there are no name segments.
- */
- num_segments = 0;
- type = this_node->type;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Prefix-only Pathname (Zero name segments), Flags=%X\n",
- flags));
- break;
-
- case AML_DUAL_NAME_PREFIX:
-
- /* More than one name_seg, search rules do not apply */
-
- search_parent_flag = ACPI_NS_NO_UPSEARCH;
-
- /* Two segments, point to first name segment */
-
- num_segments = 2;
- path++;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Dual Pathname (2 segments, Flags=%X)\n",
- flags));
- break;
-
- case AML_MULTI_NAME_PREFIX_OP:
-
- /* More than one name_seg, search rules do not apply */
-
- search_parent_flag = ACPI_NS_NO_UPSEARCH;
-
- /* Extract segment count, point to first name segment */
-
- path++;
- num_segments = (u32) (u8) * path;
- path++;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Multi Pathname (%d Segments, Flags=%X)\n",
- num_segments, flags));
- break;
-
- default:
- /*
- * Not a Null name, no Dual or Multi prefix, hence there is
- * only one name segment and Pathname is already pointing to it.
- */
- num_segments = 1;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Simple Pathname (1 segment, Flags=%X)\n",
- flags));
- break;
- }
-
- ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));
- }
-
- /*
- * Search namespace for each segment of the name. Loop through and
- * verify (or add to the namespace) each name segment.
- *
- * The object type is significant only at the last name
- * segment. (We don't care about the types along the path, only
- * the type of the final target object.)
- */
- this_search_type = ACPI_TYPE_ANY;
- current_node = this_node;
- while (num_segments && current_node) {
- num_segments--;
- if (!num_segments) {
- /*
- * This is the last segment, enable typechecking
- */
- this_search_type = type;
-
- /*
- * Only allow automatic parent search (search rules) if the caller
- * requested it AND we have a single, non-fully-qualified name_seg
- */
- if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
- (flags & ACPI_NS_SEARCH_PARENT)) {
- local_flags |= ACPI_NS_SEARCH_PARENT;
- }
-
- /* Set error flag according to caller */
-
- if (flags & ACPI_NS_ERROR_IF_FOUND) {
- local_flags |= ACPI_NS_ERROR_IF_FOUND;
- }
- }
-
- /* Extract one ACPI name from the front of the pathname */
-
- ACPI_MOVE_32_TO_32(&simple_name, path);
-
- /* Try to find the single (4 character) ACPI name */
-
- status =
- acpi_ns_search_and_enter(simple_name, walk_state,
- current_node, interpreter_mode,
- this_search_type, local_flags,
- &this_node);
- if (ACPI_FAILURE(status)) {
- if (status == AE_NOT_FOUND) {
-
- /* Name not found in ACPI namespace */
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Name [%4.4s] not found in scope [%4.4s] %p\n",
- (char *)&simple_name,
- (char *)&current_node->name,
- current_node));
- }
-
- *return_node = this_node;
- return_ACPI_STATUS(status);
- }
-
- /* More segments to follow? */
-
- if (num_segments > 0) {
- /*
- * If we have an alias to an object that opens a scope (such as a
- * device or processor), we need to dereference the alias here so that
- * we can access any children of the original node (via the remaining
- * segments).
- */
- if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) {
- if (!this_node->object) {
- return_ACPI_STATUS(AE_NOT_EXIST);
- }
-
- if (acpi_ns_opens_scope
- (((struct acpi_namespace_node *)this_node->
- object)->type)) {
- this_node =
- (struct acpi_namespace_node *)
- this_node->object;
- }
- }
- }
-
- /* Special handling for the last segment (num_segments == 0) */
-
- else {
- /*
- * Sanity typecheck of the target object:
- *
- * If 1) This is the last segment (num_segments == 0)
- * 2) And we are looking for a specific type
- * (Not checking for TYPE_ANY)
- * 3) Which is not an alias
- * 4) Which is not a local type (TYPE_SCOPE)
- * 5) And the type of target object is known (not TYPE_ANY)
- * 6) And target object does not match what we are looking for
- *
- * Then we have a type mismatch. Just warn and ignore it.
- */
- if ((type_to_check_for != ACPI_TYPE_ANY) &&
- (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&
- (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS)
- && (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE)
- && (this_node->type != ACPI_TYPE_ANY)
- && (this_node->type != type_to_check_for)) {
-
- /* Complain about a type mismatch */
-
- ACPI_WARNING((AE_INFO,
- "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
- ACPI_CAST_PTR(char, &simple_name),
- acpi_ut_get_type_name(this_node->
- type),
- acpi_ut_get_type_name
- (type_to_check_for)));
- }
-
- /*
- * If this is the last name segment and we are not looking for a
- * specific type, but the type of found object is known, use that type
- * to (later) see if it opens a scope.
- */
- if (type == ACPI_TYPE_ANY) {
- type = this_node->type;
- }
- }
-
- /* Point to next name segment and make this node current */
-
- path += ACPI_NAME_SIZE;
- current_node = this_node;
- }
-
- /*
- * Always check if we need to open a new scope
- */
- if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {
- /*
- * If entry is a type which opens a scope, push the new scope on the
- * scope stack.
- */
- if (acpi_ns_opens_scope(type)) {
- status =
- acpi_ds_scope_stack_push(this_node, type,
- walk_state);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
- }
- }
-
- *return_node = this_node;
- return_ACPI_STATUS(AE_OK);
-}
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
deleted file mode 100644
index cb2afbf4e45..00000000000
--- a/drivers/acpi/namespace/nsalloc.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsalloc - Namespace allocation and deletion utilities
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsalloc")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_create_node
- *
- * PARAMETERS: Name - Name of the new node (4 char ACPI name)
- *
- * RETURN: New namespace node (Null on failure)
- *
- * DESCRIPTION: Create a namespace node
- *
- ******************************************************************************/
-struct acpi_namespace_node *acpi_ns_create_node(u32 name)
-{
- struct acpi_namespace_node *node;
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- u32 temp;
-#endif
-
- ACPI_FUNCTION_TRACE(ns_create_node);
-
- node = acpi_os_acquire_object(acpi_gbl_namespace_cache);
- if (!node) {
- return_PTR(NULL);
- }
-
- ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- temp =
- acpi_gbl_ns_node_list->total_allocated -
- acpi_gbl_ns_node_list->total_freed;
- if (temp > acpi_gbl_ns_node_list->max_occupied) {
- acpi_gbl_ns_node_list->max_occupied = temp;
- }
-#endif
-
- node->name.integer = name;
- ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);
- return_PTR(node);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_delete_node
- *
- * PARAMETERS: Node - Node to be deleted
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete a namespace node
- *
- ******************************************************************************/
-
-void acpi_ns_delete_node(struct acpi_namespace_node *node)
-{
- struct acpi_namespace_node *parent_node;
- struct acpi_namespace_node *prev_node;
- struct acpi_namespace_node *next_node;
-
- ACPI_FUNCTION_TRACE_PTR(ns_delete_node, node);
-
- parent_node = acpi_ns_get_parent_node(node);
-
- prev_node = NULL;
- next_node = parent_node->child;
-
- /* Find the node that is the previous peer in the parent's child list */
-
- while (next_node != node) {
- prev_node = next_node;
- next_node = prev_node->peer;
- }
-
- if (prev_node) {
-
- /* Node is not first child, unlink it */
-
- prev_node->peer = next_node->peer;
- if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
- prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
- }
- } else {
- /* Node is first child (has no previous peer) */
-
- if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
-
- /* No peers at all */
-
- parent_node->child = NULL;
- } else { /* Link peer list to parent */
-
- parent_node->child = next_node->peer;
- }
- }
-
- ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
-
- /*
- * Detach an object if there is one, then delete the node
- */
- acpi_ns_detach_object(node);
- (void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
- return_VOID;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_install_node
- *
- * PARAMETERS: walk_state - Current state of the walk
- * parent_node - The parent of the new Node
- * Node - The new Node to install
- * Type - ACPI object type of the new Node
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize a new namespace node and install it amongst
- * its peers.
- *
- * Note: Current namespace lookup is linear search. This appears
- * to be sufficient as namespace searches consume only a small
- * fraction of the execution time of the ACPI subsystem.
- *
- ******************************************************************************/
-
-void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */
- struct acpi_namespace_node *node, /* New Child */
- acpi_object_type type)
-{
- acpi_owner_id owner_id = 0;
- struct acpi_namespace_node *child_node;
-
- ACPI_FUNCTION_TRACE(ns_install_node);
-
- /*
- * Get the owner ID from the Walk state
- * The owner ID is used to track table deletion and
- * deletion of objects created by methods
- */
- if (walk_state) {
- owner_id = walk_state->owner_id;
- }
-
- /* Link the new entry into the parent and existing children */
-
- child_node = parent_node->child;
- if (!child_node) {
- parent_node->child = node;
- node->flags |= ANOBJ_END_OF_PEER_LIST;
- node->peer = parent_node;
- } else {
- while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
- child_node = child_node->peer;
- }
-
- child_node->peer = node;
-
- /* Clear end-of-list flag */
-
- child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
- node->flags |= ANOBJ_END_OF_PEER_LIST;
- node->peer = parent_node;
- }
-
- /* Init the new entry */
-
- node->owner_id = owner_id;
- node->type = (u8) type;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
- acpi_ut_get_node_name(node),
- acpi_ut_get_type_name(node->type), node, owner_id,
- acpi_ut_get_node_name(parent_node),
- acpi_ut_get_type_name(parent_node->type),
- parent_node));
-
- return_VOID;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_delete_children
- *
- * PARAMETERS: parent_node - Delete this objects children
- *
- * RETURN: None.
- *
- * DESCRIPTION: Delete all children of the parent object. In other words,
- * deletes a "scope".
- *
- ******************************************************************************/
-
-void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
-{
- struct acpi_namespace_node *child_node;
- struct acpi_namespace_node *next_node;
- u8 flags;
-
- ACPI_FUNCTION_TRACE_PTR(ns_delete_children, parent_node);
-
- if (!parent_node) {
- return_VOID;
- }
-
- /* If no children, all done! */
-
- child_node = parent_node->child;
- if (!child_node) {
- return_VOID;
- }
-
- /*
- * Deallocate all children at this level
- */
- do {
-
- /* Get the things we need */
-
- next_node = child_node->peer;
- flags = child_node->flags;
-
- /* Grandchildren should have all been deleted already */
-
- if (child_node->child) {
- ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p",
- parent_node, child_node));
- }
-
- /* Now we can free this child object */
-
- ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
-
- ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
- "Object %p, Remaining %X\n", child_node,
- acpi_gbl_current_node_count));
-
- /*
- * Detach an object if there is one, then free the child node
- */
- acpi_ns_detach_object(child_node);
-
- /* Now we can delete the node */
-
- (void)acpi_os_release_object(acpi_gbl_namespace_cache,
- child_node);
-
- /* And move on to the next child in the list */
-
- child_node = next_node;
-
- } while (!(flags & ANOBJ_END_OF_PEER_LIST));
-
- /* Clear the parent's child pointer */
-
- parent_node->child = NULL;
-
- return_VOID;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_delete_namespace_subtree
- *
- * PARAMETERS: parent_node - Root of the subtree to be deleted
- *
- * RETURN: None.
- *
- * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
- * stored within the subtree.
- *
- ******************************************************************************/
-
-void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
-{
- struct acpi_namespace_node *child_node = NULL;
- u32 level = 1;
-
- ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree);
-
- if (!parent_node) {
- return_VOID;
- }
-
- /*
- * Traverse the tree of objects until we bubble back up
- * to where we started.
- */
- while (level > 0) {
-
- /* Get the next node in this scope (NULL if none) */
-
- child_node =
- acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
- child_node);
- if (child_node) {
-
- /* Found a child node - detach any attached object */
-
- acpi_ns_detach_object(child_node);
-
- /* Check if this node has any children */
-
- if (acpi_ns_get_next_node
- (ACPI_TYPE_ANY, child_node, NULL)) {
- /*
- * There is at least one child of this node,
- * visit the node
- */
- level++;
- parent_node = child_node;
- child_node = NULL;
- }
- } else {
- /*
- * No more children of this parent node.
- * Move up to the grandparent.
- */
- level--;
-
- /*
- * Now delete all of the children of this parent
- * all at the same time.
- */
- acpi_ns_delete_children(parent_node);
-
- /* New "last child" is this parent node */
-
- child_node = parent_node;
-
- /* Move up the tree to the grandparent */
-
- parent_node = acpi_ns_get_parent_node(parent_node);
- }
- }
-
- return_VOID;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_delete_namespace_by_owner
- *
- * PARAMETERS: owner_id - All nodes with this owner will be deleted
- *
- * RETURN: Status
- *
- * DESCRIPTION: Delete entries within the namespace that are owned by a
- * specific ID. Used to delete entire ACPI tables. All
- * reference counts are updated.
- *
- * MUTEX: Locks namespace during deletion walk.
- *
- ******************************************************************************/
-
-void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
-{
- struct acpi_namespace_node *child_node;
- struct acpi_namespace_node *deletion_node;
- struct acpi_namespace_node *parent_node;
- u32 level;
- acpi_status status;
-
- ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id);
-
- if (owner_id == 0) {
- return_VOID;
- }
-
- /* Lock namespace for possible update */
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return_VOID;
- }
-
- deletion_node = NULL;
- parent_node = acpi_gbl_root_node;
- child_node = NULL;
- level = 1;
-
- /*
- * Traverse the tree of nodes until we bubble back up
- * to where we started.
- */
- while (level > 0) {
- /*
- * Get the next child of this parent node. When child_node is NULL,
- * the first child of the parent is returned
- */
- child_node =
- acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
- child_node);
-
- if (deletion_node) {
- acpi_ns_delete_children(deletion_node);
- acpi_ns_delete_node(deletion_node);
- deletion_node = NULL;
- }
-
- if (child_node) {
- if (child_node->owner_id == owner_id) {
-
- /* Found a matching child node - detach any attached object */
-
- acpi_ns_detach_object(child_node);
- }
-
- /* Check if this node has any children */
-
- if (acpi_ns_get_next_node
- (ACPI_TYPE_ANY, child_node, NULL)) {
- /*
- * There is at least one child of this node,
- * visit the node
- */
- level++;
- parent_node = child_node;
- child_node = NULL;
- } else if (child_node->owner_id == owner_id) {
- deletion_node = child_node;
- }
- } else {
- /*
- * No more children of this parent node.
- * Move up to the grandparent.
- */
- level--;
- if (level != 0) {
- if (parent_node->owner_id == owner_id) {
- deletion_node = parent_node;
- }
- }
-
- /* New "last child" is this parent node */
-
- child_node = parent_node;
-
- /* Move up the tree to the grandparent */
-
- parent_node = acpi_ns_get_parent_node(parent_node);
- }
- }
-
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return_VOID;
-}
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
deleted file mode 100644
index 48f02e659f2..00000000000
--- a/drivers/acpi/namespace/nsdump.c
+++ /dev/null
@@ -1,709 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsdump - table dumping routines for debug
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsdump")
-
-/* Local prototypes */
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-void acpi_ns_dump_root_devices(void);
-
-static acpi_status
-acpi_ns_dump_one_device(acpi_handle obj_handle,
- u32 level, void *context, void **return_value);
-#endif
-
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_print_pathname
- *
- * PARAMETERS: num_segments - Number of ACPI name segments
- * Pathname - The compressed (internal) path
- *
- * RETURN: None
- *
- * DESCRIPTION: Print an object's full namespace pathname
- *
- ******************************************************************************/
-
-void acpi_ns_print_pathname(u32 num_segments, char *pathname)
-{
- u32 i;
-
- ACPI_FUNCTION_NAME(ns_print_pathname);
-
- if (!(acpi_dbg_level & ACPI_LV_NAMES)
- || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
- return;
- }
-
- /* Print the entire name */
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
-
- while (num_segments) {
- for (i = 0; i < 4; i++) {
- ACPI_IS_PRINT(pathname[i]) ?
- acpi_os_printf("%c", pathname[i]) :
- acpi_os_printf("?");
- }
-
- pathname += ACPI_NAME_SIZE;
- num_segments--;
- if (num_segments) {
- acpi_os_printf(".");
- }
- }
-
- acpi_os_printf("]\n");
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_pathname
- *
- * PARAMETERS: Handle - Object
- * Msg - Prefix message
- * Level - Desired debug level
- * Component - Caller's component ID
- *
- * RETURN: None
- *
- * DESCRIPTION: Print an object's full namespace pathname
- * Manages allocation/freeing of a pathname buffer
- *
- ******************************************************************************/
-
-void
-acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
-{
-
- ACPI_FUNCTION_TRACE(ns_dump_pathname);
-
- /* Do this only if the requested debug level and component are enabled */
-
- if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) {
- return_VOID;
- }
-
- /* Convert handle to a full pathname and print it (with supplied message) */
-
- acpi_ns_print_node_pathname(handle, msg);
- acpi_os_printf("\n");
- return_VOID;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_one_object
- *
- * PARAMETERS: obj_handle - Node to be dumped
- * Level - Nesting level of the handle
- * Context - Passed into walk_namespace
- * return_value - Not used
- *
- * RETURN: Status
- *
- * DESCRIPTION: Dump a single Node
- * This procedure is a user_function called by acpi_ns_walk_namespace.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_dump_one_object(acpi_handle obj_handle,
- u32 level, void *context, void **return_value)
-{
- struct acpi_walk_info *info = (struct acpi_walk_info *)context;
- struct acpi_namespace_node *this_node;
- union acpi_operand_object *obj_desc = NULL;
- acpi_object_type obj_type;
- acpi_object_type type;
- u32 bytes_to_dump;
- u32 dbg_level;
- u32 i;
-
- ACPI_FUNCTION_NAME(ns_dump_one_object);
-
- /* Is output enabled? */
-
- if (!(acpi_dbg_level & info->debug_level)) {
- return (AE_OK);
- }
-
- if (!obj_handle) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
- return (AE_OK);
- }
-
- this_node = acpi_ns_map_handle_to_node(obj_handle);
- type = this_node->type;
-
- /* Check if the owner matches */
-
- if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
- (info->owner_id != this_node->owner_id)) {
- return (AE_OK);
- }
-
- if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
-
- /* Indent the object according to the level */
-
- acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
-
- /* Check the node type and name */
-
- if (type > ACPI_TYPE_LOCAL_MAX) {
- ACPI_WARNING((AE_INFO, "Invalid ACPI Object Type %08X",
- type));
- }
-
- if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
- this_node->name.integer =
- acpi_ut_repair_name(this_node->name.ascii);
-
- ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
- this_node->name.integer));
- }
-
- acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
- }
-
- /*
- * Now we can print out the pertinent information
- */
- acpi_os_printf(" %-12s %p %2.2X ",
- acpi_ut_get_type_name(type), this_node,
- this_node->owner_id);
-
- dbg_level = acpi_dbg_level;
- acpi_dbg_level = 0;
- obj_desc = acpi_ns_get_attached_object(this_node);
- acpi_dbg_level = dbg_level;
-
- /* Temp nodes are those nodes created by a control method */
-
- if (this_node->flags & ANOBJ_TEMPORARY) {
- acpi_os_printf("(T) ");
- }
-
- switch (info->display_type & ACPI_DISPLAY_MASK) {
- case ACPI_DISPLAY_SUMMARY:
-
- if (!obj_desc) {
-
- /* No attached object, we are done */
-
- acpi_os_printf("\n");
- return (AE_OK);
- }
-
- switch (type) {
- case ACPI_TYPE_PROCESSOR:
-
- acpi_os_printf("ID %X Len %.4X Addr %p\n",
- obj_desc->processor.proc_id,
- obj_desc->processor.length,
- ACPI_CAST_PTR(void,
- obj_desc->processor.
- address));
- break;
-
- case ACPI_TYPE_DEVICE:
-
- acpi_os_printf("Notify Object: %p\n", obj_desc);
- break;
-
- case ACPI_TYPE_METHOD:
-
- acpi_os_printf("Args %X Len %.4X Aml %p\n",
- (u32) obj_desc->method.param_count,
- obj_desc->method.aml_length,
- obj_desc->method.aml_start);
- break;
-
- case ACPI_TYPE_INTEGER:
-
- acpi_os_printf("= %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64(obj_desc->integer.
- value));
- break;
-
- case ACPI_TYPE_PACKAGE:
-
- if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
- acpi_os_printf("Elements %.2X\n",
- obj_desc->package.count);
- } else {
- acpi_os_printf("[Length not yet evaluated]\n");
- }
- break;
-
- case ACPI_TYPE_BUFFER:
-
- if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
- acpi_os_printf("Len %.2X",
- obj_desc->buffer.length);
-
- /* Dump some of the buffer */
-
- if (obj_desc->buffer.length > 0) {
- acpi_os_printf(" =");
- for (i = 0;
- (i < obj_desc->buffer.length
- && i < 12); i++) {
- acpi_os_printf(" %.2hX",
- obj_desc->buffer.
- pointer[i]);
- }
- }
- acpi_os_printf("\n");
- } else {
- acpi_os_printf("[Length not yet evaluated]\n");
- }
- break;
-
- case ACPI_TYPE_STRING:
-
- acpi_os_printf("Len %.2X ", obj_desc->string.length);
- acpi_ut_print_string(obj_desc->string.pointer, 32);
- acpi_os_printf("\n");
- break;
-
- case ACPI_TYPE_REGION:
-
- acpi_os_printf("[%s]",
- acpi_ut_get_region_name(obj_desc->region.
- space_id));
- if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
- acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
- ACPI_FORMAT_NATIVE_UINT
- (obj_desc->region.address),
- obj_desc->region.length);
- } else {
- acpi_os_printf
- (" [Address/Length not yet evaluated]\n");
- }
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- acpi_os_printf("[%s]\n",
- acpi_ut_get_reference_name(obj_desc));
- break;
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- if (obj_desc->buffer_field.buffer_obj &&
- obj_desc->buffer_field.buffer_obj->buffer.node) {
- acpi_os_printf("Buf [%4.4s]",
- acpi_ut_get_node_name(obj_desc->
- buffer_field.
- buffer_obj->
- buffer.
- node));
- }
- break;
-
- case ACPI_TYPE_LOCAL_REGION_FIELD:
-
- acpi_os_printf("Rgn [%4.4s]",
- acpi_ut_get_node_name(obj_desc->
- common_field.
- region_obj->region.
- node));
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
- acpi_ut_get_node_name(obj_desc->
- common_field.
- region_obj->region.
- node),
- acpi_ut_get_node_name(obj_desc->
- bank_field.
- bank_obj->
- common_field.
- node));
- break;
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
- acpi_ut_get_node_name(obj_desc->
- index_field.
- index_obj->
- common_field.node),
- acpi_ut_get_node_name(obj_desc->
- index_field.
- data_obj->
- common_field.
- node));
- break;
-
- case ACPI_TYPE_LOCAL_ALIAS:
- case ACPI_TYPE_LOCAL_METHOD_ALIAS:
-
- acpi_os_printf("Target %4.4s (%p)\n",
- acpi_ut_get_node_name(obj_desc),
- obj_desc);
- break;
-
- default:
-
- acpi_os_printf("Object %p\n", obj_desc);
- break;
- }
-
- /* Common field handling */
-
- switch (type) {
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
- (obj_desc->common_field.
- base_byte_offset * 8)
- +
- obj_desc->common_field.
- start_field_bit_offset,
- obj_desc->common_field.bit_length,
- obj_desc->common_field.
- access_byte_width);
- break;
-
- default:
- break;
- }
- break;
-
- case ACPI_DISPLAY_OBJECTS:
-
- acpi_os_printf("O:%p", obj_desc);
- if (!obj_desc) {
-
- /* No attached object, we are done */
-
- acpi_os_printf("\n");
- return (AE_OK);
- }
-
- acpi_os_printf("(R%d)", obj_desc->common.reference_count);
-
- switch (type) {
- case ACPI_TYPE_METHOD:
-
- /* Name is a Method and its AML offset/length are set */
-
- acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
- obj_desc->method.aml_length);
- break;
-
- case ACPI_TYPE_INTEGER:
-
- acpi_os_printf(" I:%8.8X8.8%X\n",
- ACPI_FORMAT_UINT64(obj_desc->integer.
- value));
- break;
-
- case ACPI_TYPE_STRING:
-
- acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
- obj_desc->string.length);
- break;
-
- case ACPI_TYPE_BUFFER:
-
- acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
- obj_desc->buffer.length);
- break;
-
- default:
-
- acpi_os_printf("\n");
- break;
- }
- break;
-
- default:
- acpi_os_printf("\n");
- break;
- }
-
- /* If debug turned off, done */
-
- if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
- return (AE_OK);
- }
-
- /* If there is an attached object, display it */
-
- dbg_level = acpi_dbg_level;
- acpi_dbg_level = 0;
- obj_desc = acpi_ns_get_attached_object(this_node);
- acpi_dbg_level = dbg_level;
-
- /* Dump attached objects */
-
- while (obj_desc) {
- obj_type = ACPI_TYPE_INVALID;
- acpi_os_printf("Attached Object %p: ", obj_desc);
-
- /* Decode the type of attached object and dump the contents */
-
- switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
- case ACPI_DESC_TYPE_NAMED:
-
- acpi_os_printf("(Ptr to Node)\n");
- bytes_to_dump = sizeof(struct acpi_namespace_node);
- ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
- break;
-
- case ACPI_DESC_TYPE_OPERAND:
-
- obj_type = ACPI_GET_OBJECT_TYPE(obj_desc);
-
- if (obj_type > ACPI_TYPE_LOCAL_MAX) {
- acpi_os_printf
- ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
- obj_type);
- bytes_to_dump = 32;
- } else {
- acpi_os_printf
- ("(Pointer to ACPI Object type %.2X [%s])\n",
- obj_type, acpi_ut_get_type_name(obj_type));
- bytes_to_dump =
- sizeof(union acpi_operand_object);
- }
-
- ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
- break;
-
- default:
-
- break;
- }
-
- /* If value is NOT an internal object, we are done */
-
- if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
- ACPI_DESC_TYPE_OPERAND) {
- goto cleanup;
- }
-
- /*
- * Valid object, get the pointer to next level, if any
- */
- switch (obj_type) {
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_STRING:
- /*
- * NOTE: takes advantage of common fields between string/buffer
- */
- bytes_to_dump = obj_desc->string.length;
- obj_desc = (void *)obj_desc->string.pointer;
- acpi_os_printf("(Buffer/String pointer %p length %X)\n",
- obj_desc, bytes_to_dump);
- ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
- goto cleanup;
-
- case ACPI_TYPE_BUFFER_FIELD:
- obj_desc =
- (union acpi_operand_object *)obj_desc->buffer_field.
- buffer_obj;
- break;
-
- case ACPI_TYPE_PACKAGE:
- obj_desc = (void *)obj_desc->package.elements;
- break;
-
- case ACPI_TYPE_METHOD:
- obj_desc = (void *)obj_desc->method.aml_start;
- break;
-
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- obj_desc = (void *)obj_desc->field.region_obj;
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- obj_desc = (void *)obj_desc->bank_field.region_obj;
- break;
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
- obj_desc = (void *)obj_desc->index_field.index_obj;
- break;
-
- default:
- goto cleanup;
- }
-
- obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
- }
-
- cleanup:
- acpi_os_printf("\n");
- return (AE_OK);
-}
-
-#ifdef ACPI_FUTURE_USAGE
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_objects
- *
- * PARAMETERS: Type - Object type to be dumped
- * display_type - 0 or ACPI_DISPLAY_SUMMARY
- * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
- * for an effectively unlimited depth.
- * owner_id - Dump only objects owned by this ID. Use
- * ACPI_UINT32_MAX to match all owners.
- * start_handle - Where in namespace to start/end search
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump typed objects within the loaded namespace.
- * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
- *
- ******************************************************************************/
-
-void
-acpi_ns_dump_objects(acpi_object_type type,
- u8 display_type,
- u32 max_depth,
- acpi_owner_id owner_id, acpi_handle start_handle)
-{
- struct acpi_walk_info info;
-
- ACPI_FUNCTION_ENTRY();
-
- info.debug_level = ACPI_LV_TABLES;
- info.owner_id = owner_id;
- info.display_type = display_type;
-
- (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
- ACPI_NS_WALK_NO_UNLOCK |
- ACPI_NS_WALK_TEMP_NODES,
- acpi_ns_dump_one_object, (void *)&info,
- NULL);
-}
-#endif /* ACPI_FUTURE_USAGE */
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_entry
- *
- * PARAMETERS: Handle - Node to be dumped
- * debug_level - Output level
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump a single Node
- *
- ******************************************************************************/
-
-void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
-{
- struct acpi_walk_info info;
-
- ACPI_FUNCTION_ENTRY();
-
- info.debug_level = debug_level;
- info.owner_id = ACPI_OWNER_ID_MAX;
- info.display_type = ACPI_DISPLAY_SUMMARY;
-
- (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
-}
-
-#ifdef ACPI_ASL_COMPILER
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_tables
- *
- * PARAMETERS: search_base - Root of subtree to be dumped, or
- * NS_ALL to dump the entire namespace
- * max_depth - Maximum depth of dump. Use INT_MAX
- * for an effectively unlimited depth.
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump the name space, or a portion of it.
- *
- ******************************************************************************/
-
-void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
-{
- acpi_handle search_handle = search_base;
-
- ACPI_FUNCTION_TRACE(ns_dump_tables);
-
- if (!acpi_gbl_root_node) {
- /*
- * If the name space has not been initialized,
- * there is nothing to dump.
- */
- ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
- "namespace not initialized!\n"));
- return_VOID;
- }
-
- if (ACPI_NS_ALL == search_base) {
-
- /* Entire namespace */
-
- search_handle = acpi_gbl_root_node;
- ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
- }
-
- acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
- ACPI_OWNER_ID_MAX, search_handle);
- return_VOID;
-}
-#endif /* _ACPI_ASL_COMPILER */
-#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
deleted file mode 100644
index cc3df78258e..00000000000
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsdump - table dumping routines for debug
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-
-/* TBD: This entire module is apparently obsolete and should be removed */
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsdumpdv")
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-#include <acpi/acnamesp.h>
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_one_device
- *
- * PARAMETERS: Handle - Node to be dumped
- * Level - Nesting level of the handle
- * Context - Passed into walk_namespace
- * return_value - Not used
- *
- * RETURN: Status
- *
- * DESCRIPTION: Dump a single Node that represents a device
- * This procedure is a user_function called by acpi_ns_walk_namespace.
- *
- ******************************************************************************/
-static acpi_status
-acpi_ns_dump_one_device(acpi_handle obj_handle,
- u32 level, void *context, void **return_value)
-{
- struct acpi_buffer buffer;
- struct acpi_device_info *info;
- acpi_status status;
- u32 i;
-
- ACPI_FUNCTION_NAME(ns_dump_one_device);
-
- status =
- acpi_ns_dump_one_object(obj_handle, level, context, return_value);
-
- buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
- status = acpi_get_object_info(obj_handle, &buffer);
- if (ACPI_SUCCESS(status)) {
- info = buffer.pointer;
- for (i = 0; i < level; i++) {
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, " "));
- }
-
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES,
- " HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
- info->hardware_id.value,
- ACPI_FORMAT_UINT64(info->address),
- info->current_status));
- ACPI_FREE(info);
- }
-
- return (status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_root_devices
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump all objects of type "device"
- *
- ******************************************************************************/
-
-void acpi_ns_dump_root_devices(void)
-{
- acpi_handle sys_bus_handle;
- acpi_status status;
-
- ACPI_FUNCTION_NAME(ns_dump_root_devices);
-
- /* Only dump the table if tracing is enabled */
-
- if (!(ACPI_LV_TABLES & acpi_dbg_level)) {
- return;
- }
-
- status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle);
- if (ACPI_FAILURE(status)) {
- return;
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
- "Display of all devices in the namespace:\n"));
-
- status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, sys_bus_handle,
- ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
- acpi_ns_dump_one_device, NULL, NULL);
-}
-
-#endif
-#endif
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
deleted file mode 100644
index a8d7764c73b..00000000000
--- a/drivers/acpi/namespace/nseval.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nseval - Object evaluation, includes control method execution
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acparser.h>
-#include <acpi/acinterp.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nseval")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_evaluate
- *
- * PARAMETERS: Info - Evaluation info block, contains:
- * prefix_node - Prefix or Method/Object Node to execute
- * Pathname - Name of method to execute, If NULL, the
- * Node is the object to execute
- * Parameters - List of parameters to pass to the method,
- * terminated by NULL. Params itself may be
- * NULL if no parameters are being passed.
- * return_object - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * parameter_type - Type of Parameter list
- * return_object - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * Flags - ACPI_IGNORE_RETURN_VALUE to delete return
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute a control method or return the current value of an
- * ACPI namespace object.
- *
- * MUTEX: Locks interpreter
- *
- ******************************************************************************/
-acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
-{
- acpi_status status;
- struct acpi_namespace_node *node;
-
- ACPI_FUNCTION_TRACE(ns_evaluate);
-
- if (!info) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /* Initialize the return value to an invalid object */
-
- info->return_object = NULL;
- info->param_count = 0;
-
- /*
- * Get the actual namespace node for the target object. Handles these cases:
- *
- * 1) Null node, Pathname (absolute path)
- * 2) Node, Pathname (path relative to Node)
- * 3) Node, Null Pathname
- */
- status = acpi_ns_get_node(info->prefix_node, info->pathname,
- ACPI_NS_NO_UPSEARCH, &info->resolved_node);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /*
- * For a method alias, we must grab the actual method node so that proper
- * scoping context will be established before execution.
- */
- if (acpi_ns_get_type(info->resolved_node) ==
- ACPI_TYPE_LOCAL_METHOD_ALIAS) {
- info->resolved_node =
- ACPI_CAST_PTR(struct acpi_namespace_node,
- info->resolved_node->object);
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", info->pathname,
- info->resolved_node,
- acpi_ns_get_attached_object(info->resolved_node)));
-
- node = info->resolved_node;
-
- /*
- * Two major cases here:
- *
- * 1) The object is a control method -- execute it
- * 2) The object is not a method -- just return it's current value
- */
- if (acpi_ns_get_type(info->resolved_node) == ACPI_TYPE_METHOD) {
- /*
- * 1) Object is a control method - execute it
- */
-
- /* Verify that there is a method object associated with this node */
-
- info->obj_desc =
- acpi_ns_get_attached_object(info->resolved_node);
- if (!info->obj_desc) {
- ACPI_ERROR((AE_INFO,
- "Control method has no attached sub-object"));
- return_ACPI_STATUS(AE_NULL_OBJECT);
- }
-
- /* Count the number of arguments being passed to the method */
-
- if (info->parameters) {
- while (info->parameters[info->param_count]) {
- if (info->param_count > ACPI_METHOD_MAX_ARG) {
- return_ACPI_STATUS(AE_LIMIT);
- }
- info->param_count++;
- }
- }
-
-
- ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:",
- ACPI_LV_INFO, _COMPONENT);
-
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
- "Method at AML address %p Length %X\n",
- info->obj_desc->method.aml_start + 1,
- info->obj_desc->method.aml_length - 1));
-
- /*
- * Any namespace deletion must acquire both the namespace and
- * interpreter locks to ensure that no thread is using the portion of
- * the namespace that is being deleted.
- *
- * Execute the method via the interpreter. The interpreter is locked
- * here before calling into the AML parser
- */
- acpi_ex_enter_interpreter();
- status = acpi_ps_execute_method(info);
- acpi_ex_exit_interpreter();
- } else {
- /*
- * 2) Object is not a method, return its current value
- *
- * Disallow certain object types. For these, "evaluation" is undefined.
- */
- switch (info->resolved_node->type) {
- case ACPI_TYPE_DEVICE:
- case ACPI_TYPE_EVENT:
- case ACPI_TYPE_MUTEX:
- case ACPI_TYPE_REGION:
- case ACPI_TYPE_THERMAL:
- case ACPI_TYPE_LOCAL_SCOPE:
-
- ACPI_ERROR((AE_INFO,
- "[%4.4s] Evaluation of object type [%s] is not supported",
- info->resolved_node->name.ascii,
- acpi_ut_get_type_name(info->resolved_node->
- type)));
-
- return_ACPI_STATUS(AE_TYPE);
-
- default:
- break;
- }
-
- /*
- * Objects require additional resolution steps (e.g., the Node may be
- * a field that must be read, etc.) -- we can't just grab the object
- * out of the node.
- *
- * Use resolve_node_to_value() to get the associated value.
- *
- * NOTE: we can get away with passing in NULL for a walk state because
- * resolved_node is guaranteed to not be a reference to either a method
- * local or a method argument (because this interface is never called
- * from a running method.)
- *
- * Even though we do not directly invoke the interpreter for object
- * resolution, we must lock it because we could access an opregion.
- * The opregion access code assumes that the interpreter is locked.
- */
- acpi_ex_enter_interpreter();
-
- /* Function has a strange interface */
-
- status =
- acpi_ex_resolve_node_to_value(&info->resolved_node, NULL);
- acpi_ex_exit_interpreter();
-
- /*
- * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed
- * in resolved_node.
- */
- if (ACPI_SUCCESS(status)) {
- status = AE_CTRL_RETURN_VALUE;
- info->return_object =
- ACPI_CAST_PTR(union acpi_operand_object,
- info->resolved_node);
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Returning object %p [%s]\n",
- info->return_object,
- acpi_ut_get_object_type_name(info->
- return_object)));
- }
- }
-
- /*
- * Check input argument count against the ASL-defined count for a method.
- * Also check predefined names: argument count and return value against
- * the ACPI specification. Some incorrect return value types are repaired.
- */
- (void)acpi_ns_check_predefined_names(node, info->param_count,
- status, &info->return_object);
-
- /* Check if there is a return value that must be dealt with */
-
- if (status == AE_CTRL_RETURN_VALUE) {
-
- /* If caller does not want the return value, delete it */
-
- if (info->flags & ACPI_IGNORE_RETURN_VALUE) {
- acpi_ut_remove_reference(info->return_object);
- info->return_object = NULL;
- }
-
- /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
-
- status = AE_OK;
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "*** Completed evaluation of object %s ***\n",
- info->pathname));
-
- /*
- * Namespace was unlocked by the handling acpi_ns* function, so we
- * just return
- */
- return_ACPI_STATUS(status);
-}
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
deleted file mode 100644
index fe470c4b38f..00000000000
--- a/drivers/acpi/namespace/nsinit.c
+++ /dev/null
@@ -1,593 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsinit - namespace initialization
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-#include <acpi/acdispat.h>
-#include <acpi/acinterp.h>
-#include <linux/nmi.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsinit")
-
-/* Local prototypes */
-static acpi_status
-acpi_ns_init_one_object(acpi_handle obj_handle,
- u32 level, void *context, void **return_value);
-
-static acpi_status
-acpi_ns_init_one_device(acpi_handle obj_handle,
- u32 nesting_level, void *context, void **return_value);
-
-static acpi_status
-acpi_ns_find_ini_methods(acpi_handle obj_handle,
- u32 nesting_level, void *context, void **return_value);
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_initialize_objects
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Walk the entire namespace and perform any necessary
- * initialization on the objects found therein
- *
- ******************************************************************************/
-
-acpi_status acpi_ns_initialize_objects(void)
-{
- acpi_status status;
- struct acpi_init_walk_info info;
-
- ACPI_FUNCTION_TRACE(ns_initialize_objects);
-
- ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
- "**** Starting initialization of namespace objects ****\n"));
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
- "Completing Region/Field/Buffer/Package initialization:"));
-
- /* Set all init info to zero */
-
- ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info));
-
- /* Walk entire namespace from the supplied root */
-
- status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, acpi_ns_init_one_object,
- &info, NULL);
- if (ACPI_FAILURE(status)) {
- ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
- }
-
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
- "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n",
- info.op_region_init, info.op_region_count,
- info.field_init, info.field_count,
- info.buffer_init, info.buffer_count,
- info.package_init, info.package_count,
- info.object_count));
-
- ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
- "%hd Control Methods found\n", info.method_count));
- ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
- "%hd Op Regions found\n", info.op_region_count));
-
- return_ACPI_STATUS(AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_initialize_devices
- *
- * PARAMETERS: None
- *
- * RETURN: acpi_status
- *
- * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
- * This means running _INI on all present devices.
- *
- * Note: We install PCI config space handler on region access,
- * not here.
- *
- ******************************************************************************/
-
-acpi_status acpi_ns_initialize_devices(void)
-{
- acpi_status status;
- struct acpi_device_walk_info info;
-
- ACPI_FUNCTION_TRACE(ns_initialize_devices);
-
- /* Init counters */
-
- info.device_count = 0;
- info.num_STA = 0;
- info.num_INI = 0;
-
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
- "Initializing Device/Processor/Thermal objects by executing _INI methods:"));
-
- /* Tree analysis: find all subtrees that contain _INI methods */
-
- status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, FALSE,
- acpi_ns_find_ini_methods, &info, NULL);
- if (ACPI_FAILURE(status)) {
- goto error_exit;
- }
-
- /* Allocate the evaluation information block */
-
- info.evaluate_info =
- ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
- if (!info.evaluate_info) {
- status = AE_NO_MEMORY;
- goto error_exit;
- }
-
- /* Walk namespace to execute all _INIs on present devices */
-
- status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, FALSE,
- acpi_ns_init_one_device, &info, NULL);
-
- ACPI_FREE(info.evaluate_info);
- if (ACPI_FAILURE(status)) {
- goto error_exit;
- }
-
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
- "\nExecuted %hd _INI methods requiring %hd _STA executions (examined %hd objects)\n",
- info.num_INI, info.num_STA, info.device_count));
-
- return_ACPI_STATUS(status);
-
- error_exit:
- ACPI_EXCEPTION((AE_INFO, status, "During device initialization"));
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_init_one_object
- *
- * PARAMETERS: obj_handle - Node
- * Level - Current nesting level
- * Context - Points to a init info struct
- * return_value - Not used
- *
- * RETURN: Status
- *
- * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
- * within the namespace.
- *
- * Currently, the only objects that require initialization are:
- * 1) Methods
- * 2) Op Regions
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_init_one_object(acpi_handle obj_handle,
- u32 level, void *context, void **return_value)
-{
- acpi_object_type type;
- acpi_status status = AE_OK;
- struct acpi_init_walk_info *info =
- (struct acpi_init_walk_info *)context;
- struct acpi_namespace_node *node =
- (struct acpi_namespace_node *)obj_handle;
- union acpi_operand_object *obj_desc;
-
- ACPI_FUNCTION_NAME(ns_init_one_object);
-
- info->object_count++;
-
- /* And even then, we are only interested in a few object types */
-
- type = acpi_ns_get_type(obj_handle);
- obj_desc = acpi_ns_get_attached_object(node);
- if (!obj_desc) {
- return (AE_OK);
- }
-
- /* Increment counters for object types we are looking for */
-
- switch (type) {
- case ACPI_TYPE_REGION:
- info->op_region_count++;
- break;
-
- case ACPI_TYPE_BUFFER_FIELD:
- info->field_count++;
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- info->field_count++;
- break;
-
- case ACPI_TYPE_BUFFER:
- info->buffer_count++;
- break;
-
- case ACPI_TYPE_PACKAGE:
- info->package_count++;
- break;
-
- default:
-
- /* No init required, just exit now */
- return (AE_OK);
- }
-
- /*
- * If the object is already initialized, nothing else to do
- */
- if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
- return (AE_OK);
- }
-
- /*
- * Must lock the interpreter before executing AML code
- */
- acpi_ex_enter_interpreter();
-
- /*
- * Each of these types can contain executable AML code within the
- * declaration.
- */
- switch (type) {
- case ACPI_TYPE_REGION:
-
- info->op_region_init++;
- status = acpi_ds_get_region_arguments(obj_desc);
- break;
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- info->field_init++;
- status = acpi_ds_get_buffer_field_arguments(obj_desc);
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- info->field_init++;
- status = acpi_ds_get_bank_field_arguments(obj_desc);
- break;
-
- case ACPI_TYPE_BUFFER:
-
- info->buffer_init++;
- status = acpi_ds_get_buffer_arguments(obj_desc);
- break;
-
- case ACPI_TYPE_PACKAGE:
-
- info->package_init++;
- status = acpi_ds_get_package_arguments(obj_desc);
- break;
-
- default:
- /* No other types can get here */
- break;
- }
-
- if (ACPI_FAILURE(status)) {
- ACPI_EXCEPTION((AE_INFO, status,
- "Could not execute arguments for [%4.4s] (%s)",
- acpi_ut_get_node_name(node),
- acpi_ut_get_type_name(type)));
- }
-
- /*
- * Print a dot for each object unless we are going to print the entire
- * pathname
- */
- if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
- }
-
- /*
- * We ignore errors from above, and always return OK, since we don't want
- * to abort the walk on any single error.
- */
- acpi_ex_exit_interpreter();
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_find_ini_methods
- *
- * PARAMETERS: acpi_walk_callback
- *
- * RETURN: acpi_status
- *
- * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
- * device/processor/thermal objects, and marks the entire subtree
- * with a SUBTREE_HAS_INI flag. This flag is used during the
- * subsequent device initialization walk to avoid entire subtrees
- * that do not contain an _INI.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_find_ini_methods(acpi_handle obj_handle,
- u32 nesting_level, void *context, void **return_value)
-{
- struct acpi_device_walk_info *info =
- ACPI_CAST_PTR(struct acpi_device_walk_info, context);
- struct acpi_namespace_node *node;
- struct acpi_namespace_node *parent_node;
-
- /* Keep count of device/processor/thermal objects */
-
- node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
- if ((node->type == ACPI_TYPE_DEVICE) ||
- (node->type == ACPI_TYPE_PROCESSOR) ||
- (node->type == ACPI_TYPE_THERMAL)) {
- info->device_count++;
- return (AE_OK);
- }
-
- /* We are only looking for methods named _INI */
-
- if (!ACPI_COMPARE_NAME(node->name.ascii, METHOD_NAME__INI)) {
- return (AE_OK);
- }
-
- /*
- * The only _INI methods that we care about are those that are
- * present under Device, Processor, and Thermal objects.
- */
- parent_node = acpi_ns_get_parent_node(node);
- switch (parent_node->type) {
- case ACPI_TYPE_DEVICE:
- case ACPI_TYPE_PROCESSOR:
- case ACPI_TYPE_THERMAL:
-
- /* Mark parent and bubble up the INI present flag to the root */
-
- while (parent_node) {
- parent_node->flags |= ANOBJ_SUBTREE_HAS_INI;
- parent_node = acpi_ns_get_parent_node(parent_node);
- }
- break;
-
- default:
- break;
- }
-
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_init_one_device
- *
- * PARAMETERS: acpi_walk_callback
- *
- * RETURN: acpi_status
- *
- * DESCRIPTION: This is called once per device soon after ACPI is enabled
- * to initialize each device. It determines if the device is
- * present, and if so, calls _INI.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_init_one_device(acpi_handle obj_handle,
- u32 nesting_level, void *context, void **return_value)
-{
- struct acpi_device_walk_info *walk_info =
- ACPI_CAST_PTR(struct acpi_device_walk_info, context);
- struct acpi_evaluate_info *info = walk_info->evaluate_info;
- u32 flags;
- acpi_status status;
- struct acpi_namespace_node *device_node;
-
- ACPI_FUNCTION_TRACE(ns_init_one_device);
-
- /* We are interested in Devices, Processors and thermal_zones only */
-
- device_node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
- if ((device_node->type != ACPI_TYPE_DEVICE) &&
- (device_node->type != ACPI_TYPE_PROCESSOR) &&
- (device_node->type != ACPI_TYPE_THERMAL)) {
- return_ACPI_STATUS(AE_OK);
- }
-
- /*
- * Because of an earlier namespace analysis, all subtrees that contain an
- * _INI method are tagged.
- *
- * If this device subtree does not contain any _INI methods, we
- * can exit now and stop traversing this entire subtree.
- */
- if (!(device_node->flags & ANOBJ_SUBTREE_HAS_INI)) {
- return_ACPI_STATUS(AE_CTRL_DEPTH);
- }
-
- /*
- * Run _STA to determine if this device is present and functioning. We
- * must know this information for two important reasons (from ACPI spec):
- *
- * 1) We can only run _INI if the device is present.
- * 2) We must abort the device tree walk on this subtree if the device is
- * not present and is not functional (we will not examine the children)
- *
- * The _STA method is not required to be present under the device, we
- * assume the device is present if _STA does not exist.
- */
- ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
- (ACPI_TYPE_METHOD, device_node, METHOD_NAME__STA));
-
- status = acpi_ut_execute_STA(device_node, &flags);
- if (ACPI_FAILURE(status)) {
-
- /* Ignore error and move on to next device */
-
- return_ACPI_STATUS(AE_OK);
- }
-
- /*
- * Flags == -1 means that _STA was not found. In this case, we assume that
- * the device is both present and functional.
- *
- * From the ACPI spec, description of _STA:
- *
- * "If a device object (including the processor object) does not have an
- * _STA object, then OSPM assumes that all of the above bits are set (in
- * other words, the device is present, ..., and functioning)"
- */
- if (flags != ACPI_UINT32_MAX) {
- walk_info->num_STA++;
- }
-
- /*
- * Examine the PRESENT and FUNCTIONING status bits
- *
- * Note: ACPI spec does not seem to specify behavior for the present but
- * not functioning case, so we assume functioning if present.
- */
- if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
-
- /* Device is not present, we must examine the Functioning bit */
-
- if (flags & ACPI_STA_DEVICE_FUNCTIONING) {
- /*
- * Device is not present but is "functioning". In this case,
- * we will not run _INI, but we continue to examine the children
- * of this device.
- *
- * From the ACPI spec, description of _STA: (Note - no mention
- * of whether to run _INI or not on the device in question)
- *
- * "_STA may return bit 0 clear (not present) with bit 3 set
- * (device is functional). This case is used to indicate a valid
- * device for which no device driver should be loaded (for example,
- * a bridge device.) Children of this device may be present and
- * valid. OSPM should continue enumeration below a device whose
- * _STA returns this bit combination"
- */
- return_ACPI_STATUS(AE_OK);
- } else {
- /*
- * Device is not present and is not functioning. We must abort the
- * walk of this subtree immediately -- don't look at the children
- * of such a device.
- *
- * From the ACPI spec, description of _INI:
- *
- * "If the _STA method indicates that the device is not present,
- * OSPM will not run the _INI and will not examine the children
- * of the device for _INI methods"
- */
- return_ACPI_STATUS(AE_CTRL_DEPTH);
- }
- }
-
- /*
- * The device is present or is assumed present if no _STA exists.
- * Run the _INI if it exists (not required to exist)
- *
- * Note: We know there is an _INI within this subtree, but it may not be
- * under this particular device, it may be lower in the branch.
- */
- ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
- (ACPI_TYPE_METHOD, device_node, METHOD_NAME__INI));
-
- info->prefix_node = device_node;
- info->pathname = METHOD_NAME__INI;
- info->parameters = NULL;
- info->flags = ACPI_IGNORE_RETURN_VALUE;
-
- /*
- * Some hardware relies on this being executed as atomically
- * as possible (without an NMI being received in the middle of
- * this) - so disable NMIs and initialize the device:
- */
- acpi_nmi_disable();
- status = acpi_ns_evaluate(info);
- acpi_nmi_enable();
-
- if (ACPI_SUCCESS(status)) {
- walk_info->num_INI++;
-
- if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
- (!(acpi_dbg_level & ACPI_LV_INFO))) {
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
- }
- }
-#ifdef ACPI_DEBUG_OUTPUT
- else if (status != AE_NOT_FOUND) {
-
- /* Ignore error and move on to next device */
-
- char *scope_name =
- acpi_ns_get_external_pathname(info->resolved_node);
-
- ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution",
- scope_name));
- ACPI_FREE(scope_name);
- }
-#endif
-
- /* Ignore errors from above */
-
- status = AE_OK;
-
- /*
- * The _INI method has been run if present; call the Global Initialization
- * Handler for this device.
- */
- if (acpi_gbl_init_handler) {
- status =
- acpi_gbl_init_handler(device_node, ACPI_INIT_DEVICE_INI);
- }
-
- return_ACPI_STATUS(status);
-}
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
deleted file mode 100644
index a6e92b31a06..00000000000
--- a/drivers/acpi/namespace/nsload.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsload - namespace loading/expanding/contracting procedures
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-#include <acpi/acdispat.h>
-#include <acpi/actables.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsload")
-
-/* Local prototypes */
-#ifdef ACPI_FUTURE_IMPLEMENTATION
-acpi_status acpi_ns_unload_namespace(acpi_handle handle);
-
-static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle);
-#endif
-
-#ifndef ACPI_NO_METHOD_EXECUTION
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_load_table
- *
- * PARAMETERS: table_index - Index for table to be loaded
- * Node - Owning NS node
- *
- * RETURN: Status
- *
- * DESCRIPTION: Load one ACPI table into the namespace
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node)
-{
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(ns_load_table);
-
- /*
- * Parse the table and load the namespace with all named
- * objects found within. Control methods are NOT parsed
- * at this time. In fact, the control methods cannot be
- * parsed until the entire namespace is loaded, because
- * if a control method makes a forward reference (call)
- * to another control method, we can't continue parsing
- * because we don't know how many arguments to parse next!
- */
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /* If table already loaded into namespace, just return */
-
- if (acpi_tb_is_table_loaded(table_index)) {
- status = AE_ALREADY_EXISTS;
- goto unlock;
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "**** Loading table into namespace ****\n"));
-
- status = acpi_tb_allocate_owner_id(table_index);
- if (ACPI_FAILURE(status)) {
- goto unlock;
- }
-
- status = acpi_ns_parse_table(table_index, node);
- if (ACPI_SUCCESS(status)) {
- acpi_tb_set_table_loaded_flag(table_index, TRUE);
- } else {
- (void)acpi_tb_release_owner_id(table_index);
- }
-
- unlock:
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
-
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /*
- * Now we can parse the control methods. We always parse
- * them here for a sanity check, and if configured for
- * just-in-time parsing, we delete the control method
- * parse trees.
- */
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "**** Begin Table Method Parsing and Object Initialization ****\n"));
-
- status = acpi_ds_initialize_objects(table_index, node);
-
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "**** Completed Table Method Parsing and Object Initialization ****\n"));
-
- return_ACPI_STATUS(status);
-}
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-/*******************************************************************************
- *
- * FUNCTION: acpi_load_namespace
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
- * (DSDT points to either the BIOS or a buffer.)
- *
- ******************************************************************************/
-
-acpi_status acpi_ns_load_namespace(void)
-{
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(acpi_load_name_space);
-
- /* There must be at least a DSDT installed */
-
- if (acpi_gbl_DSDT == NULL) {
- ACPI_ERROR((AE_INFO, "DSDT is not in memory"));
- return_ACPI_STATUS(AE_NO_ACPI_TABLES);
- }
-
- /*
- * Load the namespace. The DSDT is required,
- * but the SSDT and PSDT tables are optional.
- */
- status = acpi_ns_load_table_by_type(ACPI_TABLE_ID_DSDT);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /* Ignore exceptions from these */
-
- (void)acpi_ns_load_table_by_type(ACPI_TABLE_ID_SSDT);
- (void)acpi_ns_load_table_by_type(ACPI_TABLE_ID_PSDT);
-
- ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
- "ACPI Namespace successfully loaded at root %p\n",
- acpi_gbl_root_node));
-
- return_ACPI_STATUS(status);
-}
-#endif
-
-#ifdef ACPI_FUTURE_IMPLEMENTATION
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_delete_subtree
- *
- * PARAMETERS: start_handle - Handle in namespace where search begins
- *
- * RETURNS Status
- *
- * DESCRIPTION: Walks the namespace starting at the given handle and deletes
- * all objects, entries, and scopes in the entire subtree.
- *
- * Namespace/Interpreter should be locked or the subsystem should
- * be in shutdown before this routine is called.
- *
- ******************************************************************************/
-
-static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle)
-{
- acpi_status status;
- acpi_handle child_handle;
- acpi_handle parent_handle;
- acpi_handle next_child_handle;
- acpi_handle dummy;
- u32 level;
-
- ACPI_FUNCTION_TRACE(ns_delete_subtree);
-
- parent_handle = start_handle;
- child_handle = NULL;
- level = 1;
-
- /*
- * Traverse the tree of objects until we bubble back up
- * to where we started.
- */
- while (level > 0) {
-
- /* Attempt to get the next object in this scope */
-
- status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle,
- child_handle, &next_child_handle);
-
- child_handle = next_child_handle;
-
- /* Did we get a new object? */
-
- if (ACPI_SUCCESS(status)) {
-
- /* Check if this object has any children */
-
- if (ACPI_SUCCESS
- (acpi_get_next_object
- (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) {
- /*
- * There is at least one child of this object,
- * visit the object
- */
- level++;
- parent_handle = child_handle;
- child_handle = NULL;
- }
- } else {
- /*
- * No more children in this object, go back up to
- * the object's parent
- */
- level--;
-
- /* Delete all children now */
-
- acpi_ns_delete_children(child_handle);
-
- child_handle = parent_handle;
- status = acpi_get_parent(parent_handle, &parent_handle);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
- }
- }
-
- /* Now delete the starting object, and we are done */
-
- acpi_ns_delete_node(child_handle);
-
- return_ACPI_STATUS(AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_unload_name_space
- *
- * PARAMETERS: Handle - Root of namespace subtree to be deleted
- *
- * RETURN: Status
- *
- * DESCRIPTION: Shrinks the namespace, typically in response to an undocking
- * event. Deletes an entire subtree starting from (and
- * including) the given handle.
- *
- ******************************************************************************/
-
-acpi_status acpi_ns_unload_namespace(acpi_handle handle)
-{
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(ns_unload_name_space);
-
- /* Parameter validation */
-
- if (!acpi_gbl_root_node) {
- return_ACPI_STATUS(AE_NO_NAMESPACE);
- }
-
- if (!handle) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /* This function does the real work */
-
- status = acpi_ns_delete_subtree(handle);
-
- return_ACPI_STATUS(status);
-}
-#endif
-#endif
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
deleted file mode 100644
index b7e301848ba..00000000000
--- a/drivers/acpi/namespace/nsnames.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsnames - Name manipulation and search
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/amlcode.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsnames")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_build_external_path
- *
- * PARAMETERS: Node - NS node whose pathname is needed
- * Size - Size of the pathname
- * *name_buffer - Where to return the pathname
- *
- * RETURN: Status
- * Places the pathname into the name_buffer, in external format
- * (name segments separated by path separators)
- *
- * DESCRIPTION: Generate a full pathaname
- *
- ******************************************************************************/
-acpi_status
-acpi_ns_build_external_path(struct acpi_namespace_node *node,
- acpi_size size, char *name_buffer)
-{
- acpi_size index;
- struct acpi_namespace_node *parent_node;
-
- ACPI_FUNCTION_ENTRY();
-
- /* Special case for root */
-
- index = size - 1;
- if (index < ACPI_NAME_SIZE) {
- name_buffer[0] = AML_ROOT_PREFIX;
- name_buffer[1] = 0;
- return (AE_OK);
- }
-
- /* Store terminator byte, then build name backwards */
-
- parent_node = node;
- name_buffer[index] = 0;
-
- while ((index > ACPI_NAME_SIZE) && (parent_node != acpi_gbl_root_node)) {
- index -= ACPI_NAME_SIZE;
-
- /* Put the name into the buffer */
-
- ACPI_MOVE_32_TO_32((name_buffer + index), &parent_node->name);
- parent_node = acpi_ns_get_parent_node(parent_node);
-
- /* Prefix name with the path separator */
-
- index--;
- name_buffer[index] = ACPI_PATH_SEPARATOR;
- }
-
- /* Overwrite final separator with the root prefix character */
-
- name_buffer[index] = AML_ROOT_PREFIX;
-
- if (index != 0) {
- ACPI_ERROR((AE_INFO,
- "Could not construct external pathname; index=%X, size=%X, Path=%s",
- (u32) index, (u32) size, &name_buffer[size]));
-
- return (AE_BAD_PARAMETER);
- }
-
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_external_pathname
- *
- * PARAMETERS: Node - Namespace node whose pathname is needed
- *
- * RETURN: Pointer to storage containing the fully qualified name of
- * the node, In external format (name segments separated by path
- * separators.)
- *
- * DESCRIPTION: Used for debug printing in acpi_ns_search_table().
- *
- ******************************************************************************/
-
-char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
-{
- acpi_status status;
- char *name_buffer;
- acpi_size size;
-
- ACPI_FUNCTION_TRACE_PTR(ns_get_external_pathname, node);
-
- /* Calculate required buffer size based on depth below root */
-
- size = acpi_ns_get_pathname_length(node);
- if (!size) {
- return_PTR(NULL);
- }
-
- /* Allocate a buffer to be returned to caller */
-
- name_buffer = ACPI_ALLOCATE_ZEROED(size);
- if (!name_buffer) {
- ACPI_ERROR((AE_INFO, "Allocation failure"));
- return_PTR(NULL);
- }
-
- /* Build the path in the allocated buffer */
-
- status = acpi_ns_build_external_path(node, size, name_buffer);
- if (ACPI_FAILURE(status)) {
- ACPI_FREE(name_buffer);
- return_PTR(NULL);
- }
-
- return_PTR(name_buffer);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_pathname_length
- *
- * PARAMETERS: Node - Namespace node
- *
- * RETURN: Length of path, including prefix
- *
- * DESCRIPTION: Get the length of the pathname string for this node
- *
- ******************************************************************************/
-
-acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
-{
- acpi_size size;
- struct acpi_namespace_node *next_node;
-
- ACPI_FUNCTION_ENTRY();
-
- /*
- * Compute length of pathname as 5 * number of name segments.
- * Go back up the parent tree to the root
- */
- size = 0;
- next_node = node;
-
- while (next_node && (next_node != acpi_gbl_root_node)) {
- if (ACPI_GET_DESCRIPTOR_TYPE(next_node) != ACPI_DESC_TYPE_NAMED) {
- ACPI_ERROR((AE_INFO,
- "Invalid Namespace Node (%p) while traversing namespace",
- next_node));
- return 0;
- }
- size += ACPI_PATH_SEGMENT_LENGTH;
- next_node = acpi_ns_get_parent_node(next_node);
- }
-
- if (!size) {
- size = 1; /* Root node case */
- }
-
- return (size + 1); /* +1 for null string terminator */
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_handle_to_pathname
- *
- * PARAMETERS: target_handle - Handle of named object whose name is
- * to be found
- * Buffer - Where the pathname is returned
- *
- * RETURN: Status, Buffer is filled with pathname if status is AE_OK
- *
- * DESCRIPTION: Build and return a full namespace pathname
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_handle_to_pathname(acpi_handle target_handle,
- struct acpi_buffer * buffer)
-{
- acpi_status status;
- struct acpi_namespace_node *node;
- acpi_size required_size;
-
- ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle);
-
- node = acpi_ns_map_handle_to_node(target_handle);
- if (!node) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /* Determine size required for the caller buffer */
-
- required_size = acpi_ns_get_pathname_length(node);
- if (!required_size) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- status = acpi_ut_initialize_buffer(buffer, required_size);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /* Build the path in the caller buffer */
-
- status =
- acpi_ns_build_external_path(node, required_size, buffer->pointer);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n",
- (char *)buffer->pointer, (u32) required_size));
- return_ACPI_STATUS(AE_OK);
-}
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
deleted file mode 100644
index ca9edeea27d..00000000000
--- a/drivers/acpi/namespace/nsobject.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsobject - Utilities for objects attached to namespace
- * table entries
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsobject")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_attach_object
- *
- * PARAMETERS: Node - Parent Node
- * Object - Object to be attached
- * Type - Type of object, or ACPI_TYPE_ANY if not
- * known
- *
- * RETURN: Status
- *
- * DESCRIPTION: Record the given object as the value associated with the
- * name whose acpi_handle is passed. If Object is NULL
- * and Type is ACPI_TYPE_ANY, set the name as having no value.
- * Note: Future may require that the Node->Flags field be passed
- * as a parameter.
- *
- * MUTEX: Assumes namespace is locked
- *
- ******************************************************************************/
-acpi_status
-acpi_ns_attach_object(struct acpi_namespace_node *node,
- union acpi_operand_object *object, acpi_object_type type)
-{
- union acpi_operand_object *obj_desc;
- union acpi_operand_object *last_obj_desc;
- acpi_object_type object_type = ACPI_TYPE_ANY;
-
- ACPI_FUNCTION_TRACE(ns_attach_object);
-
- /*
- * Parameter validation
- */
- if (!node) {
-
- /* Invalid handle */
-
- ACPI_ERROR((AE_INFO, "Null NamedObj handle"));
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- if (!object && (ACPI_TYPE_ANY != type)) {
-
- /* Null object */
-
- ACPI_ERROR((AE_INFO,
- "Null object, but type not ACPI_TYPE_ANY"));
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
-
- /* Not a name handle */
-
- ACPI_ERROR((AE_INFO, "Invalid handle %p [%s]",
- node, acpi_ut_get_descriptor_name(node)));
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /* Check if this object is already attached */
-
- if (node->object == object) {
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
- "Obj %p already installed in NameObj %p\n",
- object, node));
-
- return_ACPI_STATUS(AE_OK);
- }
-
- /* If null object, we will just install it */
-
- if (!object) {
- obj_desc = NULL;
- object_type = ACPI_TYPE_ANY;
- }
-
- /*
- * If the source object is a namespace Node with an attached object,
- * we will use that (attached) object
- */
- else if ((ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) &&
- ((struct acpi_namespace_node *)object)->object) {
- /*
- * Value passed is a name handle and that name has a
- * non-null value. Use that name's value and type.
- */
- obj_desc = ((struct acpi_namespace_node *)object)->object;
- object_type = ((struct acpi_namespace_node *)object)->type;
- }
-
- /*
- * Otherwise, we will use the parameter object, but we must type
- * it first
- */
- else {
- obj_desc = (union acpi_operand_object *)object;
-
- /* Use the given type */
-
- object_type = type;
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
- obj_desc, node, acpi_ut_get_node_name(node)));
-
- /* Detach an existing attached object if present */
-
- if (node->object) {
- acpi_ns_detach_object(node);
- }
-
- if (obj_desc) {
- /*
- * Must increment the new value's reference count
- * (if it is an internal object)
- */
- acpi_ut_add_reference(obj_desc);
-
- /*
- * Handle objects with multiple descriptors - walk
- * to the end of the descriptor list
- */
- last_obj_desc = obj_desc;
- while (last_obj_desc->common.next_object) {
- last_obj_desc = last_obj_desc->common.next_object;
- }
-
- /* Install the object at the front of the object list */
-
- last_obj_desc->common.next_object = node->object;
- }
-
- node->type = (u8) object_type;
- node->object = obj_desc;
-
- return_ACPI_STATUS(AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_detach_object
- *
- * PARAMETERS: Node - A Namespace node whose object will be detached
- *
- * RETURN: None.
- *
- * DESCRIPTION: Detach/delete an object associated with a namespace node.
- * if the object is an allocated object, it is freed.
- * Otherwise, the field is simply cleared.
- *
- ******************************************************************************/
-
-void acpi_ns_detach_object(struct acpi_namespace_node *node)
-{
- union acpi_operand_object *obj_desc;
-
- ACPI_FUNCTION_TRACE(ns_detach_object);
-
- obj_desc = node->object;
-
- if (!obj_desc ||
- (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA)) {
- return_VOID;
- }
-
- /* Clear the entry in all cases */
-
- node->object = NULL;
- if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) {
- node->object = obj_desc->common.next_object;
- if (node->object &&
- (ACPI_GET_OBJECT_TYPE(node->object) !=
- ACPI_TYPE_LOCAL_DATA)) {
- node->object = node->object->common.next_object;
- }
- }
-
- /* Reset the node type to untyped */
-
- node->type = ACPI_TYPE_ANY;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
- node, acpi_ut_get_node_name(node), obj_desc));
-
- /* Remove one reference on the object (and all subobjects) */
-
- acpi_ut_remove_reference(obj_desc);
- return_VOID;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_attached_object
- *
- * PARAMETERS: Node - Namespace node
- *
- * RETURN: Current value of the object field from the Node whose
- * handle is passed
- *
- * DESCRIPTION: Obtain the object attached to a namespace node.
- *
- ******************************************************************************/
-
-union acpi_operand_object *acpi_ns_get_attached_object(struct
- acpi_namespace_node
- *node)
-{
- ACPI_FUNCTION_TRACE_PTR(ns_get_attached_object, node);
-
- if (!node) {
- ACPI_WARNING((AE_INFO, "Null Node ptr"));
- return_PTR(NULL);
- }
-
- if (!node->object ||
- ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND)
- && (ACPI_GET_DESCRIPTOR_TYPE(node->object) !=
- ACPI_DESC_TYPE_NAMED))
- || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) {
- return_PTR(NULL);
- }
-
- return_PTR(node->object);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_secondary_object
- *
- * PARAMETERS: Node - Namespace node
- *
- * RETURN: Current value of the object field from the Node whose
- * handle is passed.
- *
- * DESCRIPTION: Obtain a secondary object associated with a namespace node.
- *
- ******************************************************************************/
-
-union acpi_operand_object *acpi_ns_get_secondary_object(union
- acpi_operand_object
- *obj_desc)
-{
- ACPI_FUNCTION_TRACE_PTR(ns_get_secondary_object, obj_desc);
-
- if ((!obj_desc) ||
- (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) ||
- (!obj_desc->common.next_object) ||
- (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) ==
- ACPI_TYPE_LOCAL_DATA)) {
- return_PTR(NULL);
- }
-
- return_PTR(obj_desc->common.next_object);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_attach_data
- *
- * PARAMETERS: Node - Namespace node
- * Handler - Handler to be associated with the data
- * Data - Data to be attached
- *
- * RETURN: Status
- *
- * DESCRIPTION: Low-level attach data. Create and attach a Data object.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_attach_data(struct acpi_namespace_node *node,
- acpi_object_handler handler, void *data)
-{
- union acpi_operand_object *prev_obj_desc;
- union acpi_operand_object *obj_desc;
- union acpi_operand_object *data_desc;
-
- /* We only allow one attachment per handler */
-
- prev_obj_desc = NULL;
- obj_desc = node->object;
- while (obj_desc) {
- if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
- (obj_desc->data.handler == handler)) {
- return (AE_ALREADY_EXISTS);
- }
-
- prev_obj_desc = obj_desc;
- obj_desc = obj_desc->common.next_object;
- }
-
- /* Create an internal object for the data */
-
- data_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_DATA);
- if (!data_desc) {
- return (AE_NO_MEMORY);
- }
-
- data_desc->data.handler = handler;
- data_desc->data.pointer = data;
-
- /* Install the data object */
-
- if (prev_obj_desc) {
- prev_obj_desc->common.next_object = data_desc;
- } else {
- node->object = data_desc;
- }
-
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_detach_data
- *
- * PARAMETERS: Node - Namespace node
- * Handler - Handler associated with the data
- *
- * RETURN: Status
- *
- * DESCRIPTION: Low-level detach data. Delete the data node, but the caller
- * is responsible for the actual data.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_detach_data(struct acpi_namespace_node * node,
- acpi_object_handler handler)
-{
- union acpi_operand_object *obj_desc;
- union acpi_operand_object *prev_obj_desc;
-
- prev_obj_desc = NULL;
- obj_desc = node->object;
- while (obj_desc) {
- if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
- (obj_desc->data.handler == handler)) {
- if (prev_obj_desc) {
- prev_obj_desc->common.next_object =
- obj_desc->common.next_object;
- } else {
- node->object = obj_desc->common.next_object;
- }
-
- acpi_ut_remove_reference(obj_desc);
- return (AE_OK);
- }
-
- prev_obj_desc = obj_desc;
- obj_desc = obj_desc->common.next_object;
- }
-
- return (AE_NOT_FOUND);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_attached_data
- *
- * PARAMETERS: Node - Namespace node
- * Handler - Handler associated with the data
- * Data - Where the data is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Low level interface to obtain data previously associated with
- * a namespace node.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_get_attached_data(struct acpi_namespace_node * node,
- acpi_object_handler handler, void **data)
-{
- union acpi_operand_object *obj_desc;
-
- obj_desc = node->object;
- while (obj_desc) {
- if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
- (obj_desc->data.handler == handler)) {
- *data = obj_desc->data.pointer;
- return (AE_OK);
- }
-
- obj_desc = obj_desc->common.next_object;
- }
-
- return (AE_NOT_FOUND);
-}
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c
deleted file mode 100644
index bcfcf427c90..00000000000
--- a/drivers/acpi/namespace/nsparse.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsparse - namespace interface to AML parser
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-#include <acpi/acparser.h>
-#include <acpi/acdispat.h>
-#include <acpi/actables.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsparse")
-
-/*******************************************************************************
- *
- * FUNCTION: ns_one_complete_parse
- *
- * PARAMETERS: pass_number - 1 or 2
- * table_desc - The table to be parsed.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
- *
- ******************************************************************************/
-acpi_status
-acpi_ns_one_complete_parse(u32 pass_number,
- u32 table_index,
- struct acpi_namespace_node *start_node)
-{
- union acpi_parse_object *parse_root;
- acpi_status status;
- u32 aml_length;
- u8 *aml_start;
- struct acpi_walk_state *walk_state;
- struct acpi_table_header *table;
- acpi_owner_id owner_id;
-
- ACPI_FUNCTION_TRACE(ns_one_complete_parse);
-
- status = acpi_tb_get_owner_id(table_index, &owner_id);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /* Create and init a Root Node */
-
- parse_root = acpi_ps_create_scope_op();
- if (!parse_root) {
- return_ACPI_STATUS(AE_NO_MEMORY);
- }
-
- /* Create and initialize a new walk state */
-
- walk_state = acpi_ds_create_walk_state(owner_id, NULL, NULL, NULL);
- if (!walk_state) {
- acpi_ps_free_op(parse_root);
- return_ACPI_STATUS(AE_NO_MEMORY);
- }
-
- status = acpi_get_table_by_index(table_index, &table);
- if (ACPI_FAILURE(status)) {
- acpi_ds_delete_walk_state(walk_state);
- acpi_ps_free_op(parse_root);
- return_ACPI_STATUS(status);
- }
-
- /* Table must consist of at least a complete header */
-
- if (table->length < sizeof(struct acpi_table_header)) {
- status = AE_BAD_HEADER;
- } else {
- aml_start = (u8 *) table + sizeof(struct acpi_table_header);
- aml_length = table->length - sizeof(struct acpi_table_header);
- status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL,
- aml_start, aml_length, NULL,
- (u8) pass_number);
- }
-
- if (ACPI_FAILURE(status)) {
- acpi_ds_delete_walk_state(walk_state);
- goto cleanup;
- }
-
- /* start_node is the default location to load the table */
-
- if (start_node && start_node != acpi_gbl_root_node) {
- status =
- acpi_ds_scope_stack_push(start_node, ACPI_TYPE_METHOD,
- walk_state);
- if (ACPI_FAILURE(status)) {
- acpi_ds_delete_walk_state(walk_state);
- goto cleanup;
- }
- }
-
- /* Parse the AML */
-
- ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n",
- (unsigned)pass_number));
- status = acpi_ps_parse_aml(walk_state);
-
- cleanup:
- acpi_ps_delete_parse_tree(parse_root);
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_parse_table
- *
- * PARAMETERS: table_desc - An ACPI table descriptor for table to parse
- * start_node - Where to enter the table into the namespace
- *
- * RETURN: Status
- *
- * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node)
-{
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(ns_parse_table);
-
- /*
- * AML Parse, pass 1
- *
- * In this pass, we load most of the namespace. Control methods
- * are not parsed until later. A parse tree is not created. Instead,
- * each Parser Op subtree is deleted when it is finished. This saves
- * a great deal of memory, and allows a small cache of parse objects
- * to service the entire parse. The second pass of the parse then
- * performs another complete parse of the AML.
- */
- ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
- status =
- acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS1, table_index,
- start_node);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /*
- * AML Parse, pass 2
- *
- * In this pass, we resolve forward references and other things
- * that could not be completed during the first pass.
- * Another complete parse of the AML is performed, but the
- * overhead of this is compensated for by the fact that the
- * parse objects are all cached.
- */
- ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n"));
- status =
- acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS2, table_index,
- start_node);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- return_ACPI_STATUS(status);
-}
diff --git a/drivers/acpi/namespace/nspredef.c b/drivers/acpi/namespace/nspredef.c
deleted file mode 100644
index 1e682d03f62..00000000000
--- a/drivers/acpi/namespace/nspredef.c
+++ /dev/null
@@ -1,1065 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nspredef - Validation of ACPI predefined methods and objects
- * $Revision: 1.1 $
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-#include <acpi/acpredef.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nspredef")
-
-/*******************************************************************************
- *
- * This module validates predefined ACPI objects that appear in the namespace,
- * at the time they are evaluated (via acpi_evaluate_object). The purpose of this
- * validation is to detect problems with BIOS-exposed predefined ACPI objects
- * before the results are returned to the ACPI-related drivers.
- *
- * There are several areas that are validated:
- *
- * 1) The number of input arguments as defined by the method/object in the
- * ASL is validated against the ACPI specification.
- * 2) The type of the return object (if any) is validated against the ACPI
- * specification.
- * 3) For returned package objects, the count of package elements is
- * validated, as well as the type of each package element. Nested
- * packages are supported.
- *
- * For any problems found, a warning message is issued.
- *
- ******************************************************************************/
-/* Local prototypes */
-static acpi_status
-acpi_ns_check_package(char *pathname,
- union acpi_operand_object **return_object_ptr,
- const union acpi_predefined_info *predefined);
-
-static acpi_status
-acpi_ns_check_package_elements(char *pathname,
- union acpi_operand_object **elements,
- u8 type1, u32 count1, u8 type2, u32 count2);
-
-static acpi_status
-acpi_ns_check_object_type(char *pathname,
- union acpi_operand_object **return_object_ptr,
- u32 expected_btypes, u32 package_index);
-
-static acpi_status
-acpi_ns_check_reference(char *pathname,
- union acpi_operand_object *return_object);
-
-static acpi_status
-acpi_ns_repair_object(u32 expected_btypes,
- u32 package_index,
- union acpi_operand_object **return_object_ptr);
-
-/*
- * Names for the types that can be returned by the predefined objects.
- * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
- */
-static const char *acpi_rtype_names[] = {
- "/Integer",
- "/String",
- "/Buffer",
- "/Package",
- "/Reference",
-};
-
-#define ACPI_NOT_PACKAGE ACPI_UINT32_MAX
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_check_predefined_names
- *
- * PARAMETERS: Node - Namespace node for the method/object
- * return_object_ptr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check an ACPI name for a match in the predefined name list.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
- u32 user_param_count,
- acpi_status return_status,
- union acpi_operand_object **return_object_ptr)
-{
- union acpi_operand_object *return_object = *return_object_ptr;
- acpi_status status = AE_OK;
- const union acpi_predefined_info *predefined;
- char *pathname;
-
- /* Match the name for this method/object against the predefined list */
-
- predefined = acpi_ns_check_for_predefined_name(node);
-
- /* Get the full pathname to the object, for use in error messages */
-
- pathname = acpi_ns_get_external_pathname(node);
- if (!pathname) {
- pathname = ACPI_CAST_PTR(char, predefined->info.name);
- }
-
- /*
- * Check that the parameter count for this method matches the ASL
- * definition. For predefined names, ensure that both the caller and
- * the method itself are in accordance with the ACPI specification.
- */
- acpi_ns_check_parameter_count(pathname, node, user_param_count,
- predefined);
-
- /* If not a predefined name, we cannot validate the return object */
-
- if (!predefined) {
- goto exit;
- }
-
- /* If the method failed, we cannot validate the return object */
-
- if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
- goto exit;
- }
-
- /*
- * Only validate the return value on the first successful evaluation of
- * the method. This ensures that any warnings will only be emitted during
- * the very first evaluation of the method/object.
- */
- if (node->flags & ANOBJ_EVALUATED) {
- goto exit;
- }
-
- /* Mark the node as having been successfully evaluated */
-
- node->flags |= ANOBJ_EVALUATED;
-
- /*
- * If there is no return value, check if we require a return value for
- * this predefined name. Either one return value is expected, or none,
- * for both methods and other objects.
- *
- * Exit now if there is no return object. Warning if one was expected.
- */
- if (!return_object) {
- if ((predefined->info.expected_btypes) &&
- (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) {
- ACPI_ERROR((AE_INFO,
- "%s: Missing expected return value",
- pathname));
-
- status = AE_AML_NO_RETURN_VALUE;
- }
- goto exit;
- }
-
- /*
- * We have a return value, but if one wasn't expected, just exit, this is
- * not a problem
- *
- * For example, if the "Implicit Return" feature is enabled, methods will
- * always return a value
- */
- if (!predefined->info.expected_btypes) {
- goto exit;
- }
-
- /*
- * Check that the type of the return object is what is expected for
- * this predefined name
- */
- status = acpi_ns_check_object_type(pathname, return_object_ptr,
- predefined->info.expected_btypes,
- ACPI_NOT_PACKAGE);
- if (ACPI_FAILURE(status)) {
- goto exit;
- }
-
- /* For returned Package objects, check the type of all sub-objects */
-
- if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) {
- status =
- acpi_ns_check_package(pathname, return_object_ptr,
- predefined);
- }
-
- exit:
- if (pathname != predefined->info.name) {
- ACPI_FREE(pathname);
- }
-
- return (status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_check_parameter_count
- *
- * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
- * Node - Namespace node for the method/object
- * user_param_count - Number of args passed in by the caller
- * Predefined - Pointer to entry in predefined name table
- *
- * RETURN: None
- *
- * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a
- * predefined name is what is expected (i.e., what is defined in
- * the ACPI specification for this predefined name.)
- *
- ******************************************************************************/
-
-void
-acpi_ns_check_parameter_count(char *pathname,
- struct acpi_namespace_node *node,
- u32 user_param_count,
- const union acpi_predefined_info *predefined)
-{
- u32 param_count;
- u32 required_params_current;
- u32 required_params_old;
-
- /* Methods have 0-7 parameters. All other types have zero. */
-
- param_count = 0;
- if (node->type == ACPI_TYPE_METHOD) {
- param_count = node->object->method.param_count;
- }
-
- /* Argument count check for non-predefined methods/objects */
-
- if (!predefined) {
- /*
- * Warning if too few or too many arguments have been passed by the
- * caller. An incorrect number of arguments may not cause the method
- * to fail. However, the method will fail if there are too few
- * arguments and the method attempts to use one of the missing ones.
- */
- if (user_param_count < param_count) {
- ACPI_WARNING((AE_INFO,
- "%s: Insufficient arguments - needs %d, found %d",
- pathname, param_count, user_param_count));
- } else if (user_param_count > param_count) {
- ACPI_WARNING((AE_INFO,
- "%s: Excess arguments - needs %d, found %d",
- pathname, param_count, user_param_count));
- }
- return;
- }
-
- /* Allow two different legal argument counts (_SCP, etc.) */
-
- required_params_current = predefined->info.param_count & 0x0F;
- required_params_old = predefined->info.param_count >> 4;
-
- if (user_param_count != ACPI_UINT32_MAX) {
-
- /* Validate the user-supplied parameter count */
-
- if ((user_param_count != required_params_current) &&
- (user_param_count != required_params_old)) {
- ACPI_WARNING((AE_INFO,
- "%s: Parameter count mismatch - caller passed %d, ACPI requires %d",
- pathname, user_param_count,
- required_params_current));
- }
- }
-
- /*
- * Only validate the argument count on the first successful evaluation of
- * the method. This ensures that any warnings will only be emitted during
- * the very first evaluation of the method/object.
- */
- if (node->flags & ANOBJ_EVALUATED) {
- return;
- }
-
- /*
- * Check that the ASL-defined parameter count is what is expected for
- * this predefined name.
- */
- if ((param_count != required_params_current) &&
- (param_count != required_params_old)) {
- ACPI_WARNING((AE_INFO,
- "%s: Parameter count mismatch - ASL declared %d, ACPI requires %d",
- pathname, param_count, required_params_current));
- }
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_check_for_predefined_name
- *
- * PARAMETERS: Node - Namespace node for the method/object
- *
- * RETURN: Pointer to entry in predefined table. NULL indicates not found.
- *
- * DESCRIPTION: Check an object name against the predefined object list.
- *
- ******************************************************************************/
-
-const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
- acpi_namespace_node
- *node)
-{
- const union acpi_predefined_info *this_name;
-
- /* Quick check for a predefined name, first character must be underscore */
-
- if (node->name.ascii[0] != '_') {
- return (NULL);
- }
-
- /* Search info table for a predefined method/object name */
-
- this_name = predefined_names;
- while (this_name->info.name[0]) {
- if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) {
-
- /* Return pointer to this table entry */
-
- return (this_name);
- }
-
- /*
- * Skip next entry in the table if this name returns a Package
- * (next entry contains the package info)
- */
- if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) {
- this_name++;
- }
-
- this_name++;
- }
-
- return (NULL);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_check_package
- *
- * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
- * return_object_ptr - Pointer to the object returned from the
- * evaluation of a method or object
- * Predefined - Pointer to entry in predefined name table
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check a returned package object for the correct count and
- * correct type of all sub-objects.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_check_package(char *pathname,
- union acpi_operand_object **return_object_ptr,
- const union acpi_predefined_info *predefined)
-{
- union acpi_operand_object *return_object = *return_object_ptr;
- const union acpi_predefined_info *package;
- union acpi_operand_object *sub_package;
- union acpi_operand_object **elements;
- union acpi_operand_object **sub_elements;
- acpi_status status;
- u32 expected_count;
- u32 count;
- u32 i;
- u32 j;
-
- ACPI_FUNCTION_NAME(ns_check_package);
-
- /* The package info for this name is in the next table entry */
-
- package = predefined + 1;
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "%s Validating return Package of Type %X, Count %X\n",
- pathname, package->ret_info.type,
- return_object->package.count));
-
- /* Extract package count and elements array */
-
- elements = return_object->package.elements;
- count = return_object->package.count;
-
- /* The package must have at least one element, else invalid */
-
- if (!count) {
- ACPI_WARNING((AE_INFO,
- "%s: Return Package has no elements (empty)",
- pathname));
-
- return (AE_AML_OPERAND_VALUE);
- }
-
- /*
- * Decode the type of the expected package contents
- *
- * PTYPE1 packages contain no subpackages
- * PTYPE2 packages contain sub-packages
- */
- switch (package->ret_info.type) {
- case ACPI_PTYPE1_FIXED:
-
- /*
- * The package count is fixed and there are no sub-packages
- *
- * If package is too small, exit.
- * If package is larger than expected, issue warning but continue
- */
- expected_count =
- package->ret_info.count1 + package->ret_info.count2;
- if (count < expected_count) {
- goto package_too_small;
- } else if (count > expected_count) {
- ACPI_WARNING((AE_INFO,
- "%s: Return Package is larger than needed - "
- "found %u, expected %u", pathname, count,
- expected_count));
- }
-
- /* Validate all elements of the returned package */
-
- status = acpi_ns_check_package_elements(pathname, elements,
- package->ret_info.
- object_type1,
- package->ret_info.
- count1,
- package->ret_info.
- object_type2,
- package->ret_info.
- count2);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- break;
-
- case ACPI_PTYPE1_VAR:
-
- /*
- * The package count is variable, there are no sub-packages, and all
- * elements must be of the same type
- */
- for (i = 0; i < count; i++) {
- status = acpi_ns_check_object_type(pathname, elements,
- package->ret_info.
- object_type1, i);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- elements++;
- }
- break;
-
- case ACPI_PTYPE1_OPTION:
-
- /*
- * The package count is variable, there are no sub-packages. There are
- * a fixed number of required elements, and a variable number of
- * optional elements.
- *
- * Check if package is at least as large as the minimum required
- */
- expected_count = package->ret_info3.count;
- if (count < expected_count) {
- goto package_too_small;
- }
-
- /* Variable number of sub-objects */
-
- for (i = 0; i < count; i++) {
- if (i < package->ret_info3.count) {
-
- /* These are the required package elements (0, 1, or 2) */
-
- status =
- acpi_ns_check_object_type(pathname,
- elements,
- package->
- ret_info3.
- object_type[i],
- i);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- } else {
- /* These are the optional package elements */
-
- status =
- acpi_ns_check_object_type(pathname,
- elements,
- package->
- ret_info3.
- tail_object_type,
- i);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- }
- elements++;
- }
- break;
-
- case ACPI_PTYPE2_PKG_COUNT:
-
- /* First element is the (Integer) count of sub-packages to follow */
-
- status = acpi_ns_check_object_type(pathname, elements,
- ACPI_RTYPE_INTEGER, 0);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /*
- * Count cannot be larger than the parent package length, but allow it
- * to be smaller. The >= accounts for the Integer above.
- */
- expected_count = (u32) (*elements)->integer.value;
- if (expected_count >= count) {
- goto package_too_small;
- }
-
- count = expected_count;
- elements++;
-
- /* Now we can walk the sub-packages */
-
- /*lint -fallthrough */
-
- case ACPI_PTYPE2:
- case ACPI_PTYPE2_FIXED:
- case ACPI_PTYPE2_MIN:
- case ACPI_PTYPE2_COUNT:
-
- /*
- * These types all return a single package that consists of a variable
- * number of sub-packages
- */
- for (i = 0; i < count; i++) {
- sub_package = *elements;
- sub_elements = sub_package->package.elements;
-
- /* Each sub-object must be of type Package */
-
- status =
- acpi_ns_check_object_type(pathname, &sub_package,
- ACPI_RTYPE_PACKAGE, i);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Examine the different types of sub-packages */
-
- switch (package->ret_info.type) {
- case ACPI_PTYPE2:
- case ACPI_PTYPE2_PKG_COUNT:
-
- /* Each subpackage has a fixed number of elements */
-
- expected_count =
- package->ret_info.count1 +
- package->ret_info.count2;
- if (sub_package->package.count !=
- expected_count) {
- count = sub_package->package.count;
- goto package_too_small;
- }
-
- status =
- acpi_ns_check_package_elements(pathname,
- sub_elements,
- package->
- ret_info.
- object_type1,
- package->
- ret_info.
- count1,
- package->
- ret_info.
- object_type2,
- package->
- ret_info.
- count2);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- break;
-
- case ACPI_PTYPE2_FIXED:
-
- /* Each sub-package has a fixed length */
-
- expected_count = package->ret_info2.count;
- if (sub_package->package.count < expected_count) {
- count = sub_package->package.count;
- goto package_too_small;
- }
-
- /* Check the type of each sub-package element */
-
- for (j = 0; j < expected_count; j++) {
- status =
- acpi_ns_check_object_type(pathname,
- &sub_elements[j],
- package->ret_info2.object_type[j], j);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- }
- break;
-
- case ACPI_PTYPE2_MIN:
-
- /* Each sub-package has a variable but minimum length */
-
- expected_count = package->ret_info.count1;
- if (sub_package->package.count < expected_count) {
- count = sub_package->package.count;
- goto package_too_small;
- }
-
- /* Check the type of each sub-package element */
-
- status =
- acpi_ns_check_package_elements(pathname,
- sub_elements,
- package->
- ret_info.
- object_type1,
- sub_package->
- package.
- count, 0, 0);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- break;
-
- case ACPI_PTYPE2_COUNT:
-
- /* First element is the (Integer) count of elements to follow */
-
- status =
- acpi_ns_check_object_type(pathname,
- sub_elements,
- ACPI_RTYPE_INTEGER,
- 0);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Make sure package is large enough for the Count */
-
- expected_count =
- (u32) (*sub_elements)->integer.value;
- if (sub_package->package.count < expected_count) {
- count = sub_package->package.count;
- goto package_too_small;
- }
-
- /* Check the type of each sub-package element */
-
- status =
- acpi_ns_check_package_elements(pathname,
- (sub_elements
- + 1),
- package->
- ret_info.
- object_type1,
- (expected_count
- - 1), 0, 0);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- break;
-
- default:
- break;
- }
-
- elements++;
- }
- break;
-
- default:
-
- /* Should not get here if predefined info table is correct */
-
- ACPI_WARNING((AE_INFO,
- "%s: Invalid internal return type in table entry: %X",
- pathname, package->ret_info.type));
-
- return (AE_AML_INTERNAL);
- }
-
- return (AE_OK);
-
- package_too_small:
-
- /* Error exit for the case with an incorrect package count */
-
- ACPI_WARNING((AE_INFO, "%s: Return Package is too small - "
- "found %u, expected %u", pathname, count,
- expected_count));
-
- return (AE_AML_OPERAND_VALUE);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_check_package_elements
- *
- * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
- * Elements - Pointer to the package elements array
- * Type1 - Object type for first group
- * Count1 - Count for first group
- * Type2 - Object type for second group
- * Count2 - Count for second group
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check that all elements of a package are of the correct object
- * type. Supports up to two groups of different object types.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_check_package_elements(char *pathname,
- union acpi_operand_object **elements,
- u8 type1, u32 count1, u8 type2, u32 count2)
-{
- union acpi_operand_object **this_element = elements;
- acpi_status status;
- u32 i;
-
- /*
- * Up to two groups of package elements are supported by the data
- * structure. All elements in each group must be of the same type.
- * The second group can have a count of zero.
- */
- for (i = 0; i < count1; i++) {
- status = acpi_ns_check_object_type(pathname, this_element,
- type1, i);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- this_element++;
- }
-
- for (i = 0; i < count2; i++) {
- status = acpi_ns_check_object_type(pathname, this_element,
- type2, (i + count1));
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- this_element++;
- }
-
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_check_object_type
- *
- * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
- * return_object_ptr - Pointer to the object returned from the
- * evaluation of a method or object
- * expected_btypes - Bitmap of expected return type(s)
- * package_index - Index of object within parent package (if
- * applicable - ACPI_NOT_PACKAGE otherwise)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check the type of the return object against the expected object
- * type(s). Use of Btype allows multiple expected object types.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_check_object_type(char *pathname,
- union acpi_operand_object **return_object_ptr,
- u32 expected_btypes, u32 package_index)
-{
- union acpi_operand_object *return_object = *return_object_ptr;
- acpi_status status = AE_OK;
- u32 return_btype;
- char type_buffer[48]; /* Room for 5 types */
- u32 this_rtype;
- u32 i;
- u32 j;
-
- /*
- * If we get a NULL return_object here, it is a NULL package element,
- * and this is always an error.
- */
- if (!return_object) {
- goto type_error_exit;
- }
-
- /* A Namespace node should not get here, but make sure */
-
- if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) {
- ACPI_WARNING((AE_INFO,
- "%s: Invalid return type - Found a Namespace node [%4.4s] type %s",
- pathname, return_object->node.name.ascii,
- acpi_ut_get_type_name(return_object->node.type)));
- return (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type.
- * The bitmapped type allows multiple possible return types.
- *
- * Note, the cases below must handle all of the possible types returned
- * from all of the predefined names (including elements of returned
- * packages)
- */
- switch (ACPI_GET_OBJECT_TYPE(return_object)) {
- case ACPI_TYPE_INTEGER:
- return_btype = ACPI_RTYPE_INTEGER;
- break;
-
- case ACPI_TYPE_BUFFER:
- return_btype = ACPI_RTYPE_BUFFER;
- break;
-
- case ACPI_TYPE_STRING:
- return_btype = ACPI_RTYPE_STRING;
- break;
-
- case ACPI_TYPE_PACKAGE:
- return_btype = ACPI_RTYPE_PACKAGE;
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
- return_btype = ACPI_RTYPE_REFERENCE;
- break;
-
- default:
- /* Not one of the supported objects, must be incorrect */
-
- goto type_error_exit;
- }
-
- /* Is the object one of the expected types? */
-
- if (!(return_btype & expected_btypes)) {
-
- /* Type mismatch -- attempt repair of the returned object */
-
- status = acpi_ns_repair_object(expected_btypes, package_index,
- return_object_ptr);
- if (ACPI_SUCCESS(status)) {
- return (status);
- }
- goto type_error_exit;
- }
-
- /* For reference objects, check that the reference type is correct */
-
- if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_LOCAL_REFERENCE) {
- status = acpi_ns_check_reference(pathname, return_object);
- }
-
- return (status);
-
- type_error_exit:
-
- /* Create a string with all expected types for this predefined object */
-
- j = 1;
- type_buffer[0] = 0;
- this_rtype = ACPI_RTYPE_INTEGER;
-
- for (i = 0; i < ACPI_NUM_RTYPES; i++) {
-
- /* If one of the expected types, concatenate the name of this type */
-
- if (expected_btypes & this_rtype) {
- ACPI_STRCAT(type_buffer, &acpi_rtype_names[i][j]);
- j = 0; /* Use name separator from now on */
- }
- this_rtype <<= 1; /* Next Rtype */
- }
-
- if (package_index == ACPI_NOT_PACKAGE) {
- ACPI_WARNING((AE_INFO,
- "%s: Return type mismatch - found %s, expected %s",
- pathname,
- acpi_ut_get_object_type_name(return_object),
- type_buffer));
- } else {
- ACPI_WARNING((AE_INFO,
- "%s: Return Package type mismatch at index %u - "
- "found %s, expected %s", pathname, package_index,
- acpi_ut_get_object_type_name(return_object),
- type_buffer));
- }
-
- return (AE_AML_OPERAND_TYPE);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_check_reference
- *
- * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
- * return_object - Object returned from the evaluation of a
- * method or object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check a returned reference object for the correct reference
- * type. The only reference type that can be returned from a
- * predefined method is a named reference. All others are invalid.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_check_reference(char *pathname,
- union acpi_operand_object *return_object)
-{
-
- /*
- * Check the reference object for the correct reference type (opcode).
- * The only type of reference that can be converted to an union acpi_object is
- * a reference to a named object (reference class: NAME)
- */
- if (return_object->reference.class == ACPI_REFCLASS_NAME) {
- return (AE_OK);
- }
-
- ACPI_WARNING((AE_INFO,
- "%s: Return type mismatch - unexpected reference object type [%s] %2.2X",
- pathname, acpi_ut_get_reference_name(return_object),
- return_object->reference.class));
-
- return (AE_AML_OPERAND_TYPE);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_repair_object
- *
- * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
- * package_index - Used to determine if target is in a package
- * return_object_ptr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if repair was successful.
- *
- * DESCRIPTION: Attempt to repair/convert a return object of a type that was
- * not expected.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_repair_object(u32 expected_btypes,
- u32 package_index,
- union acpi_operand_object **return_object_ptr)
-{
- union acpi_operand_object *return_object = *return_object_ptr;
- union acpi_operand_object *new_object;
- acpi_size length;
-
- switch (ACPI_GET_OBJECT_TYPE(return_object)) {
- case ACPI_TYPE_BUFFER:
-
- if (!(expected_btypes & ACPI_RTYPE_STRING)) {
- return (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * Have a Buffer, expected a String, convert. Use a to_string
- * conversion, no transform performed on the buffer data. The best
- * example of this is the _BIF method, where the string data from
- * the battery is often (incorrectly) returned as buffer object(s).
- */
- length = 0;
- while ((length < return_object->buffer.length) &&
- (return_object->buffer.pointer[length])) {
- length++;
- }
-
- /* Allocate a new string object */
-
- new_object = acpi_ut_create_string_object(length);
- if (!new_object) {
- return (AE_NO_MEMORY);
- }
-
- /*
- * Copy the raw buffer data with no transform. String is already NULL
- * terminated at Length+1.
- */
- ACPI_MEMCPY(new_object->string.pointer,
- return_object->buffer.pointer, length);
-
- /* Install the new return object */
-
- acpi_ut_remove_reference(return_object);
- *return_object_ptr = new_object;
-
- /*
- * If the object is a package element, we need to:
- * 1. Decrement the reference count of the orignal object, it was
- * incremented when building the package
- * 2. Increment the reference count of the new object, it will be
- * decremented when releasing the package
- */
- if (package_index != ACPI_NOT_PACKAGE) {
- acpi_ut_remove_reference(return_object);
- acpi_ut_add_reference(new_object);
- }
- return (AE_OK);
-
- default:
- break;
- }
-
- return (AE_AML_OPERAND_TYPE);
-}
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
deleted file mode 100644
index a76c731e3ba..00000000000
--- a/drivers/acpi/namespace/nssearch.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nssearch - Namespace search
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nssearch")
-
-/* Local prototypes */
-static acpi_status
-acpi_ns_search_parent_tree(u32 target_name,
- struct acpi_namespace_node *node,
- acpi_object_type type,
- struct acpi_namespace_node **return_node);
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_search_one_scope
- *
- * PARAMETERS: target_name - Ascii ACPI name to search for
- * parent_node - Starting node where search will begin
- * Type - Object type to match
- * return_node - Where the matched Named obj is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Search a single level of the namespace. Performs a
- * simple search of the specified level, and does not add
- * entries or search parents.
- *
- *
- * Named object lists are built (and subsequently dumped) in the
- * order in which the names are encountered during the namespace load;
- *
- * All namespace searching is linear in this implementation, but
- * could be easily modified to support any improved search
- * algorithm. However, the linear search was chosen for simplicity
- * and because the trees are small and the other interpreter
- * execution overhead is relatively high.
- *
- * Note: CPU execution analysis has shown that the AML interpreter spends
- * a very small percentage of its time searching the namespace. Therefore,
- * the linear search seems to be sufficient, as there would seem to be
- * little value in improving the search.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_search_one_scope(u32 target_name,
- struct acpi_namespace_node *parent_node,
- acpi_object_type type,
- struct acpi_namespace_node **return_node)
-{
- struct acpi_namespace_node *node;
-
- ACPI_FUNCTION_TRACE(ns_search_one_scope);
-
-#ifdef ACPI_DEBUG_OUTPUT
- if (ACPI_LV_NAMES & acpi_dbg_level) {
- char *scope_name;
-
- scope_name = acpi_ns_get_external_pathname(parent_node);
- if (scope_name) {
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Searching %s (%p) For [%4.4s] (%s)\n",
- scope_name, parent_node,
- ACPI_CAST_PTR(char, &target_name),
- acpi_ut_get_type_name(type)));
-
- ACPI_FREE(scope_name);
- }
- }
-#endif
-
- /*
- * Search for name at this namespace level, which is to say that we
- * must search for the name among the children of this object
- */
- node = parent_node->child;
- while (node) {
-
- /* Check for match against the name */
-
- if (node->name.integer == target_name) {
-
- /* Resolve a control method alias if any */
-
- if (acpi_ns_get_type(node) ==
- ACPI_TYPE_LOCAL_METHOD_ALIAS) {
- node =
- ACPI_CAST_PTR(struct acpi_namespace_node,
- node->object);
- }
-
- /* Found matching entry */
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
- ACPI_CAST_PTR(char, &target_name),
- acpi_ut_get_type_name(node->type),
- node,
- acpi_ut_get_node_name(parent_node),
- parent_node));
-
- *return_node = node;
- return_ACPI_STATUS(AE_OK);
- }
-
- /*
- * The last entry in the list points back to the parent,
- * so a flag is used to indicate the end-of-list
- */
- if (node->flags & ANOBJ_END_OF_PEER_LIST) {
-
- /* Searched entire list, we are done */
-
- break;
- }
-
- /* Didn't match name, move on to the next peer object */
-
- node = node->peer;
- }
-
- /* Searched entire namespace level, not found */
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n",
- ACPI_CAST_PTR(char, &target_name),
- acpi_ut_get_type_name(type),
- acpi_ut_get_node_name(parent_node), parent_node,
- parent_node->child));
-
- return_ACPI_STATUS(AE_NOT_FOUND);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_search_parent_tree
- *
- * PARAMETERS: target_name - Ascii ACPI name to search for
- * Node - Starting node where search will begin
- * Type - Object type to match
- * return_node - Where the matched Node is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Called when a name has not been found in the current namespace
- * level. Before adding it or giving up, ACPI scope rules require
- * searching enclosing scopes in cases identified by acpi_ns_local().
- *
- * "A name is located by finding the matching name in the current
- * name space, and then in the parent name space. If the parent
- * name space does not contain the name, the search continues
- * recursively until either the name is found or the name space
- * does not have a parent (the root of the name space). This
- * indicates that the name is not found" (From ACPI Specification,
- * section 5.3)
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ns_search_parent_tree(u32 target_name,
- struct acpi_namespace_node *node,
- acpi_object_type type,
- struct acpi_namespace_node **return_node)
-{
- acpi_status status;
- struct acpi_namespace_node *parent_node;
-
- ACPI_FUNCTION_TRACE(ns_search_parent_tree);
-
- parent_node = acpi_ns_get_parent_node(node);
-
- /*
- * If there is no parent (i.e., we are at the root) or type is "local",
- * we won't be searching the parent tree.
- */
- if (!parent_node) {
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
- ACPI_CAST_PTR(char, &target_name)));
- return_ACPI_STATUS(AE_NOT_FOUND);
- }
-
- if (acpi_ns_local(type)) {
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
- ACPI_CAST_PTR(char, &target_name),
- acpi_ut_get_type_name(type)));
- return_ACPI_STATUS(AE_NOT_FOUND);
- }
-
- /* Search the parent tree */
-
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "Searching parent [%4.4s] for [%4.4s]\n",
- acpi_ut_get_node_name(parent_node),
- ACPI_CAST_PTR(char, &target_name)));
-
- /*
- * Search parents until target is found or we have backed up to the root
- */
- while (parent_node) {
- /*
- * Search parent scope. Use TYPE_ANY because we don't care about the
- * object type at this point, we only care about the existence of
- * the actual name we are searching for. Typechecking comes later.
- */
- status =
- acpi_ns_search_one_scope(target_name, parent_node,
- ACPI_TYPE_ANY, return_node);
- if (ACPI_SUCCESS(status)) {
- return_ACPI_STATUS(status);
- }
-
- /* Not found here, go up another level (until we reach the root) */
-
- parent_node = acpi_ns_get_parent_node(parent_node);
- }
-
- /* Not found in parent tree */
-
- return_ACPI_STATUS(AE_NOT_FOUND);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_search_and_enter
- *
- * PARAMETERS: target_name - Ascii ACPI name to search for (4 chars)
- * walk_state - Current state of the walk
- * Node - Starting node where search will begin
- * interpreter_mode - Add names only in ACPI_MODE_LOAD_PASS_x.
- * Otherwise,search only.
- * Type - Object type to match
- * Flags - Flags describing the search restrictions
- * return_node - Where the Node is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Search for a name segment in a single namespace level,
- * optionally adding it if it is not found. If the passed
- * Type is not Any and the type previously stored in the
- * entry was Any (i.e. unknown), update the stored type.
- *
- * In ACPI_IMODE_EXECUTE, search only.
- * In other modes, search and add if not found.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_search_and_enter(u32 target_name,
- struct acpi_walk_state *walk_state,
- struct acpi_namespace_node *node,
- acpi_interpreter_mode interpreter_mode,
- acpi_object_type type,
- u32 flags, struct acpi_namespace_node **return_node)
-{
- acpi_status status;
- struct acpi_namespace_node *new_node;
-
- ACPI_FUNCTION_TRACE(ns_search_and_enter);
-
- /* Parameter validation */
-
- if (!node || !target_name || !return_node) {
- ACPI_ERROR((AE_INFO,
- "Null parameter: Node %p Name %X ReturnNode %p",
- node, target_name, return_node));
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /*
- * Name must consist of valid ACPI characters. We will repair the name if
- * necessary because we don't want to abort because of this, but we want
- * all namespace names to be printable. A warning message is appropriate.
- *
- * This issue came up because there are in fact machines that exhibit
- * this problem, and we want to be able to enable ACPI support for them,
- * even though there are a few bad names.
- */
- if (!acpi_ut_valid_acpi_name(target_name)) {
- target_name =
- acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name));
-
- /* Report warning only if in strict mode or debug mode */
-
- if (!acpi_gbl_enable_interpreter_slack) {
- ACPI_WARNING((AE_INFO,
- "Found bad character(s) in name, repaired: [%4.4s]\n",
- ACPI_CAST_PTR(char, &target_name)));
- } else {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "Found bad character(s) in name, repaired: [%4.4s]\n",
- ACPI_CAST_PTR(char, &target_name)));
- }
- }
-
- /* Try to find the name in the namespace level specified by the caller */
-
- *return_node = ACPI_ENTRY_NOT_FOUND;
- status = acpi_ns_search_one_scope(target_name, node, type, return_node);
- if (status != AE_NOT_FOUND) {
- /*
- * If we found it AND the request specifies that a find is an error,
- * return the error
- */
- if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) {
- status = AE_ALREADY_EXISTS;
- }
-
- /* Either found it or there was an error: finished either way */
-
- return_ACPI_STATUS(status);
- }
-
- /*
- * The name was not found. If we are NOT performing the first pass
- * (name entry) of loading the namespace, search the parent tree (all the
- * way to the root if necessary.) We don't want to perform the parent
- * search when the namespace is actually being loaded. We want to perform
- * the search when namespace references are being resolved (load pass 2)
- * and during the execution phase.
- */
- if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) &&
- (flags & ACPI_NS_SEARCH_PARENT)) {
- /*
- * Not found at this level - search parent tree according to the
- * ACPI specification
- */
- status =
- acpi_ns_search_parent_tree(target_name, node, type,
- return_node);
- if (ACPI_SUCCESS(status)) {
- return_ACPI_STATUS(status);
- }
- }
-
- /* In execute mode, just search, never add names. Exit now */
-
- if (interpreter_mode == ACPI_IMODE_EXECUTE) {
- ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
- "%4.4s Not found in %p [Not adding]\n",
- ACPI_CAST_PTR(char, &target_name), node));
-
- return_ACPI_STATUS(AE_NOT_FOUND);
- }
-
- /* Create the new named object */
-
- new_node = acpi_ns_create_node(target_name);
- if (!new_node) {
- return_ACPI_STATUS(AE_NO_MEMORY);
- }
-#ifdef ACPI_ASL_COMPILER
- /*
- * Node is an object defined by an External() statement
- */
- if (flags & ACPI_NS_EXTERNAL) {
- new_node->flags |= ANOBJ_IS_EXTERNAL;
- }
-#endif
-
- if (flags & ACPI_NS_TEMPORARY) {
- new_node->flags |= ANOBJ_TEMPORARY;
- }
-
- /* Install the new object into the parent's list of children */
-
- acpi_ns_install_node(walk_state, node, new_node, type);
- *return_node = new_node;
- return_ACPI_STATUS(AE_OK);
-}
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
deleted file mode 100644
index a443d2805d2..00000000000
--- a/drivers/acpi/namespace/nsutils.c
+++ /dev/null
@@ -1,997 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
- * parents and siblings and Scope manipulation
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-#include <acpi/amlcode.h>
-#include <acpi/actables.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsutils")
-
-/* Local prototypes */
-static u8 acpi_ns_valid_path_separator(char sep);
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
-#endif
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_report_error
- *
- * PARAMETERS: module_name - Caller's module name (for error output)
- * line_number - Caller's line number (for error output)
- * internal_name - Name or path of the namespace node
- * lookup_status - Exception code from NS lookup
- *
- * RETURN: None
- *
- * DESCRIPTION: Print warning message with full pathname
- *
- ******************************************************************************/
-
-void
-acpi_ns_report_error(const char *module_name,
- u32 line_number,
- const char *internal_name, acpi_status lookup_status)
-{
- acpi_status status;
- u32 bad_name;
- char *name = NULL;
-
- acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
-
- if (lookup_status == AE_BAD_CHARACTER) {
-
- /* There is a non-ascii character in the name */
-
- ACPI_MOVE_32_TO_32(&bad_name, internal_name);
- acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name);
- } else {
- /* Convert path to external format */
-
- status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
- internal_name, NULL, &name);
-
- /* Print target name */
-
- if (ACPI_SUCCESS(status)) {
- acpi_os_printf("[%s]", name);
- } else {
- acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
- }
-
- if (name) {
- ACPI_FREE(name);
- }
- }
-
- acpi_os_printf(" Namespace lookup failure, %s\n",
- acpi_format_exception(lookup_status));
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_report_method_error
- *
- * PARAMETERS: module_name - Caller's module name (for error output)
- * line_number - Caller's line number (for error output)
- * Message - Error message to use on failure
- * prefix_node - Prefix relative to the path
- * Path - Path to the node (optional)
- * method_status - Execution status
- *
- * RETURN: None
- *
- * DESCRIPTION: Print warning message with full pathname
- *
- ******************************************************************************/
-
-void
-acpi_ns_report_method_error(const char *module_name,
- u32 line_number,
- const char *message,
- struct acpi_namespace_node *prefix_node,
- const char *path, acpi_status method_status)
-{
- acpi_status status;
- struct acpi_namespace_node *node = prefix_node;
-
- acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
-
- if (path) {
- status =
- acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH,
- &node);
- if (ACPI_FAILURE(status)) {
- acpi_os_printf("[Could not get node by pathname]");
- }
- }
-
- acpi_ns_print_node_pathname(node, message);
- acpi_os_printf(", %s\n", acpi_format_exception(method_status));
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_print_node_pathname
- *
- * PARAMETERS: Node - Object
- * Message - Prefix message
- *
- * DESCRIPTION: Print an object's full namespace pathname
- * Manages allocation/freeing of a pathname buffer
- *
- ******************************************************************************/
-
-void
-acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
- const char *message)
-{
- struct acpi_buffer buffer;
- acpi_status status;
-
- if (!node) {
- acpi_os_printf("[NULL NAME]");
- return;
- }
-
- /* Convert handle to full pathname and print it (with supplied message) */
-
- buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
-
- status = acpi_ns_handle_to_pathname(node, &buffer);
- if (ACPI_SUCCESS(status)) {
- if (message) {
- acpi_os_printf("%s ", message);
- }
-
- acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node);
- ACPI_FREE(buffer.pointer);
- }
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_valid_root_prefix
- *
- * PARAMETERS: Prefix - Character to be checked
- *
- * RETURN: TRUE if a valid prefix
- *
- * DESCRIPTION: Check if a character is a valid ACPI Root prefix
- *
- ******************************************************************************/
-
-u8 acpi_ns_valid_root_prefix(char prefix)
-{
-
- return ((u8) (prefix == '\\'));
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_valid_path_separator
- *
- * PARAMETERS: Sep - Character to be checked
- *
- * RETURN: TRUE if a valid path separator
- *
- * DESCRIPTION: Check if a character is a valid ACPI path separator
- *
- ******************************************************************************/
-
-static u8 acpi_ns_valid_path_separator(char sep)
-{
-
- return ((u8) (sep == '.'));
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_type
- *
- * PARAMETERS: Node - Parent Node to be examined
- *
- * RETURN: Type field from Node whose handle is passed
- *
- * DESCRIPTION: Return the type of a Namespace node
- *
- ******************************************************************************/
-
-acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
-{
- ACPI_FUNCTION_TRACE(ns_get_type);
-
- if (!node) {
- ACPI_WARNING((AE_INFO, "Null Node parameter"));
- return_UINT32(ACPI_TYPE_ANY);
- }
-
- return_UINT32((acpi_object_type) node->type);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_local
- *
- * PARAMETERS: Type - A namespace object type
- *
- * RETURN: LOCAL if names must be found locally in objects of the
- * passed type, 0 if enclosing scopes should be searched
- *
- * DESCRIPTION: Returns scope rule for the given object type.
- *
- ******************************************************************************/
-
-u32 acpi_ns_local(acpi_object_type type)
-{
- ACPI_FUNCTION_TRACE(ns_local);
-
- if (!acpi_ut_valid_object_type(type)) {
-
- /* Type code out of range */
-
- ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type));
- return_UINT32(ACPI_NS_NORMAL);
- }
-
- return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_internal_name_length
- *
- * PARAMETERS: Info - Info struct initialized with the
- * external name pointer.
- *
- * RETURN: None
- *
- * DESCRIPTION: Calculate the length of the internal (AML) namestring
- * corresponding to the external (ASL) namestring.
- *
- ******************************************************************************/
-
-void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
-{
- const char *next_external_char;
- u32 i;
-
- ACPI_FUNCTION_ENTRY();
-
- next_external_char = info->external_name;
- info->num_carats = 0;
- info->num_segments = 0;
- info->fully_qualified = FALSE;
-
- /*
- * For the internal name, the required length is 4 bytes per segment, plus
- * 1 each for root_prefix, multi_name_prefix_op, segment count, trailing null
- * (which is not really needed, but no there's harm in putting it there)
- *
- * strlen() + 1 covers the first name_seg, which has no path separator
- */
- if (acpi_ns_valid_root_prefix(*next_external_char)) {
- info->fully_qualified = TRUE;
- next_external_char++;
-
- /* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
-
- while (acpi_ns_valid_root_prefix(*next_external_char)) {
- next_external_char++;
- }
- } else {
- /*
- * Handle Carat prefixes
- */
- while (*next_external_char == '^') {
- info->num_carats++;
- next_external_char++;
- }
- }
-
- /*
- * Determine the number of ACPI name "segments" by counting the number of
- * path separators within the string. Start with one segment since the
- * segment count is [(# separators) + 1], and zero separators is ok.
- */
- if (*next_external_char) {
- info->num_segments = 1;
- for (i = 0; next_external_char[i]; i++) {
- if (acpi_ns_valid_path_separator(next_external_char[i])) {
- info->num_segments++;
- }
- }
- }
-
- info->length = (ACPI_NAME_SIZE * info->num_segments) +
- 4 + info->num_carats;
-
- info->next_external_char = next_external_char;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_build_internal_name
- *
- * PARAMETERS: Info - Info struct fully initialized
- *
- * RETURN: Status
- *
- * DESCRIPTION: Construct the internal (AML) namestring
- * corresponding to the external (ASL) namestring.
- *
- ******************************************************************************/
-
-acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
-{
- u32 num_segments = info->num_segments;
- char *internal_name = info->internal_name;
- const char *external_name = info->next_external_char;
- char *result = NULL;
- u32 i;
-
- ACPI_FUNCTION_TRACE(ns_build_internal_name);
-
- /* Setup the correct prefixes, counts, and pointers */
-
- if (info->fully_qualified) {
- internal_name[0] = '\\';
-
- if (num_segments <= 1) {
- result = &internal_name[1];
- } else if (num_segments == 2) {
- internal_name[1] = AML_DUAL_NAME_PREFIX;
- result = &internal_name[2];
- } else {
- internal_name[1] = AML_MULTI_NAME_PREFIX_OP;
- internal_name[2] = (char)num_segments;
- result = &internal_name[3];
- }
- } else {
- /*
- * Not fully qualified.
- * Handle Carats first, then append the name segments
- */
- i = 0;
- if (info->num_carats) {
- for (i = 0; i < info->num_carats; i++) {
- internal_name[i] = '^';
- }
- }
-
- if (num_segments <= 1) {
- result = &internal_name[i];
- } else if (num_segments == 2) {
- internal_name[i] = AML_DUAL_NAME_PREFIX;
- result = &internal_name[(acpi_size) i + 1];
- } else {
- internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
- internal_name[(acpi_size) i + 1] = (char)num_segments;
- result = &internal_name[(acpi_size) i + 2];
- }
- }
-
- /* Build the name (minus path separators) */
-
- for (; num_segments; num_segments--) {
- for (i = 0; i < ACPI_NAME_SIZE; i++) {
- if (acpi_ns_valid_path_separator(*external_name) ||
- (*external_name == 0)) {
-
- /* Pad the segment with underscore(s) if segment is short */
-
- result[i] = '_';
- } else {
- /* Convert the character to uppercase and save it */
-
- result[i] =
- (char)ACPI_TOUPPER((int)*external_name);
- external_name++;
- }
- }
-
- /* Now we must have a path separator, or the pathname is bad */
-
- if (!acpi_ns_valid_path_separator(*external_name) &&
- (*external_name != 0)) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /* Move on the next segment */
-
- external_name++;
- result += ACPI_NAME_SIZE;
- }
-
- /* Terminate the string */
-
- *result = 0;
-
- if (info->fully_qualified) {
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
- "Returning [%p] (abs) \"\\%s\"\n",
- internal_name, internal_name));
- } else {
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
- internal_name, internal_name));
- }
-
- return_ACPI_STATUS(AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_internalize_name
- *
- * PARAMETERS: *external_name - External representation of name
- * **Converted Name - Where to return the resulting
- * internal represention of the name
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
- * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
- *
- *******************************************************************************/
-
-acpi_status
-acpi_ns_internalize_name(const char *external_name, char **converted_name)
-{
- char *internal_name;
- struct acpi_namestring_info info;
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(ns_internalize_name);
-
- if ((!external_name) || (*external_name == 0) || (!converted_name)) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /* Get the length of the new internal name */
-
- info.external_name = external_name;
- acpi_ns_get_internal_name_length(&info);
-
- /* We need a segment to store the internal name */
-
- internal_name = ACPI_ALLOCATE_ZEROED(info.length);
- if (!internal_name) {
- return_ACPI_STATUS(AE_NO_MEMORY);
- }
-
- /* Build the name */
-
- info.internal_name = internal_name;
- status = acpi_ns_build_internal_name(&info);
- if (ACPI_FAILURE(status)) {
- ACPI_FREE(internal_name);
- return_ACPI_STATUS(status);
- }
-
- *converted_name = internal_name;
- return_ACPI_STATUS(AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_externalize_name
- *
- * PARAMETERS: internal_name_length - Lenth of the internal name below
- * internal_name - Internal representation of name
- * converted_name_length - Where the length is returned
- * converted_name - Where the resulting external name
- * is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
- * to its external (printable) form (e.g. "\_PR_.CPU0")
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_externalize_name(u32 internal_name_length,
- const char *internal_name,
- u32 * converted_name_length, char **converted_name)
-{
- u32 names_index = 0;
- u32 num_segments = 0;
- u32 required_length;
- u32 prefix_length = 0;
- u32 i = 0;
- u32 j = 0;
-
- ACPI_FUNCTION_TRACE(ns_externalize_name);
-
- if (!internal_name_length || !internal_name || !converted_name) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /*
- * Check for a prefix (one '\' | one or more '^').
- */
- switch (internal_name[0]) {
- case '\\':
- prefix_length = 1;
- break;
-
- case '^':
- for (i = 0; i < internal_name_length; i++) {
- if (internal_name[i] == '^') {
- prefix_length = i + 1;
- } else {
- break;
- }
- }
-
- if (i == internal_name_length) {
- prefix_length = i;
- }
-
- break;
-
- default:
- break;
- }
-
- /*
- * Check for object names. Note that there could be 0-255 of these
- * 4-byte elements.
- */
- if (prefix_length < internal_name_length) {
- switch (internal_name[prefix_length]) {
- case AML_MULTI_NAME_PREFIX_OP:
-
- /* <count> 4-byte names */
-
- names_index = prefix_length + 2;
- num_segments = (u8)
- internal_name[(acpi_size) prefix_length + 1];
- break;
-
- case AML_DUAL_NAME_PREFIX:
-
- /* Two 4-byte names */
-
- names_index = prefix_length + 1;
- num_segments = 2;
- break;
-
- case 0:
-
- /* null_name */
-
- names_index = 0;
- num_segments = 0;
- break;
-
- default:
-
- /* one 4-byte name */
-
- names_index = prefix_length;
- num_segments = 1;
- break;
- }
- }
-
- /*
- * Calculate the length of converted_name, which equals the length
- * of the prefix, length of all object names, length of any required
- * punctuation ('.') between object names, plus the NULL terminator.
- */
- required_length = prefix_length + (4 * num_segments) +
- ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
-
- /*
- * Check to see if we're still in bounds. If not, there's a problem
- * with internal_name (invalid format).
- */
- if (required_length > internal_name_length) {
- ACPI_ERROR((AE_INFO, "Invalid internal name"));
- return_ACPI_STATUS(AE_BAD_PATHNAME);
- }
-
- /*
- * Build converted_name
- */
- *converted_name = ACPI_ALLOCATE_ZEROED(required_length);
- if (!(*converted_name)) {
- return_ACPI_STATUS(AE_NO_MEMORY);
- }
-
- j = 0;
-
- for (i = 0; i < prefix_length; i++) {
- (*converted_name)[j++] = internal_name[i];
- }
-
- if (num_segments > 0) {
- for (i = 0; i < num_segments; i++) {
- if (i > 0) {
- (*converted_name)[j++] = '.';
- }
-
- (*converted_name)[j++] = internal_name[names_index++];
- (*converted_name)[j++] = internal_name[names_index++];
- (*converted_name)[j++] = internal_name[names_index++];
- (*converted_name)[j++] = internal_name[names_index++];
- }
- }
-
- if (converted_name_length) {
- *converted_name_length = (u32) required_length;
- }
-
- return_ACPI_STATUS(AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_map_handle_to_node
- *
- * PARAMETERS: Handle - Handle to be converted to an Node
- *
- * RETURN: A Name table entry pointer
- *
- * DESCRIPTION: Convert a namespace handle to a real Node
- *
- * Note: Real integer handles would allow for more verification
- * and keep all pointers within this subsystem - however this introduces
- * more (and perhaps unnecessary) overhead.
- *
- ******************************************************************************/
-
-struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
-{
-
- ACPI_FUNCTION_ENTRY();
-
- /*
- * Simple implementation
- */
- if ((!handle) || (handle == ACPI_ROOT_OBJECT)) {
- return (acpi_gbl_root_node);
- }
-
- /* We can at least attempt to verify the handle */
-
- if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) {
- return (NULL);
- }
-
- return (ACPI_CAST_PTR(struct acpi_namespace_node, handle));
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_convert_entry_to_handle
- *
- * PARAMETERS: Node - Node to be converted to a Handle
- *
- * RETURN: A user handle
- *
- * DESCRIPTION: Convert a real Node to a namespace handle
- *
- ******************************************************************************/
-
-acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node)
-{
-
- /*
- * Simple implementation for now;
- */
- return ((acpi_handle) node);
-
-/* Example future implementation ---------------------
-
- if (!Node)
- {
- return (NULL);
- }
-
- if (Node == acpi_gbl_root_node)
- {
- return (ACPI_ROOT_OBJECT);
- }
-
- return ((acpi_handle) Node);
-------------------------------------------------------*/
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_terminate
- *
- * PARAMETERS: none
- *
- * RETURN: none
- *
- * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
- *
- ******************************************************************************/
-
-void acpi_ns_terminate(void)
-{
- union acpi_operand_object *obj_desc;
-
- ACPI_FUNCTION_TRACE(ns_terminate);
-
- /*
- * 1) Free the entire namespace -- all nodes and objects
- *
- * Delete all object descriptors attached to namepsace nodes
- */
- acpi_ns_delete_namespace_subtree(acpi_gbl_root_node);
-
- /* Detach any objects attached to the root */
-
- obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
- if (obj_desc) {
- acpi_ns_detach_object(acpi_gbl_root_node);
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
- return_VOID;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_opens_scope
- *
- * PARAMETERS: Type - A valid namespace type
- *
- * RETURN: NEWSCOPE if the passed type "opens a name scope" according
- * to the ACPI specification, else 0
- *
- ******************************************************************************/
-
-u32 acpi_ns_opens_scope(acpi_object_type type)
-{
- ACPI_FUNCTION_TRACE_STR(ns_opens_scope, acpi_ut_get_type_name(type));
-
- if (!acpi_ut_valid_object_type(type)) {
-
- /* type code out of range */
-
- ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type));
- return_UINT32(ACPI_NS_NORMAL);
- }
-
- return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_node
- *
- * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
- * \ (backslash) and ^ (carat) prefixes, and the
- * . (period) to separate segments are supported.
- * prefix_node - Root of subtree to be searched, or NS_ALL for the
- * root of the name space. If Name is fully
- * qualified (first s8 is '\'), the passed value
- * of Scope will not be accessed.
- * Flags - Used to indicate whether to perform upsearch or
- * not.
- * return_node - Where the Node is returned
- *
- * DESCRIPTION: Look up a name relative to a given scope and return the
- * corresponding Node. NOTE: Scope can be null.
- *
- * MUTEX: Locks namespace
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
- const char *pathname,
- u32 flags, struct acpi_namespace_node **return_node)
-{
- union acpi_generic_state scope_info;
- acpi_status status;
- char *internal_path;
-
- ACPI_FUNCTION_TRACE_PTR(ns_get_node, pathname);
-
- if (!pathname) {
- *return_node = prefix_node;
- if (!prefix_node) {
- *return_node = acpi_gbl_root_node;
- }
- return_ACPI_STATUS(AE_OK);
- }
-
- /* Convert path to internal representation */
-
- status = acpi_ns_internalize_name(pathname, &internal_path);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /* Must lock namespace during lookup */
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- goto cleanup;
- }
-
- /* Setup lookup scope (search starting point) */
-
- scope_info.scope.node = prefix_node;
-
- /* Lookup the name in the namespace */
-
- status = acpi_ns_lookup(&scope_info, internal_path, ACPI_TYPE_ANY,
- ACPI_IMODE_EXECUTE,
- (flags | ACPI_NS_DONT_OPEN_SCOPE), NULL,
- return_node);
- if (ACPI_FAILURE(status)) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s, %s\n",
- pathname, acpi_format_exception(status)));
- }
-
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
-
- cleanup:
- ACPI_FREE(internal_path);
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_parent_node
- *
- * PARAMETERS: Node - Current table entry
- *
- * RETURN: Parent entry of the given entry
- *
- * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
- *
- ******************************************************************************/
-
-struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
- *node)
-{
- ACPI_FUNCTION_ENTRY();
-
- if (!node) {
- return (NULL);
- }
-
- /*
- * Walk to the end of this peer list. The last entry is marked with a flag
- * and the peer pointer is really a pointer back to the parent. This saves
- * putting a parent back pointer in each and every named object!
- */
- while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
- node = node->peer;
- }
-
- return (node->peer);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_next_valid_node
- *
- * PARAMETERS: Node - Current table entry
- *
- * RETURN: Next valid Node in the linked node list. NULL if no more valid
- * nodes.
- *
- * DESCRIPTION: Find the next valid node within a name table.
- * Useful for implementing NULL-end-of-list loops.
- *
- ******************************************************************************/
-
-struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
- acpi_namespace_node
- *node)
-{
-
- /* If we are at the end of this peer list, return NULL */
-
- if (node->flags & ANOBJ_END_OF_PEER_LIST) {
- return NULL;
- }
-
- /* Otherwise just return the next peer */
-
- return (node->peer);
-}
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_find_parent_name
- *
- * PARAMETERS: *child_node - Named Obj whose name is to be found
- *
- * RETURN: The ACPI name
- *
- * DESCRIPTION: Search for the given obj in its parent scope and return the
- * name segment, or "????" if the parent name can't be found
- * (which "should not happen").
- *
- ******************************************************************************/
-
-acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node * child_node)
-{
- struct acpi_namespace_node *parent_node;
-
- ACPI_FUNCTION_TRACE(ns_find_parent_name);
-
- if (child_node) {
-
- /* Valid entry. Get the parent Node */
-
- parent_node = acpi_ns_get_parent_node(child_node);
- if (parent_node) {
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
- "Parent of %p [%4.4s] is %p [%4.4s]\n",
- child_node,
- acpi_ut_get_node_name(child_node),
- parent_node,
- acpi_ut_get_node_name(parent_node)));
-
- if (parent_node->name.integer) {
- return_VALUE((acpi_name) parent_node->name.
- integer);
- }
- }
-
- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
- "Unable to find parent of %p (%4.4s)\n",
- child_node,
- acpi_ut_get_node_name(child_node)));
- }
-
- return_VALUE(ACPI_UNKNOWN_NAME);
-}
-#endif
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
deleted file mode 100644
index 71b83e9807d..00000000000
--- a/drivers/acpi/namespace/nswalk.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nswalk - Functions for walking the ACPI namespace
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nswalk")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_next_node
- *
- * PARAMETERS: Type - Type of node to be searched for
- * parent_node - Parent node whose children we are
- * getting
- * child_node - Previous child that was found.
- * The NEXT child will be returned
- *
- * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if
- * none is found.
- *
- * DESCRIPTION: Return the next peer node within the namespace. If Handle
- * is valid, Scope is ignored. Otherwise, the first node
- * within Scope is returned.
- *
- ******************************************************************************/
-struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct acpi_namespace_node
- *parent_node, struct acpi_namespace_node
- *child_node)
-{
- struct acpi_namespace_node *next_node = NULL;
-
- ACPI_FUNCTION_ENTRY();
-
- if (!child_node) {
-
- /* It's really the parent's _scope_ that we want */
-
- next_node = parent_node->child;
- }
-
- else {
- /* Start search at the NEXT node */
-
- next_node = acpi_ns_get_next_valid_node(child_node);
- }
-
- /* If any type is OK, we are done */
-
- if (type == ACPI_TYPE_ANY) {
-
- /* next_node is NULL if we are at the end-of-list */
-
- return (next_node);
- }
-
- /* Must search for the node -- but within this scope only */
-
- while (next_node) {
-
- /* If type matches, we are done */
-
- if (next_node->type == type) {
- return (next_node);
- }
-
- /* Otherwise, move on to the next node */
-
- next_node = acpi_ns_get_next_valid_node(next_node);
- }
-
- /* Not found */
-
- return (NULL);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_walk_namespace
- *
- * PARAMETERS: Type - acpi_object_type to search for
- * start_node - Handle in namespace where search begins
- * max_depth - Depth to which search is to reach
- * Flags - Whether to unlock the NS before invoking
- * the callback routine
- * user_function - Called when an object of "Type" is found
- * Context - Passed to user function
- * return_value - from the user_function if terminated early.
- * Otherwise, returns NULL.
- * RETURNS: Status
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- * starting (and ending) at the node specified by start_handle.
- * The user_function is called whenever a node that matches
- * the type parameter is found. If the user function returns
- * a non-zero value, the search is terminated immediately and this
- * value is returned to the caller.
- *
- * The point of this procedure is to provide a generic namespace
- * walk routine that can be called from multiple places to
- * provide multiple services; the User Function can be tailored
- * to each task, whether it is a print function, a compare
- * function, etc.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ns_walk_namespace(acpi_object_type type,
- acpi_handle start_node,
- u32 max_depth,
- u32 flags,
- acpi_walk_callback user_function,
- void *context, void **return_value)
-{
- acpi_status status;
- acpi_status mutex_status;
- struct acpi_namespace_node *child_node;
- struct acpi_namespace_node *parent_node;
- acpi_object_type child_type;
- u32 level;
-
- ACPI_FUNCTION_TRACE(ns_walk_namespace);
-
- /* Special case for the namespace Root Node */
-
- if (start_node == ACPI_ROOT_OBJECT) {
- start_node = acpi_gbl_root_node;
- }
-
- /* Null child means "get first node" */
-
- parent_node = start_node;
- child_node = NULL;
- child_type = ACPI_TYPE_ANY;
- level = 1;
-
- /*
- * Traverse the tree of nodes until we bubble back up to where we
- * started. When Level is zero, the loop is done because we have
- * bubbled up to (and passed) the original parent handle (start_entry)
- */
- while (level > 0) {
-
- /* Get the next node in this scope. Null if not found */
-
- status = AE_OK;
- child_node =
- acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
- child_node);
- if (child_node) {
-
- /* Found next child, get the type if we are not searching for ANY */
-
- if (type != ACPI_TYPE_ANY) {
- child_type = child_node->type;
- }
-
- /*
- * Ignore all temporary namespace nodes (created during control
- * method execution) unless told otherwise. These temporary nodes
- * can cause a race condition because they can be deleted during the
- * execution of the user function (if the namespace is unlocked before
- * invocation of the user function.) Only the debugger namespace dump
- * will examine the temporary nodes.
- */
- if ((child_node->flags & ANOBJ_TEMPORARY) &&
- !(flags & ACPI_NS_WALK_TEMP_NODES)) {
- status = AE_CTRL_DEPTH;
- }
-
- /* Type must match requested type */
-
- else if (child_type == type) {
- /*
- * Found a matching node, invoke the user callback function.
- * Unlock the namespace if flag is set.
- */
- if (flags & ACPI_NS_WALK_UNLOCK) {
- mutex_status =
- acpi_ut_release_mutex
- (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(mutex_status)) {
- return_ACPI_STATUS
- (mutex_status);
- }
- }
-
- status =
- user_function(child_node, level, context,
- return_value);
-
- if (flags & ACPI_NS_WALK_UNLOCK) {
- mutex_status =
- acpi_ut_acquire_mutex
- (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(mutex_status)) {
- return_ACPI_STATUS
- (mutex_status);
- }
- }
-
- switch (status) {
- case AE_OK:
- case AE_CTRL_DEPTH:
-
- /* Just keep going */
- break;
-
- case AE_CTRL_TERMINATE:
-
- /* Exit now, with OK status */
-
- return_ACPI_STATUS(AE_OK);
-
- default:
-
- /* All others are valid exceptions */
-
- return_ACPI_STATUS(status);
- }
- }
-
- /*
- * Depth first search: Attempt to go down another level in the
- * namespace if we are allowed to. Don't go any further if we have
- * reached the caller specified maximum depth or if the user
- * function has specified that the maximum depth has been reached.
- */
- if ((level < max_depth) && (status != AE_CTRL_DEPTH)) {
- if (acpi_ns_get_next_node
- (ACPI_TYPE_ANY, child_node, NULL)) {
-
- /* There is at least one child of this node, visit it */
-
- level++;
- parent_node = child_node;
- child_node = NULL;
- }
- }
- } else {
- /*
- * No more children of this node (acpi_ns_get_next_node failed), go
- * back upwards in the namespace tree to the node's parent.
- */
- level--;
- child_node = parent_node;
- parent_node = acpi_ns_get_parent_node(parent_node);
- }
- }
-
- /* Complete walk, not terminated by user function */
-
- return_ACPI_STATUS(AE_OK);
-}
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
deleted file mode 100644
index 598393a04e5..00000000000
--- a/drivers/acpi/namespace/nsxfeval.c
+++ /dev/null
@@ -1,812 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
- * ACPI Object evaluation interfaces
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-#include <acpi/acinterp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsxfeval")
-
-/* Local prototypes */
-static void acpi_ns_resolve_references(struct acpi_evaluate_info *info);
-
-#ifdef ACPI_FUTURE_USAGE
-/*******************************************************************************
- *
- * FUNCTION: acpi_evaluate_object_typed
- *
- * PARAMETERS: Handle - Object handle (optional)
- * Pathname - Object pathname (optional)
- * external_params - List of parameters to pass to method,
- * terminated by NULL. May be NULL
- * if no parameters are being passed.
- * return_buffer - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * return_type - Expected type of return object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Find and evaluate the given object, passing the given
- * parameters if necessary. One of "Handle" or "Pathname" must
- * be valid (non-null)
- *
- ******************************************************************************/
-
-acpi_status
-acpi_evaluate_object_typed(acpi_handle handle,
- acpi_string pathname,
- struct acpi_object_list *external_params,
- struct acpi_buffer *return_buffer,
- acpi_object_type return_type)
-{
- acpi_status status;
- u8 must_free = FALSE;
-
- ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed);
-
- /* Return buffer must be valid */
-
- if (!return_buffer) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
- must_free = TRUE;
- }
-
- /* Evaluate the object */
-
- status =
- acpi_evaluate_object(handle, pathname, external_params,
- return_buffer);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- /* Type ANY means "don't care" */
-
- if (return_type == ACPI_TYPE_ANY) {
- return_ACPI_STATUS(AE_OK);
- }
-
- if (return_buffer->length == 0) {
-
- /* Error because caller specifically asked for a return value */
-
- ACPI_ERROR((AE_INFO, "No return value"));
- return_ACPI_STATUS(AE_NULL_OBJECT);
- }
-
- /* Examine the object type returned from evaluate_object */
-
- if (((union acpi_object *)return_buffer->pointer)->type == return_type) {
- return_ACPI_STATUS(AE_OK);
- }
-
- /* Return object type does not match requested type */
-
- ACPI_ERROR((AE_INFO,
- "Incorrect return type [%s] requested [%s]",
- acpi_ut_get_type_name(((union acpi_object *)return_buffer->
- pointer)->type),
- acpi_ut_get_type_name(return_type)));
-
- if (must_free) {
-
- /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
-
- ACPI_FREE(return_buffer->pointer);
- return_buffer->pointer = NULL;
- }
-
- return_buffer->length = 0;
- return_ACPI_STATUS(AE_TYPE);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed)
-#endif /* ACPI_FUTURE_USAGE */
-/*******************************************************************************
- *
- * FUNCTION: acpi_evaluate_object
- *
- * PARAMETERS: Handle - Object handle (optional)
- * Pathname - Object pathname (optional)
- * external_params - List of parameters to pass to method,
- * terminated by NULL. May be NULL
- * if no parameters are being passed.
- * return_buffer - Where to put method's return value (if
- * any). If NULL, no value is returned.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Find and evaluate the given object, passing the given
- * parameters if necessary. One of "Handle" or "Pathname" must
- * be valid (non-null)
- *
- ******************************************************************************/
-acpi_status
-acpi_evaluate_object(acpi_handle handle,
- acpi_string pathname,
- struct acpi_object_list *external_params,
- struct acpi_buffer *return_buffer)
-{
- acpi_status status;
- struct acpi_evaluate_info *info;
- acpi_size buffer_space_needed;
- u32 i;
-
- ACPI_FUNCTION_TRACE(acpi_evaluate_object);
-
- /* Allocate and initialize the evaluation information block */
-
- info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
- if (!info) {
- return_ACPI_STATUS(AE_NO_MEMORY);
- }
-
- info->pathname = pathname;
-
- /* Convert and validate the device handle */
-
- info->prefix_node = acpi_ns_map_handle_to_node(handle);
- if (!info->prefix_node) {
- status = AE_BAD_PARAMETER;
- goto cleanup;
- }
-
- /*
- * If there are parameters to be passed to a control method, the external
- * objects must all be converted to internal objects
- */
- if (external_params && external_params->count) {
- /*
- * Allocate a new parameter block for the internal objects
- * Add 1 to count to allow for null terminated internal list
- */
- info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size)
- external_params->
- count +
- 1) * sizeof(void *));
- if (!info->parameters) {
- status = AE_NO_MEMORY;
- goto cleanup;
- }
-
- /* Convert each external object in the list to an internal object */
-
- for (i = 0; i < external_params->count; i++) {
- status =
- acpi_ut_copy_eobject_to_iobject(&external_params->
- pointer[i],
- &info->
- parameters[i]);
- if (ACPI_FAILURE(status)) {
- goto cleanup;
- }
- }
- info->parameters[external_params->count] = NULL;
- }
-
- /*
- * Three major cases:
- * 1) Fully qualified pathname
- * 2) No handle, not fully qualified pathname (error)
- * 3) Valid handle
- */
- if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) {
-
- /* The path is fully qualified, just evaluate by name */
-
- info->prefix_node = NULL;
- status = acpi_ns_evaluate(info);
- } else if (!handle) {
- /*
- * A handle is optional iff a fully qualified pathname is specified.
- * Since we've already handled fully qualified names above, this is
- * an error
- */
- if (!pathname) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "Both Handle and Pathname are NULL"));
- } else {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "Null Handle with relative pathname [%s]",
- pathname));
- }
-
- status = AE_BAD_PARAMETER;
- } else {
- /* We have a namespace a node and a possible relative path */
-
- status = acpi_ns_evaluate(info);
- }
-
- /*
- * If we are expecting a return value, and all went well above,
- * copy the return value to an external object.
- */
- if (return_buffer) {
- if (!info->return_object) {
- return_buffer->length = 0;
- } else {
- if (ACPI_GET_DESCRIPTOR_TYPE(info->return_object) ==
- ACPI_DESC_TYPE_NAMED) {
- /*
- * If we received a NS Node as a return object, this means that
- * the object we are evaluating has nothing interesting to
- * return (such as a mutex, etc.) We return an error because
- * these types are essentially unsupported by this interface.
- * We don't check up front because this makes it easier to add
- * support for various types at a later date if necessary.
- */
- status = AE_TYPE;
- info->return_object = NULL; /* No need to delete a NS Node */
- return_buffer->length = 0;
- }
-
- if (ACPI_SUCCESS(status)) {
-
- /* Dereference Index and ref_of references */
-
- acpi_ns_resolve_references(info);
-
- /* Get the size of the returned object */
-
- status =
- acpi_ut_get_object_size(info->return_object,
- &buffer_space_needed);
- if (ACPI_SUCCESS(status)) {
-
- /* Validate/Allocate/Clear caller buffer */
-
- status =
- acpi_ut_initialize_buffer
- (return_buffer,
- buffer_space_needed);
- if (ACPI_FAILURE(status)) {
- /*
- * Caller's buffer is too small or a new one can't
- * be allocated
- */
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "Needed buffer size %X, %s\n",
- (u32)
- buffer_space_needed,
- acpi_format_exception
- (status)));
- } else {
- /* We have enough space for the object, build it */
-
- status =
- acpi_ut_copy_iobject_to_eobject
- (info->return_object,
- return_buffer);
- }
- }
- }
- }
- }
-
- if (info->return_object) {
- /*
- * Delete the internal return object. NOTE: Interpreter must be
- * locked to avoid race condition.
- */
- acpi_ex_enter_interpreter();
-
- /* Remove one reference on the return object (should delete it) */
-
- acpi_ut_remove_reference(info->return_object);
- acpi_ex_exit_interpreter();
- }
-
- cleanup:
-
- /* Free the input parameter list (if we created one) */
-
- if (info->parameters) {
-
- /* Free the allocated parameter block */
-
- acpi_ut_delete_internal_object_list(info->parameters);
- }
-
- ACPI_FREE(info);
- return_ACPI_STATUS(status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_evaluate_object)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_resolve_references
- *
- * PARAMETERS: Info - Evaluation info block
- *
- * RETURN: Info->return_object is replaced with the dereferenced object
- *
- * DESCRIPTION: Dereference certain reference objects. Called before an
- * internal return object is converted to an external union acpi_object.
- *
- * Performs an automatic dereference of Index and ref_of reference objects.
- * These reference objects are not supported by the union acpi_object, so this is a
- * last resort effort to return something useful. Also, provides compatibility
- * with other ACPI implementations.
- *
- * NOTE: does not handle references within returned package objects or nested
- * references, but this support could be added later if found to be necessary.
- *
- ******************************************************************************/
-static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
-{
- union acpi_operand_object *obj_desc = NULL;
- struct acpi_namespace_node *node;
-
- /* We are interested in reference objects only */
-
- if (ACPI_GET_OBJECT_TYPE(info->return_object) !=
- ACPI_TYPE_LOCAL_REFERENCE) {
- return;
- }
-
- /*
- * Two types of references are supported - those created by Index and
- * ref_of operators. A name reference (AML_NAMEPATH_OP) can be converted
- * to an union acpi_object, so it is not dereferenced here. A ddb_handle
- * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
- * an union acpi_object.
- */
- switch (info->return_object->reference.class) {
- case ACPI_REFCLASS_INDEX:
-
- obj_desc = *(info->return_object->reference.where);
- break;
-
- case ACPI_REFCLASS_REFOF:
-
- node = info->return_object->reference.object;
- if (node) {
- obj_desc = node->object;
- }
- break;
-
- default:
- return;
- }
-
- /* Replace the existing reference object */
-
- if (obj_desc) {
- acpi_ut_add_reference(obj_desc);
- acpi_ut_remove_reference(info->return_object);
- info->return_object = obj_desc;
- }
-
- return;
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_walk_namespace
- *
- * PARAMETERS: Type - acpi_object_type to search for
- * start_object - Handle in namespace where search begins
- * max_depth - Depth to which search is to reach
- * user_function - Called when an object of "Type" is found
- * Context - Passed to user function
- * return_value - Location where return value of
- * user_function is put if terminated early
- *
- * RETURNS Return value from the user_function if terminated early.
- * Otherwise, returns NULL.
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- * starting (and ending) at the object specified by start_handle.
- * The user_function is called whenever an object that matches
- * the type parameter is found. If the user function returns
- * a non-zero value, the search is terminated immediately and this
- * value is returned to the caller.
- *
- * The point of this procedure is to provide a generic namespace
- * walk routine that can be called from multiple places to
- * provide multiple services; the User Function can be tailored
- * to each task, whether it is a print function, a compare
- * function, etc.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_walk_namespace(acpi_object_type type,
- acpi_handle start_object,
- u32 max_depth,
- acpi_walk_callback user_function,
- void *context, void **return_value)
-{
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(acpi_walk_namespace);
-
- /* Parameter validation */
-
- if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /*
- * Lock the namespace around the walk.
- * The namespace will be unlocked/locked around each call
- * to the user function - since this function
- * must be allowed to make Acpi calls itself.
- */
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- status = acpi_ns_walk_namespace(type, start_object, max_depth,
- ACPI_NS_WALK_UNLOCK,
- user_function, context, return_value);
-
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return_ACPI_STATUS(status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_walk_namespace)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_get_device_callback
- *
- * PARAMETERS: Callback from acpi_get_device
- *
- * RETURN: Status
- *
- * DESCRIPTION: Takes callbacks from walk_namespace and filters out all non-
- * present devices, or if they specified a HID, it filters based
- * on that.
- *
- ******************************************************************************/
-static acpi_status
-acpi_ns_get_device_callback(acpi_handle obj_handle,
- u32 nesting_level,
- void *context, void **return_value)
-{
- struct acpi_get_devices_info *info = context;
- acpi_status status;
- struct acpi_namespace_node *node;
- u32 flags;
- struct acpica_device_id hid;
- struct acpi_compatible_id_list *cid;
- u32 i;
- int found;
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- node = acpi_ns_map_handle_to_node(obj_handle);
- status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- if (!node) {
- return (AE_BAD_PARAMETER);
- }
-
- /* Run _STA to determine if device is present */
-
- status = acpi_ut_execute_STA(node, &flags);
- if (ACPI_FAILURE(status)) {
- return (AE_CTRL_DEPTH);
- }
-
- if (!(flags & ACPI_STA_DEVICE_PRESENT) &&
- !(flags & ACPI_STA_DEVICE_FUNCTIONING)) {
- /*
- * Don't examine the children of the device only when the
- * device is neither present nor functional. See ACPI spec,
- * description of _STA for more information.
- */
- return (AE_CTRL_DEPTH);
- }
-
- /* Filter based on device HID & CID */
-
- if (info->hid != NULL) {
- status = acpi_ut_execute_HID(node, &hid);
- if (status == AE_NOT_FOUND) {
- return (AE_OK);
- } else if (ACPI_FAILURE(status)) {
- return (AE_CTRL_DEPTH);
- }
-
- if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) {
-
- /* Get the list of Compatible IDs */
-
- status = acpi_ut_execute_CID(node, &cid);
- if (status == AE_NOT_FOUND) {
- return (AE_OK);
- } else if (ACPI_FAILURE(status)) {
- return (AE_CTRL_DEPTH);
- }
-
- /* Walk the CID list */
-
- found = 0;
- for (i = 0; i < cid->count; i++) {
- if (ACPI_STRNCMP(cid->id[i].value, info->hid,
- sizeof(struct
- acpi_compatible_id)) ==
- 0) {
- found = 1;
- break;
- }
- }
- ACPI_FREE(cid);
- if (!found)
- return (AE_OK);
- }
- }
-
- status = info->user_function(obj_handle, nesting_level, info->context,
- return_value);
- return (status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_get_devices
- *
- * PARAMETERS: HID - HID to search for. Can be NULL.
- * user_function - Called when a matching object is found
- * Context - Passed to user function
- * return_value - Location where return value of
- * user_function is put if terminated early
- *
- * RETURNS Return value from the user_function if terminated early.
- * Otherwise, returns NULL.
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- * starting (and ending) at the object specified by start_handle.
- * The user_function is called whenever an object of type
- * Device is found. If the user function returns
- * a non-zero value, the search is terminated immediately and this
- * value is returned to the caller.
- *
- * This is a wrapper for walk_namespace, but the callback performs
- * additional filtering. Please see acpi_ns_get_device_callback.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_get_devices(const char *HID,
- acpi_walk_callback user_function,
- void *context, void **return_value)
-{
- acpi_status status;
- struct acpi_get_devices_info info;
-
- ACPI_FUNCTION_TRACE(acpi_get_devices);
-
- /* Parameter validation */
-
- if (!user_function) {
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
- /*
- * We're going to call their callback from OUR callback, so we need
- * to know what it is, and their context parameter.
- */
- info.hid = HID;
- info.context = context;
- info.user_function = user_function;
-
- /*
- * Lock the namespace around the walk.
- * The namespace will be unlocked/locked around each call
- * to the user function - since this function
- * must be allowed to make Acpi calls itself.
- */
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return_ACPI_STATUS(status);
- }
-
- status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
- acpi_ns_get_device_callback, &info,
- return_value);
-
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return_ACPI_STATUS(status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_devices)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_attach_data
- *
- * PARAMETERS: obj_handle - Namespace node
- * Handler - Handler for this attachment
- * Data - Pointer to data to be attached
- *
- * RETURN: Status
- *
- * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
- *
- ******************************************************************************/
-acpi_status
-acpi_attach_data(acpi_handle obj_handle,
- acpi_object_handler handler, void *data)
-{
- struct acpi_namespace_node *node;
- acpi_status status;
-
- /* Parameter validation */
-
- if (!obj_handle || !handler || !data) {
- return (AE_BAD_PARAMETER);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Convert and validate the handle */
-
- node = acpi_ns_map_handle_to_node(obj_handle);
- if (!node) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
-
- status = acpi_ns_attach_data(node, handler, data);
-
- unlock_and_exit:
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_attach_data)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_detach_data
- *
- * PARAMETERS: obj_handle - Namespace node handle
- * Handler - Handler used in call to acpi_attach_data
- *
- * RETURN: Status
- *
- * DESCRIPTION: Remove data that was previously attached to a node.
- *
- ******************************************************************************/
-acpi_status
-acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
-{
- struct acpi_namespace_node *node;
- acpi_status status;
-
- /* Parameter validation */
-
- if (!obj_handle || !handler) {
- return (AE_BAD_PARAMETER);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Convert and validate the handle */
-
- node = acpi_ns_map_handle_to_node(obj_handle);
- if (!node) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
-
- status = acpi_ns_detach_data(node, handler);
-
- unlock_and_exit:
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_detach_data)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_get_data
- *
- * PARAMETERS: obj_handle - Namespace node
- * Handler - Handler used in call to attach_data
- * Data - Where the data is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
- *
- ******************************************************************************/
-acpi_status
-acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
-{
- struct acpi_namespace_node *node;
- acpi_status status;
-
- /* Parameter validation */
-
- if (!obj_handle || !handler || !data) {
- return (AE_BAD_PARAMETER);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Convert and validate the handle */
-
- node = acpi_ns_map_handle_to_node(obj_handle);
- if (!node) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
-
- status = acpi_ns_get_attached_data(node, handler, data);
-
- unlock_and_exit:
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_data)
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
deleted file mode 100644
index 7d5bfa9e9fe..00000000000
--- a/drivers/acpi/namespace/nsxfname.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsxfname - Public interfaces to the ACPI subsystem
- * ACPI Namespace oriented interfaces
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsxfname")
-
-/******************************************************************************
- *
- * FUNCTION: acpi_get_handle
- *
- * PARAMETERS: Parent - Object to search under (search scope).
- * Pathname - Pointer to an asciiz string containing the
- * name
- * ret_handle - Where the return handle is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This routine will search for a caller specified name in the
- * name space. The caller can restrict the search region by
- * specifying a non NULL parent. The parent value is itself a
- * namespace handle.
- *
- ******************************************************************************/
-acpi_status
-acpi_get_handle(acpi_handle parent,
- acpi_string pathname, acpi_handle * ret_handle)
-{
- acpi_status status;
- struct acpi_namespace_node *node = NULL;
- struct acpi_namespace_node *prefix_node = NULL;
-
- ACPI_FUNCTION_ENTRY();
-
- /* Parameter Validation */
-
- if (!ret_handle || !pathname) {
- return (AE_BAD_PARAMETER);
- }
-
- /* Convert a parent handle to a prefix node */
-
- if (parent) {
- prefix_node = acpi_ns_map_handle_to_node(parent);
- if (!prefix_node) {
- return (AE_BAD_PARAMETER);
- }
- }
-
- /*
- * Valid cases are:
- * 1) Fully qualified pathname
- * 2) Parent + Relative pathname
- *
- * Error for <null Parent + relative path>
- */
- if (acpi_ns_valid_root_prefix(pathname[0])) {
-
- /* Pathname is fully qualified (starts with '\') */
-
- /* Special case for root-only, since we can't search for it */
-
- if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
- *ret_handle =
- acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
- return (AE_OK);
- }
- } else if (!prefix_node) {
-
- /* Relative path with null prefix is disallowed */
-
- return (AE_BAD_PARAMETER);
- }
-
- /* Find the Node and convert to a handle */
-
- status =
- acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
- if (ACPI_SUCCESS(status)) {
- *ret_handle = acpi_ns_convert_entry_to_handle(node);
- }
-
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_handle)
-
-/******************************************************************************
- *
- * FUNCTION: acpi_get_name
- *
- * PARAMETERS: Handle - Handle to be converted to a pathname
- * name_type - Full pathname or single segment
- * Buffer - Buffer for returned path
- *
- * RETURN: Pointer to a string containing the fully qualified Name.
- *
- * DESCRIPTION: This routine returns the fully qualified name associated with
- * the Handle parameter. This and the acpi_pathname_to_handle are
- * complementary functions.
- *
- ******************************************************************************/
-acpi_status
-acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
-{
- acpi_status status;
- struct acpi_namespace_node *node;
-
- /* Parameter validation */
-
- if (name_type > ACPI_NAME_TYPE_MAX) {
- return (AE_BAD_PARAMETER);
- }
-
- status = acpi_ut_validate_buffer(buffer);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- if (name_type == ACPI_FULL_PATHNAME) {
-
- /* Get the full pathname (From the namespace root) */
-
- status = acpi_ns_handle_to_pathname(handle, buffer);
- return (status);
- }
-
- /*
- * Wants the single segment ACPI name.
- * Validate handle and convert to a namespace Node
- */
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- node = acpi_ns_map_handle_to_node(handle);
- if (!node) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
- if (ACPI_FAILURE(status)) {
- goto unlock_and_exit;
- }
-
- /* Just copy the ACPI name from the Node and zero terminate it */
-
- ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node),
- ACPI_NAME_SIZE);
- ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
- status = AE_OK;
-
- unlock_and_exit:
-
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_name)
-
-/******************************************************************************
- *
- * FUNCTION: acpi_get_object_info
- *
- * PARAMETERS: Handle - Object Handle
- * Buffer - Where the info is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Returns information about an object as gleaned from the
- * namespace node and possibly by running several standard
- * control methods (Such as in the case of a device.)
- *
- ******************************************************************************/
-acpi_status
-acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
-{
- acpi_status status;
- struct acpi_namespace_node *node;
- struct acpi_device_info *info;
- struct acpi_device_info *return_info;
- struct acpi_compatible_id_list *cid_list = NULL;
- acpi_size size;
-
- /* Parameter validation */
-
- if (!handle || !buffer) {
- return (AE_BAD_PARAMETER);
- }
-
- status = acpi_ut_validate_buffer(buffer);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_device_info));
- if (!info) {
- return (AE_NO_MEMORY);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- goto cleanup;
- }
-
- node = acpi_ns_map_handle_to_node(handle);
- if (!node) {
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- status = AE_BAD_PARAMETER;
- goto cleanup;
- }
-
- /* Init return structure */
-
- size = sizeof(struct acpi_device_info);
-
- info->type = node->type;
- info->name = node->name.integer;
- info->valid = 0;
-
- if (node->type == ACPI_TYPE_METHOD) {
- info->param_count = node->object->method.param_count;
- }
-
- status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- goto cleanup;
- }
-
- /* If not a device, we are all done */
-
- if (info->type == ACPI_TYPE_DEVICE) {
- /*
- * Get extra info for ACPI Devices objects only:
- * Run the Device _HID, _UID, _CID, _STA, _ADR and _sx_d methods.
- *
- * Note: none of these methods are required, so they may or may
- * not be present for this device. The Info->Valid bitfield is used
- * to indicate which methods were found and ran successfully.
- */
-
- /* Execute the Device._HID method */
-
- status = acpi_ut_execute_HID(node, &info->hardware_id);
- if (ACPI_SUCCESS(status)) {
- info->valid |= ACPI_VALID_HID;
- }
-
- /* Execute the Device._UID method */
-
- status = acpi_ut_execute_UID(node, &info->unique_id);
- if (ACPI_SUCCESS(status)) {
- info->valid |= ACPI_VALID_UID;
- }
-
- /* Execute the Device._CID method */
-
- status = acpi_ut_execute_CID(node, &cid_list);
- if (ACPI_SUCCESS(status)) {
- size += cid_list->size;
- info->valid |= ACPI_VALID_CID;
- }
-
- /* Execute the Device._STA method */
-
- status = acpi_ut_execute_STA(node, &info->current_status);
- if (ACPI_SUCCESS(status)) {
- info->valid |= ACPI_VALID_STA;
- }
-
- /* Execute the Device._ADR method */
-
- status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node,
- &info->address);
- if (ACPI_SUCCESS(status)) {
- info->valid |= ACPI_VALID_ADR;
- }
-
- /* Execute the Device._sx_d methods */
-
- status = acpi_ut_execute_sxds(node, info->highest_dstates);
- if (ACPI_SUCCESS(status)) {
- info->valid |= ACPI_VALID_SXDS;
- }
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- status = acpi_ut_initialize_buffer(buffer, size);
- if (ACPI_FAILURE(status)) {
- goto cleanup;
- }
-
- /* Populate the return buffer */
-
- return_info = buffer->pointer;
- ACPI_MEMCPY(return_info, info, sizeof(struct acpi_device_info));
-
- if (cid_list) {
- ACPI_MEMCPY(&return_info->compatibility_id, cid_list,
- cid_list->size);
- }
-
- cleanup:
- ACPI_FREE(info);
- if (cid_list) {
- ACPI_FREE(cid_list);
- }
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_object_info)
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
deleted file mode 100644
index 80e6322d59c..00000000000
--- a/drivers/acpi/namespace/nsxfobj.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
- * ACPI Object oriented interfaces
- *
- ******************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
-ACPI_MODULE_NAME("nsxfobj")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_get_id
- *
- * PARAMETERS: Handle - Handle of object whose id is desired
- * ret_id - Where the id will be placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: This routine returns the owner id associated with a handle
- *
- ******************************************************************************/
-acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
-{
- struct acpi_namespace_node *node;
- acpi_status status;
-
- /* Parameter Validation */
-
- if (!ret_id) {
- return (AE_BAD_PARAMETER);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Convert and validate the handle */
-
- node = acpi_ns_map_handle_to_node(handle);
- if (!node) {
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (AE_BAD_PARAMETER);
- }
-
- *ret_id = node->owner_id;
-
- status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_id)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_get_type
- *
- * PARAMETERS: Handle - Handle of object whose type is desired
- * ret_type - Where the type will be placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: This routine returns the type associatd with a particular handle
- *
- ******************************************************************************/
-acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type)
-{
- struct acpi_namespace_node *node;
- acpi_status status;
-
- /* Parameter Validation */
-
- if (!ret_type) {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * Special case for the predefined Root Node
- * (return type ANY)
- */
- if (handle == ACPI_ROOT_OBJECT) {
- *ret_type = ACPI_TYPE_ANY;
- return (AE_OK);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Convert and validate the handle */
-
- node = acpi_ns_map_handle_to_node(handle);
- if (!node) {
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (AE_BAD_PARAMETER);
- }
-
- *ret_type = node->type;
-
- status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_type)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_get_parent
- *
- * PARAMETERS: Handle - Handle of object whose parent is desired
- * ret_handle - Where the parent handle will be placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: Returns a handle to the parent of the object represented by
- * Handle.
- *
- ******************************************************************************/
-acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
-{
- struct acpi_namespace_node *node;
- acpi_status status;
-
- if (!ret_handle) {
- return (AE_BAD_PARAMETER);
- }
-
- /* Special case for the predefined Root Node (no parent) */
-
- if (handle == ACPI_ROOT_OBJECT) {
- return (AE_NULL_ENTRY);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Convert and validate the handle */
-
- node = acpi_ns_map_handle_to_node(handle);
- if (!node) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
-
- /* Get the parent entry */
-
- *ret_handle =
- acpi_ns_convert_entry_to_handle(acpi_ns_get_parent_node(node));
-
- /* Return exception if parent is null */
-
- if (!acpi_ns_get_parent_node(node)) {
- status = AE_NULL_ENTRY;
- }
-
- unlock_and_exit:
-
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_parent)
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_get_next_object
- *
- * PARAMETERS: Type - Type of object to be searched for
- * Parent - Parent object whose children we are getting
- * last_child - Previous child that was found.
- * The NEXT child will be returned
- * ret_handle - Where handle to the next object is placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: Return the next peer object within the namespace. If Handle is
- * valid, Scope is ignored. Otherwise, the first object within
- * Scope is returned.
- *
- ******************************************************************************/
-acpi_status
-acpi_get_next_object(acpi_object_type type,
- acpi_handle parent,
- acpi_handle child, acpi_handle * ret_handle)
-{
- acpi_status status;
- struct acpi_namespace_node *node;
- struct acpi_namespace_node *parent_node = NULL;
- struct acpi_namespace_node *child_node = NULL;
-
- /* Parameter validation */
-
- if (type > ACPI_TYPE_EXTERNAL_MAX) {
- return (AE_BAD_PARAMETER);
- }
-
- status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* If null handle, use the parent */
-
- if (!child) {
-
- /* Start search at the beginning of the specified scope */
-
- parent_node = acpi_ns_map_handle_to_node(parent);
- if (!parent_node) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
- } else {
- /* Non-null handle, ignore the parent */
- /* Convert and validate the handle */
-
- child_node = acpi_ns_map_handle_to_node(child);
- if (!child_node) {
- status = AE_BAD_PARAMETER;
- goto unlock_and_exit;
- }
- }
-
- /* Internal function does the real work */
-
- node = acpi_ns_get_next_node(type, parent_node, child_node);
- if (!node) {
- status = AE_NOT_FOUND;
- goto unlock_and_exit;
- }
-
- if (ret_handle) {
- *ret_handle = acpi_ns_convert_entry_to_handle(node);
- }
-
- unlock_and_exit:
-
- (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
- return (status);
-}
-
-ACPI_EXPORT_SYMBOL(acpi_get_next_object)