vserver 1.9.5.x5
[linux-2.6.git] / drivers / acpi / namespace / nsinit.c
index c8e9317..4a46b38 100644 (file)
@@ -5,7 +5,7 @@
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2004, R. Byron Moore
+ * Copyright (C) 2000 - 2005, R. Byron Moore
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -77,7 +77,8 @@ acpi_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:"));
+       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+               "Completing Region/Field/Buffer/Package initialization:"));
 
        /* Set all init info to zero */
 
@@ -142,14 +143,15 @@ acpi_ns_initialize_devices (
        info.num_STA = 0;
        info.num_INI = 0;
 
-       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Executing all Device _STA and_INI methods:"));
+       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+               "Executing all Device _STA and_INI methods:"));
 
        status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
 
-       /* Walk namespace for all objects of type Device or Processor */
+       /* Walk namespace for all objects */
 
        status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
                          ACPI_UINT32_MAX, TRUE, acpi_ns_init_one_device, &info, NULL);
@@ -257,8 +259,8 @@ acpi_ns_init_one_object (
        }
 
        /*
-        * Each of these types can contain executable AML code within
-        * the declaration.
+        * Each of these types can contain executable AML code within the
+        * declaration.
         */
        switch (type) {
        case ACPI_TYPE_REGION:
@@ -267,21 +269,18 @@ acpi_ns_init_one_object (
                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_BUFFER:
 
                info->buffer_init++;
                status = acpi_ds_get_buffer_arguments (obj_desc);
                break;
 
-
        case ACPI_TYPE_PACKAGE:
 
                info->package_init++;
@@ -301,15 +300,17 @@ acpi_ns_init_one_object (
                                acpi_format_exception (status)));
        }
 
-       /* Print a dot for each object unless we are going to print the entire pathname */
-
+       /*
+        * 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.
+        * 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);
@@ -337,29 +338,34 @@ acpi_ns_init_one_device (
        void                            *context,
        void                            **return_value)
 {
-       acpi_status                     status;
-       struct acpi_namespace_node     *node;
-       u32                             flags;
        struct acpi_device_walk_info   *info = (struct acpi_device_walk_info *) context;
+       struct acpi_parameter_info      pinfo;
+       u32                             flags;
+       acpi_status                     status;
 
 
        ACPI_FUNCTION_TRACE ("ns_init_one_device");
 
 
-       node = acpi_ns_map_handle_to_node (obj_handle);
-       if (!node) {
+       pinfo.parameters = NULL;
+       pinfo.parameter_type = ACPI_PARAM_ARGS;
+
+       pinfo.node = acpi_ns_map_handle_to_node (obj_handle);
+       if (!pinfo.node) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
        /*
-        * We will run _STA/_INI on Devices and Processors only
+        * We will run _STA/_INI on Devices, Processors and thermal_zones only
         */
-       if ((node->type != ACPI_TYPE_DEVICE) &&
-               (node->type != ACPI_TYPE_PROCESSOR)) {
+       if ((pinfo.node->type != ACPI_TYPE_DEVICE)      &&
+               (pinfo.node->type != ACPI_TYPE_PROCESSOR)   &&
+               (pinfo.node->type != ACPI_TYPE_THERMAL)) {
                return_ACPI_STATUS (AE_OK);
        }
 
-       if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && (!(acpi_dbg_level & ACPI_LV_INFO))) {
+       if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
+               (!(acpi_dbg_level & ACPI_LV_INFO))) {
                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
        }
 
@@ -368,17 +374,17 @@ acpi_ns_init_one_device (
        /*
         * Run _STA to determine if we can run _INI on the device.
         */
-       ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, node, "_STA"));
-       status = acpi_ut_execute_STA (node, &flags);
+       ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, pinfo.node, "_STA"));
+       status = acpi_ut_execute_STA (pinfo.node, &flags);
 
        if (ACPI_FAILURE (status)) {
-               if (node->type == ACPI_TYPE_DEVICE) {
+               if (pinfo.node->type == ACPI_TYPE_DEVICE) {
                        /* Ignore error and move on to next device */
 
                        return_ACPI_STATUS (AE_OK);
                }
 
-               /* _STA is not required for Processor objects */
+               /* _STA is not required for Processor or thermal_zone objects */
        }
        else {
                info->num_STA++;
@@ -393,27 +399,33 @@ acpi_ns_init_one_device (
        /*
         * The device is present. Run _INI.
         */
-       ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, obj_handle, "_INI"));
-       status = acpi_ns_evaluate_relative (obj_handle, "_INI", NULL, NULL);
+       ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, pinfo.node, "_INI"));
+       status = acpi_ns_evaluate_relative ("_INI", &pinfo);
        if (ACPI_FAILURE (status)) {
                /* No _INI (AE_NOT_FOUND) means device requires no initialization */
 
                if (status != AE_NOT_FOUND) {
                        /* Ignore error and move on to next device */
 
-       #ifdef ACPI_DEBUG_OUTPUT
-                       char                *scope_name = acpi_ns_get_external_pathname (obj_handle);
+#ifdef ACPI_DEBUG_OUTPUT
+                       char                *scope_name = acpi_ns_get_external_pathname (pinfo.node);
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n",
                                        scope_name, acpi_format_exception (status)));
 
                        ACPI_MEM_FREE (scope_name);
-       #endif
+#endif
                }
 
                status = AE_OK;
        }
        else {
+               /* Delete any return object (especially if implicit_return is enabled) */
+
+               if (pinfo.return_object) {
+                       acpi_ut_remove_reference (pinfo.return_object);
+               }
+
                /* Count of successful INIs */
 
                info->num_INI++;
@@ -422,9 +434,8 @@ acpi_ns_init_one_device (
        if (acpi_gbl_init_handler) {
                /* External initialization handler is present, call it */
 
-               status = acpi_gbl_init_handler (obj_handle, ACPI_INIT_DEVICE_INI);
+               status = acpi_gbl_init_handler (pinfo.node, ACPI_INIT_DEVICE_INI);
        }
 
-
        return_ACPI_STATUS (status);
 }