ACPICA: Restructure includes into public/private
[deliverable/linux.git] / drivers / acpi / namespace / nsaccess.c
index 57faf598bad8f2fe98055f34589f23a2c341d976..7954640e69cb36d15773a8d5c161e61550da0509 100644 (file)
@@ -5,7 +5,7 @@
  ******************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2007, R. Byron Moore
+ * Copyright (C) 2000 - 2008, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,6 +42,7 @@
  */
 
 #include <acpi/acpi.h>
+#include <acpi/accommon.h>
 #include <acpi/amlcode.h>
 #include <acpi/acnamesp.h>
 #include <acpi/acdispat.h>
@@ -165,11 +166,8 @@ acpi_status acpi_ns_root_initialize(void)
 
                                obj_desc->method.method_flags =
                                    AML_METHOD_INTERNAL_ONLY;
-
-#ifndef ACPI_DUMP_APP
                                obj_desc->method.implementation =
                                    acpi_ut_osi_implementation;
-#endif
 #endif
                                break;
 
@@ -208,8 +206,7 @@ acpi_status acpi_ns_root_initialize(void)
                                /* Special case for ACPI Global Lock */
 
                                if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
-                                       acpi_gbl_global_lock_mutex =
-                                           obj_desc->mutex.os_mutex;
+                                       acpi_gbl_global_lock_mutex = obj_desc;
 
                                        /* Create additional counting semaphore for global lock */
 
@@ -522,11 +519,11 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
        }
 
        /*
-        * Search namespace for each segment of the name.  Loop through and
+        * 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
+        * 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;
@@ -582,44 +579,72 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
                        return_ACPI_STATUS(status);
                }
 
-               /*
-                * 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 ((num_segments == 0) &&
-                   (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)));
+               /* 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;
+                               }
+                       }
                }
 
-               /*
-                * 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 see if it opens a scope.
-                */
-               if ((num_segments == 0) && (type == ACPI_TYPE_ANY)) {
-                       type = this_node->type;
+               /* 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 */
This page took 0.032941 seconds and 5 git commands to generate.