]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/events/evregion.c
Pull dock into release branch
[linux-2.6-omap-h63xx.git] / drivers / acpi / events / evregion.c
index edf9d2e1dff9106c330464e20cf4ee2863b4b4ce..96b0e84317482ed67d8ecdd493d678986cf1d6c9 100644 (file)
@@ -5,7 +5,7 @@
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2006, R. Byron Moore
+ * Copyright (C) 2000 - 2007, R. Byron Moore
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -193,8 +193,8 @@ acpi_status acpi_ev_initialize_op_regions(void)
 acpi_status
 acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
 {
-       struct acpi_parameter_info info;
-       union acpi_operand_object *params[3];
+       struct acpi_evaluate_info *info;
+       union acpi_operand_object *args[3];
        union acpi_operand_object *region_obj2;
        acpi_status status;
 
@@ -209,47 +209,60 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
                return_ACPI_STATUS(AE_OK);
        }
 
+       /* 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->prefix_node = region_obj2->extra.method_REG;
+       info->pathname = NULL;
+       info->parameters = args;
+       info->parameter_type = ACPI_PARAM_ARGS;
+       info->flags = ACPI_IGNORE_RETURN_VALUE;
+
        /*
         * The _REG method has two arguments:
         *
-        * Arg0, Integer: Operation region space ID
-        *          Same value as region_obj->Region.space_id
-        * Arg1, Integer: connection status
-        *          1 for connecting the handler,
-        *          0 for disconnecting the handler
-        *          Passed as a parameter
+        * Arg0 - Integer:
+        *  Operation region space ID Same value as region_obj->Region.space_id
+        *
+        * Arg1 - Integer:
+        *  connection status 1 for connecting the handler, 0 for disconnecting
+        *  the handler (Passed as a parameter)
         */
-       params[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
-       if (!params[0]) {
-               return_ACPI_STATUS(AE_NO_MEMORY);
+       args[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
+       if (!args[0]) {
+               status = AE_NO_MEMORY;
+               goto cleanup1;
        }
 
-       params[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
-       if (!params[1]) {
+       args[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
+       if (!args[1]) {
                status = AE_NO_MEMORY;
-               goto cleanup;
+               goto cleanup2;
        }
 
        /* Setup the parameter objects */
 
-       params[0]->integer.value = region_obj->region.space_id;
-       params[1]->integer.value = function;
-       params[2] = NULL;
-
-       info.node = region_obj2->extra.method_REG;
-       info.parameters = params;
-       info.parameter_type = ACPI_PARAM_ARGS;
+       args[0]->integer.value = region_obj->region.space_id;
+       args[1]->integer.value = function;
+       args[2] = NULL;
 
        /* Execute the method, no return value */
 
        ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
-                       (ACPI_TYPE_METHOD, info.node, NULL));
-       status = acpi_ns_evaluate_by_handle(&info);
+                       (ACPI_TYPE_METHOD, info->prefix_node, NULL));
+
+       status = acpi_ns_evaluate(info);
+       acpi_ut_remove_reference(args[1]);
 
-       acpi_ut_remove_reference(params[1]);
+      cleanup2:
+       acpi_ut_remove_reference(args[0]);
 
-      cleanup:
-       acpi_ut_remove_reference(params[0]);
+      cleanup1:
+       ACPI_FREE(info);
        return_ACPI_STATUS(status);
 }
 
@@ -515,34 +528,40 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
                                }
                        }
 
-                       /* Call the setup handler with the deactivate notification */
+                       /*
+                        * If the region has been activated, call the setup handler
+                        * with the deactivate notification
+                        */
+                       if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
+                               region_setup = handler_obj->address_space.setup;
+                               status =
+                                   region_setup(region_obj,
+                                                ACPI_REGION_DEACTIVATE,
+                                                handler_obj->address_space.
+                                                context, region_context);
 
-                       region_setup = handler_obj->address_space.setup;
-                       status =
-                           region_setup(region_obj, ACPI_REGION_DEACTIVATE,
-                                        handler_obj->address_space.context,
-                                        region_context);
+                               /* Init routine may fail, Just ignore errors */
 
-                       /* Init routine may fail, Just ignore errors */
+                               if (ACPI_FAILURE(status)) {
+                                       ACPI_EXCEPTION((AE_INFO, status,
+                                                       "from region handler - deactivate, [%s]",
+                                                       acpi_ut_get_region_name
+                                                       (region_obj->region.
+                                                        space_id)));
+                               }
 
-                       if (ACPI_FAILURE(status)) {
-                               ACPI_EXCEPTION((AE_INFO, status,
-                                               "from region init, [%s]",
-                                               acpi_ut_get_region_name
-                                               (region_obj->region.space_id)));
+                               region_obj->region.flags &=
+                                   ~(AOPOBJ_SETUP_COMPLETE);
                        }
 
-                       region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
-
                        /*
                         * Remove handler reference in the region
                         *
-                        * NOTE: this doesn't mean that the region goes away
-                        * The region is just inaccessible as indicated to
-                        * the _REG method
+                        * NOTE: this doesn't mean that the region goes away, the region
+                        * is just inaccessible as indicated to the _REG method
                         *
-                        * If the region is on the handler's list
-                        * this better be the region's handler
+                        * If the region is on the handler's list, this must be the
+                        * region's handler
                         */
                        region_obj->region.handler = NULL;
                        acpi_ut_remove_reference(handler_obj);