diff options
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r-- | drivers/acpi/utilities/utcopy.c | 19 | ||||
-rw-r--r-- | drivers/acpi/utilities/utglobal.c | 4 | ||||
-rw-r--r-- | drivers/acpi/utilities/utmisc.c | 34 | ||||
-rw-r--r-- | drivers/acpi/utilities/utresrc.c | 19 |
4 files changed, 49 insertions, 27 deletions
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 5442b32..568df9e 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -398,14 +398,17 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object, * Build a simple object (no nested objects) */ status = acpi_ut_copy_isimple_to_esimple(internal_object, - (union acpi_object *) - ret_buffer->pointer, - ((u8 *) ret_buffer-> - pointer + - ACPI_ROUND_UP_TO_NATIVE_WORD - (sizeof - (union - acpi_object))), + ACPI_CAST_PTR(union + acpi_object, + ret_buffer-> + pointer), + ACPI_ADD_PTR(u8, + ret_buffer-> + pointer, + ACPI_ROUND_UP_TO_NATIVE_WORD + (sizeof + (union + acpi_object))), &ret_buffer->length); /* * build simple does not include the object size in the length diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 413e1dd..d6813d8 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -638,7 +638,7 @@ char *acpi_ut_get_node_name(void *object) /* Name must be a valid ACPI name */ - if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) { + if (!acpi_ut_valid_acpi_name(node->name.integer)) { return ("????"); } @@ -831,6 +831,7 @@ void acpi_ut_init_globals(void) acpi_gbl_ps_find_count = 0; acpi_gbl_acpi_hardware_present = TRUE; acpi_gbl_owner_id_mask = 0; + acpi_gbl_last_owner_id = 0; acpi_gbl_trace_method_name = 0; acpi_gbl_trace_dbg_level = 0; acpi_gbl_trace_dbg_layer = 0; @@ -845,7 +846,6 @@ void acpi_ut_init_globals(void) /* Namespace */ acpi_gbl_root_node = NULL; - acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 2a9110c..89efba7 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -63,6 +63,7 @@ ACPI_MODULE_NAME("utmisc") acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) { acpi_native_uint i; + acpi_native_uint j; acpi_status status; ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); @@ -82,29 +83,46 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) return_ACPI_STATUS(status); } - /* Find a free owner ID */ + /* + * Find a free owner ID, cycle through all possible IDs on repeated + * allocations. Note: Index for next possible ID is equal to the value + * of the last allocated ID. + */ + for (i = 0, j = acpi_gbl_last_owner_id; i < 32; i++, j++) { + if (j >= 32) { + j = 0; /* Wraparound to ID start */ + } + + if (!(acpi_gbl_owner_id_mask & (1 << j))) { + /* + * Found a free ID. The actual ID is the bit index plus one, + * making zero an invalid Owner ID. Save this as the last ID + * allocated and update the global ID mask. + */ + acpi_gbl_last_owner_id = (acpi_owner_id) (j + 1); + *owner_id = acpi_gbl_last_owner_id; - for (i = 0; i < 32; i++) { - if (!(acpi_gbl_owner_id_mask & (1 << i))) { ACPI_DEBUG_PRINT((ACPI_DB_VALUES, "Current owner_id mask: %8.8X New ID: %2.2X\n", acpi_gbl_owner_id_mask, - (unsigned int)(i + 1))); + (unsigned int) + acpi_gbl_last_owner_id)); - acpi_gbl_owner_id_mask |= (1 << i); - *owner_id = (acpi_owner_id) (i + 1); + acpi_gbl_owner_id_mask |= (1 << j); goto exit; } } /* - * If we are here, all owner_ids have been allocated. This probably should + * All owner_ids have been allocated. This typically should * not happen since the IDs are reused after deallocation. The IDs are * allocated upon table load (one per table) and method execution, and * they are released when a table is unloaded or a method completes * execution. + * + * If this error happens, there may be very deep nesting of invoked control + * methods, or there may be a bug where the IDs are not released. */ - *owner_id = 0; status = AE_OWNER_ID_LIMIT; ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c index 07a314c..6c0ce7b 100644 --- a/drivers/acpi/utilities/utresrc.c +++ b/drivers/acpi/utilities/utresrc.c @@ -157,7 +157,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) /* * 1) Validate the resource_type field (Byte 0) */ - resource_type = *((u8 *) aml); + resource_type = ACPI_GET8(aml); /* * Byte 0 contains the descriptor name (Resource Type) @@ -266,14 +266,14 @@ u8 acpi_ut_get_resource_type(void *aml) * Byte 0 contains the descriptor name (Resource Type) * Examine the large/small bit in the resource header */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { /* Large Resource Type -- bits 6:0 contain the name */ - return (*((u8 *) aml)); + return (ACPI_GET8(aml)); } else { /* Small Resource Type -- bits 6:3 contain the name */ - return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); } } @@ -301,15 +301,15 @@ u16 acpi_ut_get_resource_length(void *aml) * Byte 0 contains the descriptor name (Resource Type) * Examine the large/small bit in the resource header */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { /* Large Resource type -- bytes 1-2 contain the 16-bit length */ - ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); + ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1)); } else { /* Small Resource type -- bits 2:0 of byte 0 contain the length */ - resource_length = (u16) (*((u8 *) aml) & + resource_length = (u16) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); } @@ -334,7 +334,7 @@ u8 acpi_ut_get_resource_header_length(void *aml) /* Examine the large/small bit in the resource header */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { return (sizeof(struct aml_resource_large_header)); } else { return (sizeof(struct aml_resource_small_header)); @@ -372,8 +372,9 @@ u32 acpi_ut_get_descriptor_length(void *aml) * FUNCTION: acpi_ut_get_resource_end_tag * * PARAMETERS: obj_desc - The resource template buffer object + * end_tag - Where the pointer to the end_tag is returned * - * RETURN: Pointer to the end tag + * RETURN: Status, pointer to the end tag * * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template * |