aboutsummaryrefslogtreecommitdiff
path: root/drivers/acpi/dispatcher/dsmethod.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/dispatcher/dsmethod.c')
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 9fc3f4c033e..e344c06ed33 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -58,12 +58,11 @@
*
* FUNCTION: acpi_ds_parse_method
*
- * PARAMETERS: obj_handle - Method node
+ * PARAMETERS: Node - Method node
*
* RETURN: Status
*
- * DESCRIPTION: Call the parser and parse the AML that is associated with the
- * method.
+ * DESCRIPTION: Parse the AML that is associated with the method.
*
* MUTEX: Assumes parser is locked
*
@@ -71,31 +70,28 @@
acpi_status
acpi_ds_parse_method (
- acpi_handle obj_handle)
+ struct acpi_namespace_node *node)
{
acpi_status status;
union acpi_operand_object *obj_desc;
union acpi_parse_object *op;
- struct acpi_namespace_node *node;
- acpi_owner_id owner_id;
struct acpi_walk_state *walk_state;
- ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", obj_handle);
+ ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", node);
/* Parameter Validation */
- if (!obj_handle) {
+ if (!node) {
return_ACPI_STATUS (AE_NULL_ENTRY);
}
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n",
- acpi_ut_get_node_name (obj_handle), obj_handle));
+ acpi_ut_get_node_name (node), node));
/* Extract the method object from the method Node */
- node = (struct acpi_namespace_node *) obj_handle;
obj_desc = acpi_ns_get_attached_object (node);
if (!obj_desc) {
return_ACPI_STATUS (AE_NULL_OBJECT);
@@ -132,14 +128,18 @@ acpi_ds_parse_method (
* objects (such as Operation Regions) can be created during the
* first pass parse.
*/
- owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
- obj_desc->method.owning_id = owner_id;
+ status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id);
+ if (ACPI_FAILURE (status)) {
+ goto cleanup;
+ }
/* Create and initialize a new walk state */
- walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL);
+ walk_state = acpi_ds_create_walk_state (
+ obj_desc->method.owner_id, NULL, NULL, NULL);
if (!walk_state) {
- return_ACPI_STATUS (AE_NO_MEMORY);
+ status = AE_NO_MEMORY;
+ goto cleanup2;
}
status = acpi_ds_init_aml_walk (walk_state, op, node,
@@ -147,7 +147,7 @@ acpi_ds_parse_method (
obj_desc->method.aml_length, NULL, 1);
if (ACPI_FAILURE (status)) {
acpi_ds_delete_walk_state (walk_state);
- return_ACPI_STATUS (status);
+ goto cleanup2;
}
/*
@@ -161,13 +161,25 @@ acpi_ds_parse_method (
*/
status = acpi_ps_parse_aml (walk_state);
if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
+ goto cleanup2;
}
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
- acpi_ut_get_node_name (obj_handle), obj_handle, op));
+ acpi_ut_get_node_name (node), node, op));
+
+ /*
+ * Delete the parse tree. We simply re-parse the method for every
+ * execution since there isn't much overhead (compared to keeping lots
+ * of parse trees around)
+ */
+ acpi_ns_delete_namespace_subtree (node);
+ acpi_ns_delete_namespace_by_owner (obj_desc->method.owner_id);
+
+cleanup2:
+ acpi_ut_release_owner_id (&obj_desc->method.owner_id);
+cleanup:
acpi_ps_delete_parse_tree (op);
return_ACPI_STATUS (status);
}
@@ -263,7 +275,7 @@ acpi_ds_call_control_method (
{
acpi_status status;
struct acpi_namespace_node *method_node;
- struct acpi_walk_state *next_walk_state;
+ struct acpi_walk_state *next_walk_state = NULL;
union acpi_operand_object *obj_desc;
struct acpi_parameter_info info;
u32 i;
@@ -287,20 +299,23 @@ acpi_ds_call_control_method (
return_ACPI_STATUS (AE_NULL_OBJECT);
}
- obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
+ status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id);
+ if (ACPI_FAILURE (status)) {
+ return_ACPI_STATUS (status);
+ }
/* Init for new method, wait on concurrency semaphore */
status = acpi_ds_begin_method_execution (method_node, obj_desc,
this_walk_state->method_node);
if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
+ goto cleanup;
}
if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {
/* 1) Parse: Create a new walk state for the preempting walk */
- next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
+ next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id,
op, obj_desc, NULL);
if (!next_walk_state) {
return_ACPI_STATUS (AE_NO_MEMORY);
@@ -330,7 +345,7 @@ acpi_ds_call_control_method (
/* 2) Execute: Create a new state for the preempting walk */
- next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
+ next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id,
NULL, obj_desc, thread);
if (!next_walk_state) {
status = AE_NO_MEMORY;
@@ -381,6 +396,7 @@ acpi_ds_call_control_method (
/* On error, we must delete the new walk state */
cleanup:
+ acpi_ut_release_owner_id (&obj_desc->method.owner_id);
if (next_walk_state && (next_walk_state->method_desc)) {
/* Decrement the thread count on the method parse tree */
@@ -552,8 +568,7 @@ acpi_ds_terminate_control_method (
*/
if ((walk_state->method_desc->method.concurrency == 1) &&
(!walk_state->method_desc->method.semaphore)) {
- status = acpi_os_create_semaphore (1,
- 1,
+ status = acpi_os_create_semaphore (1, 1,
&walk_state->method_desc->method.semaphore);
}
@@ -582,8 +597,10 @@ acpi_ds_terminate_control_method (
* Delete any namespace entries created anywhere else within
* the namespace
*/
- acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id);
+ acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id);
status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+ acpi_ut_release_owner_id (&walk_state->method_desc->method.owner_id);
+
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}