X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Facpi%2Fparser%2Fpswalk.c;h=a84a547a0f1b469706cff58935750ed4ec05db56;hb=16c70f8c1b54b61c3b951b6fb220df250fe09b32;hp=e04b1b73606b95dbe95fbcebef1b1c4ff81d8687;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c index e04b1b736..a84a547a0 100644 --- a/drivers/acpi/parser/pswalk.c +++ b/drivers/acpi/parser/pswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,199 +41,11 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include -#include #define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("pswalk") - - -/******************************************************************************* - * - * FUNCTION: acpi_ps_get_next_walk_op - * - * PARAMETERS: walk_state - Current state of the walk - * Op - Current Op to be walked - * ascending_callback - Procedure called when Op is complete - * - * RETURN: Status - * - * DESCRIPTION: Get the next Op in a walk of the parse tree. - * - ******************************************************************************/ - -acpi_status -acpi_ps_get_next_walk_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - acpi_parse_upwards ascending_callback) -{ - union acpi_parse_object *next; - union acpi_parse_object *parent; - union acpi_parse_object *grand_parent; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ps_get_next_walk_op", op); - - - /* Check for a argument only if we are descending in the tree */ - - if (walk_state->next_op_info != ACPI_NEXT_OP_UPWARD) { - /* Look for an argument or child of the current op */ - - next = acpi_ps_get_arg (op, 0); - if (next) { - /* Still going downward in tree (Op is not completed yet) */ - - walk_state->prev_op = op; - walk_state->next_op = next; - walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD; - - return_ACPI_STATUS (AE_OK); - } - - /* - * No more children, this Op is complete. Save Next and Parent - * in case the Op object gets deleted by the callback routine - */ - next = op->common.next; - parent = op->common.parent; - - walk_state->op = op; - walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); - walk_state->opcode = op->common.aml_opcode; - - status = ascending_callback (walk_state); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (op == walk_state->origin) { - /* Reached the point of origin, the walk is complete */ - - walk_state->prev_op = op; - walk_state->next_op = NULL; - - return_ACPI_STATUS (status); - } - - /* - * Check for a sibling to the current op. A sibling means - * we are still going "downward" in the tree. - */ - if (next) { - /* There is a sibling, it will be next */ - - walk_state->prev_op = op; - walk_state->next_op = next; - walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD; - - /* Continue downward */ - - return_ACPI_STATUS (status); - } - - /* - * Drop into the loop below because we are moving upwards in - * the tree - */ - } - else { - /* - * We are resuming a walk, and we were (are) going upward in the tree. - * So, we want to drop into the parent loop below. - */ - parent = op; - } - - /* - * Look for a sibling of the current Op's parent - * Continue moving up the tree until we find a node that has not been - * visited, or we get back to where we started. - */ - while (parent) { - /* We are moving up the tree, therefore this parent Op is complete */ - - grand_parent = parent->common.parent; - next = parent->common.next; - - walk_state->op = parent; - walk_state->op_info = acpi_ps_get_opcode_info (parent->common.aml_opcode); - walk_state->opcode = parent->common.aml_opcode; - - status = ascending_callback (walk_state); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (parent == walk_state->origin) { - /* Reached the point of origin, the walk is complete */ - - walk_state->prev_op = parent; - walk_state->next_op = NULL; - - return_ACPI_STATUS (status); - } - - /* - * If there is a sibling to this parent (it is not the starting point - * Op), then we will visit it. - */ - if (next) { - /* found sibling of parent */ - - walk_state->prev_op = parent; - walk_state->next_op = next; - walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD; - - return_ACPI_STATUS (status); - } - - /* No siblings, no errors, just move up one more level in the tree */ - - op = parent; - parent = grand_parent; - walk_state->prev_op = op; - } - - - /* - * Got all the way to the top of the tree, we must be done! - * However, the code should have terminated in the loop above - */ - walk_state->next_op = NULL; - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: acpi_ps_delete_completed_op - * - * PARAMETERS: State - Walk state - * Op - Completed op - * - * RETURN: AE_OK - * - * DESCRIPTION: Callback function for acpi_ps_get_next_walk_op(). Used during - * acpi_ps_delete_parse tree to delete Op objects when all sub-objects - * have been visited (and deleted.) - * - ******************************************************************************/ - -acpi_status -acpi_ps_delete_completed_op ( - struct acpi_walk_state *walk_state) -{ - - acpi_ps_free_op (walk_state->op); - return (AE_OK); -} - +ACPI_MODULE_NAME("pswalk") /******************************************************************************* * @@ -246,62 +58,52 @@ acpi_ps_delete_completed_op ( * DESCRIPTION: Delete a portion of or an entire parse tree. * ******************************************************************************/ - -void -acpi_ps_delete_parse_tree ( - union acpi_parse_object *subtree_root) +void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root) { - struct acpi_walk_state *walk_state; - struct acpi_thread_state *thread; - acpi_status status; + union acpi_parse_object *op = subtree_root; + union acpi_parse_object *next = NULL; + union acpi_parse_object *parent = NULL; + ACPI_FUNCTION_TRACE_PTR(ps_delete_parse_tree, subtree_root); - ACPI_FUNCTION_TRACE_PTR ("ps_delete_parse_tree", subtree_root); + /* Visit all nodes in the subtree */ + while (op) { - if (!subtree_root) { - return_VOID; - } + /* Check if we are not ascending */ - /* Create and initialize a new walk list */ + if (op != parent) { - thread = acpi_ut_create_thread_state (); - if (!thread) { - return_VOID; - } + /* Look for an argument or child of the current op */ - walk_state = acpi_ds_create_walk_state (0, NULL, NULL, thread); - if (!walk_state) { - return_VOID; - } + next = acpi_ps_get_arg(op, 0); + if (next) { - walk_state->parse_flags = 0; - walk_state->descending_callback = NULL; - walk_state->ascending_callback = NULL; + /* Still going downward in tree (Op is not completed yet) */ - walk_state->origin = subtree_root; - walk_state->next_op = subtree_root; + op = next; + continue; + } + } - /* Head downward in the tree */ + /* No more children, this Op is complete. */ - walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD; + next = op->common.next; + parent = op->common.parent; - /* Visit all nodes in the subtree */ + acpi_ps_free_op(op); - while (walk_state->next_op) { - status = acpi_ps_get_next_walk_op (walk_state, walk_state->next_op, - acpi_ps_delete_completed_op); - if (ACPI_FAILURE (status)) { - break; + /* If we are back to the starting point, the walk is complete. */ + + if (op == subtree_root) { + return_VOID; + } + if (next) { + op = next; + } else { + op = parent; } } - /* We are done with this walk */ - - acpi_ut_delete_generic_state (ACPI_CAST_PTR (union acpi_generic_state, thread)); - acpi_ds_delete_walk_state (walk_state); - return_VOID; } - -