diff options
Diffstat (limited to 'drivers/acpi/utilities/utdelete.c')
-rw-r--r-- | drivers/acpi/utilities/utdelete.c | 140 |
1 files changed, 34 insertions, 106 deletions
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index bc5403022681..eeafb324c504 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -435,35 +435,24 @@ acpi_ut_update_object_reference ( union acpi_operand_object *object, u16 action) { - acpi_status status; - u32 i; - union acpi_generic_state *state_list = NULL; - union acpi_generic_state *state; - union acpi_operand_object *tmp; - - ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); + acpi_status status = AE_OK; + union acpi_generic_state *state_list = NULL; + union acpi_operand_object *next_object = NULL; + union acpi_generic_state *state; + acpi_native_uint i; - /* Ignore a null object ptr */ - - if (!object) { - return_ACPI_STATUS (AE_OK); - } + ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); - /* Make sure that this isn't a namespace handle */ - if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Object %p is NS handle\n", object)); - return_ACPI_STATUS (AE_OK); - } + while (object) { + /* Make sure that this isn't a namespace handle */ - state = acpi_ut_create_update_state (object, action); - - while (state) { - object = state->update.object; - action = state->update.value; - acpi_ut_delete_generic_state (state); + if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", object)); + return_ACPI_STATUS (AE_OK); + } /* * All sub-objects must have their reference count incremented also. @@ -472,24 +461,14 @@ acpi_ut_update_object_reference ( switch (ACPI_GET_OBJECT_TYPE (object)) { case ACPI_TYPE_DEVICE: - tmp = object->device.system_notify; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->device.system_notify = NULL; - acpi_ut_update_ref_count (tmp, action); - - tmp = object->device.device_notify; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->device.device_notify = NULL; - acpi_ut_update_ref_count (tmp, action); - + acpi_ut_update_ref_count (object->device.system_notify, action); + acpi_ut_update_ref_count (object->device.device_notify, action); break; - case ACPI_TYPE_PACKAGE: - /* - * We must update all the sub-objects of the package - * (Each of whom may have their own sub-objects, etc. + * We must update all the sub-objects of the package, + * each of whom may have their own sub-objects. */ for (i = 0; i < object->package.count; i++) { /* @@ -502,111 +481,52 @@ acpi_ut_update_object_reference ( if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->package.elements[i]; - if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->package.elements[i] = NULL; } break; - case ACPI_TYPE_BUFFER_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->buffer_field.buffer_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->buffer_field.buffer_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->buffer_field.buffer_obj = NULL; + next_object = object->buffer_field.buffer_obj; break; - case ACPI_TYPE_LOCAL_REGION_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->field.region_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->field.region_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->field.region_obj = NULL; - break; - + next_object = object->field.region_obj; + break; case ACPI_TYPE_LOCAL_BANK_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->bank_field.bank_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->bank_field.bank_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->bank_field.bank_obj = NULL; - + next_object = object->bank_field.bank_obj; status = acpi_ut_create_update_state_and_push ( object->bank_field.region_obj, action, &state_list); if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->bank_field.region_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->bank_field.region_obj = NULL; break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: - status = acpi_ut_create_update_state_and_push ( - object->index_field.index_obj, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } - - tmp = object->index_field.index_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->index_field.index_obj = NULL; - + next_object = object->index_field.index_obj; status = acpi_ut_create_update_state_and_push ( object->index_field.data_obj, action, &state_list); if (ACPI_FAILURE (status)) { goto error_exit; } - - tmp = object->index_field.data_obj; - if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) - object->index_field.data_obj = NULL; break; - case ACPI_TYPE_LOCAL_REFERENCE: - /* * The target of an Index (a package, string, or buffer) must track * changes to the ref count of the index. */ if (object->reference.opcode == AML_INDEX_OP) { - status = acpi_ut_create_update_state_and_push ( - object->reference.object, action, &state_list); - if (ACPI_FAILURE (status)) { - goto error_exit; - } + next_object = object->reference.object; } break; - case ACPI_TYPE_REGION: default: - - /* No subobjects */ - break; + break;/* No subobjects */ } /* @@ -615,15 +535,23 @@ acpi_ut_update_object_reference ( * main object to be deleted. */ acpi_ut_update_ref_count (object, action); + object = NULL; /* Move on to the next object to be updated */ - state = acpi_ut_pop_generic_state (&state_list); + if (next_object) { + object = next_object; + next_object = NULL; + } + else if (state_list) { + state = acpi_ut_pop_generic_state (&state_list); + object = state->update.object; + acpi_ut_delete_generic_state (state); + } } return_ACPI_STATUS (AE_OK); - error_exit: ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", |