Pull sony into release branch
[pandora-kernel.git] / drivers / acpi / events / evregion.c
index 094a17e..e99f0c4 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
@@ -291,7 +291,6 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
                               u32 bit_width, acpi_integer * value)
 {
        acpi_status status;
-       acpi_status status2;
        acpi_adr_space_handler handler;
        acpi_adr_space_setup region_setup;
        union acpi_operand_object *handler_desc;
@@ -345,7 +344,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
                 * setup will potentially execute control methods
                 * (e.g., _REG method for this region)
                 */
-               acpi_ex_exit_interpreter();
+               acpi_ex_relinquish_interpreter();
 
                status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
                                      handler_desc->address_space.context,
@@ -353,10 +352,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
 
                /* Re-enter the interpreter */
 
-               status2 = acpi_ex_enter_interpreter();
-               if (ACPI_FAILURE(status2)) {
-                       return_ACPI_STATUS(status2);
-               }
+               acpi_ex_reacquire_interpreter();
 
                /* Check for failure of the Region Setup */
 
@@ -409,7 +405,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
                 * exit the interpreter because the handler *might* block -- we don't
                 * know what it will do, so we can't hold the lock on the intepreter.
                 */
-               acpi_ex_exit_interpreter();
+               acpi_ex_relinquish_interpreter();
        }
 
        /* Call the handler */
@@ -430,10 +426,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
                 * We just returned from a non-default handler, we must re-enter the
                 * interpreter
                 */
-               status2 = acpi_ex_enter_interpreter();
-               if (ACPI_FAILURE(status2)) {
-                       return_ACPI_STATUS(status2);
-               }
+               acpi_ex_reacquire_interpreter();
        }
 
        return_ACPI_STATUS(status);
@@ -528,34 +521,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);