Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / acpi / namespace / nssearch.c
index 0e6dea2..d64b789 100644 (file)
@@ -5,7 +5,7 @@
  ******************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2005, R. Byron Moore
+ * Copyright (C) 2000 - 2006, R. Byron Moore
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
-
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
 
-
 #define _COMPONENT          ACPI_NAMESPACE
-        ACPI_MODULE_NAME    ("nssearch")
+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_node
  *
- * 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 Named obj is returned
+ * 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 Named obj is returned
  *
  * RETURN:      Status
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ns_search_node (
-       u32                             target_name,
-       struct acpi_namespace_node      *node,
-       acpi_object_type                type,
-       struct acpi_namespace_node      **return_node)
+acpi_ns_search_node(u32 target_name,
+                   struct acpi_namespace_node *node,
+                   acpi_object_type type,
+                   struct acpi_namespace_node **return_node)
 {
-       struct acpi_namespace_node      *next_node;
-
-
-       ACPI_FUNCTION_TRACE ("ns_search_node");
+       struct acpi_namespace_node *next_node;
 
+       ACPI_FUNCTION_TRACE("ns_search_node");
 
 #ifdef ACPI_DEBUG_OUTPUT
        if (ACPI_LV_NAMES & acpi_dbg_level) {
-               char                        *scope_name;
+               char *scope_name;
 
-               scope_name = acpi_ns_get_external_pathname (node);
+               scope_name = acpi_ns_get_external_pathname(node);
                if (scope_name) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-                               "Searching %s (%p) For [%4.4s] (%s)\n",
-                               scope_name, node, (char *) &target_name,
-                               acpi_ut_get_type_name (type)));
+                       ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
+                                         "Searching %s (%p) For [%4.4s] (%s)\n",
+                                         scope_name, node, ACPI_CAST_PTR(char,
+                                                                         &target_name),
+                                         acpi_ut_get_type_name(type)));
 
-                       ACPI_MEM_FREE (scope_name);
+                       ACPI_MEM_FREE(scope_name);
                }
        }
 #endif
@@ -117,20 +119,26 @@ acpi_ns_search_node (
                if (next_node->name.integer == target_name) {
                        /* Resolve a control method alias if any */
 
-                       if (acpi_ns_get_type (next_node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
-                               next_node = ACPI_CAST_PTR (struct acpi_namespace_node, next_node->object);
+                       if (acpi_ns_get_type(next_node) ==
+                           ACPI_TYPE_LOCAL_METHOD_ALIAS) {
+                               next_node =
+                                   ACPI_CAST_PTR(struct acpi_namespace_node,
+                                                 next_node->object);
                        }
 
                        /*
                         * Found matching entry.
                         */
-                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-                               "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
-                               (char *) &target_name, acpi_ut_get_type_name (next_node->type),
-                               next_node, acpi_ut_get_node_name (node), node));
+                       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(next_node->
+                                                               type),
+                                         next_node,
+                                         acpi_ut_get_node_name(node), node));
 
                        *return_node = next_node;
-                       return_ACPI_STATUS (AE_OK);
+                       return_ACPI_STATUS(AE_OK);
                }
 
                /*
@@ -150,23 +158,23 @@ acpi_ns_search_node (
 
        /* 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",
-               (char *) &target_name, acpi_ut_get_type_name (type),
-               acpi_ut_get_node_name (node), node, node->child));
+       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(node), node, node->child));
 
-       return_ACPI_STATUS (AE_NOT_FOUND);
+       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
+ * 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
  *
@@ -185,43 +193,42 @@ acpi_ns_search_node (
  ******************************************************************************/
 
 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_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_status status;
+       struct acpi_namespace_node *parent_node;
 
+       ACPI_FUNCTION_TRACE("ns_search_parent_tree");
 
-       ACPI_FUNCTION_TRACE ("ns_search_parent_tree");
-
-
-       parent_node = acpi_ns_get_parent_node (node);
+       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",
-                       (char *) &target_name));
-               return_ACPI_STATUS (AE_NOT_FOUND);
+               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",
-                       (char *) &target_name, acpi_ut_get_type_name (type)));
-               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), (char *) &target_name));
+       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
@@ -232,37 +239,36 @@ acpi_ns_search_parent_tree (
                 * 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_node (target_name, parent_node,
-                                 ACPI_TYPE_ANY, return_node);
-               if (ACPI_SUCCESS (status)) {
-                       return_ACPI_STATUS (status);
+               status = acpi_ns_search_node(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);
+               parent_node = acpi_ns_get_parent_node(parent_node);
        }
 
        /* Not found in parent tree */
 
-       return_ACPI_STATUS (AE_NOT_FOUND);
+       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
+ *              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_node         - Where the Node is returned
  *
  * RETURN:      Status
  *
@@ -277,52 +283,45 @@ acpi_ns_search_parent_tree (
  ******************************************************************************/
 
 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_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");
+       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_DEBUG_PRINT ((ACPI_DB_ERROR,
-                       "Null param: Node %p Name %X return_node %p\n",
-                       node, target_name, return_node));
-
-               ACPI_REPORT_ERROR (("ns_search_and_enter: Null parameter\n"));
-               return_ACPI_STATUS (AE_BAD_PARAMETER);
+               ACPI_ERROR((AE_INFO,
+                           "Null param: Node %p Name %X return_node %p",
+                           node, target_name, return_node));
+               return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
 
        /* Name must consist of printable characters */
 
-       if (!acpi_ut_valid_acpi_name (target_name)) {
-               ACPI_REPORT_ERROR (("ns_search_and_enter: Bad character in ACPI Name: %X\n",
-                       target_name));
-               return_ACPI_STATUS (AE_BAD_CHARACTER);
+       if (!acpi_ut_valid_acpi_name(target_name)) {
+               ACPI_ERROR((AE_INFO, "Bad character in ACPI Name: %X",
+                           target_name));
+               return_ACPI_STATUS(AE_BAD_CHARACTER);
        }
 
        /* Try to find the name in the namespace level specified by the caller */
 
        *return_node = ACPI_ENTRY_NOT_FOUND;
-       status = acpi_ns_search_node (target_name, node, type, return_node);
+       status = acpi_ns_search_node(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)) {
+               if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) {
                        status = AE_ALREADY_EXISTS;
                }
 
@@ -330,7 +329,7 @@ acpi_ns_search_and_enter (
                 * Either found it or there was an error
                 * -- finished either way
                 */
-               return_ACPI_STATUS (status);
+               return_ACPI_STATUS(status);
        }
 
        /*
@@ -342,14 +341,16 @@ acpi_ns_search_and_enter (
         * and during the execution phase.
         */
        if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) &&
-               (flags & ACPI_NS_SEARCH_PARENT)) {
+           (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);
+               status =
+                   acpi_ns_search_parent_tree(target_name, node, type,
+                                              return_node);
+               if (ACPI_SUCCESS(status)) {
+                       return_ACPI_STATUS(status);
                }
        }
 
@@ -357,25 +358,24 @@ acpi_ns_search_and_enter (
         * 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",
-                       (char *) &target_name, node));
+               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);
+               return_ACPI_STATUS(AE_NOT_FOUND);
        }
 
        /* Create the new named object */
 
-       new_node = acpi_ns_create_node (target_name);
+       new_node = acpi_ns_create_node(target_name);
        if (!new_node) {
-               return_ACPI_STATUS (AE_NO_MEMORY);
+               return_ACPI_STATUS(AE_NO_MEMORY);
        }
 
        /* Install the new object into the parent's list of children */
 
-       acpi_ns_install_node (walk_state, node, new_node, type);
+       acpi_ns_install_node(walk_state, node, new_node, type);
        *return_node = new_node;
 
-       return_ACPI_STATUS (AE_OK);
+       return_ACPI_STATUS(AE_OK);
 }
-