From 4bbfb85da27c27e9cc9a7fef4bd75df6361152ff Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Feb 2009 14:17:29 +0800 Subject: ACPICA: Add error check to debug object dump routine Add check for invalid handle in acpi_ns_dump_one_object. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/nsdump.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c index 0da33c8e9ba..e96d37a596b 100644 --- a/drivers/acpi/acpica/nsdump.c +++ b/drivers/acpi/acpica/nsdump.c @@ -181,6 +181,12 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, } this_node = acpi_ns_map_handle_to_node(obj_handle); + if (!this_node) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n", + obj_handle)); + return (AE_OK); + } + type = this_node->type; /* Check if the owner matches */ -- cgit v1.2.3 From ac5f98db7be34cefc244026f882cf030debb7431 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Feb 2009 14:35:25 +0800 Subject: ACPICA: Allow OS override of all ACPI tables Previously, the table override mechanism was implemented for the DSDT only. Now, any table in the RSDT/XSDT can be replaced by the host OS. (including the DSDT). Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/acglobal.h | 1 - drivers/acpi/acpica/tbutils.c | 59 ++++++++++++++++++++++++++++++++---------- drivers/acpi/acpica/tbxface.c | 31 +--------------------- 3 files changed, 47 insertions(+), 44 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index ddb40f5c68f..634fb0785e7 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h @@ -371,7 +371,6 @@ ACPI_EXTERN char *acpi_gbl_db_buffer; ACPI_EXTERN char *acpi_gbl_db_filename; ACPI_EXTERN u32 acpi_gbl_db_debug_level; ACPI_EXTERN u32 acpi_gbl_db_console_debug_level; -ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr; ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node; /* diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index 22ce4898572..e285bedbb98 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c @@ -287,7 +287,10 @@ u8 acpi_tb_checksum(u8 *buffer, u32 length) * * RETURN: None * - * DESCRIPTION: Install an ACPI table into the global data structure. + * DESCRIPTION: Install an ACPI table into the global data structure. The + * table override mechanism is implemented here to allow the host + * OS to replace any table before it is installed in the root + * table array. * ******************************************************************************/ @@ -295,7 +298,10 @@ void acpi_tb_install_table(acpi_physical_address address, u8 flags, char *signature, u32 table_index) { - struct acpi_table_header *table; + acpi_status status; + struct acpi_table_header *table_to_install; + struct acpi_table_header *mapped_table; + struct acpi_table_header *override_table = NULL; if (!address) { ACPI_ERROR((AE_INFO, @@ -306,41 +312,68 @@ acpi_tb_install_table(acpi_physical_address address, /* Map just the table header */ - table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); - if (!table) { + mapped_table = + acpi_os_map_memory(address, sizeof(struct acpi_table_header)); + if (!mapped_table) { return; } - /* If a particular signature is expected, signature must match */ + /* If a particular signature is expected (DSDT/FACS), it must match */ - if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) { + if (signature && !ACPI_COMPARE_NAME(mapped_table->signature, signature)) { ACPI_ERROR((AE_INFO, - "Invalid signature 0x%X for ACPI table [%s]", - *ACPI_CAST_PTR(u32, table->signature), signature)); + "Invalid signature 0x%X for ACPI table, expected [%s]", + *ACPI_CAST_PTR(u32, mapped_table->signature), + signature)); goto unmap_and_exit; } + /* + * ACPI Table Override: + * + * Before we install the table, let the host OS override it with a new + * one if desired. Any table within the RSDT/XSDT can be replaced, + * including the DSDT which is pointed to by the FADT. + */ + status = acpi_os_table_override(mapped_table, &override_table); + if (ACPI_SUCCESS(status) && override_table) { + ACPI_INFO((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + mapped_table->signature, ACPI_CAST_PTR(void, + address))); + + acpi_gbl_root_table_list.tables[table_index].pointer = + override_table; + flags = ACPI_TABLE_ORIGIN_OVERRIDE; + address = ACPI_PTR_TO_PHYSADDR(override_table); + + table_to_install = override_table; + } else { + table_to_install = mapped_table; + } + /* Initialize the table entry */ acpi_gbl_root_table_list.tables[table_index].address = address; - acpi_gbl_root_table_list.tables[table_index].length = table->length; + acpi_gbl_root_table_list.tables[table_index].length = + table_to_install->length; acpi_gbl_root_table_list.tables[table_index].flags = flags; ACPI_MOVE_32_TO_32(& (acpi_gbl_root_table_list.tables[table_index]. - signature), table->signature); + signature), table_to_install->signature); - acpi_tb_print_table_header(address, table); + acpi_tb_print_table_header(address, table_to_install); if (table_index == ACPI_TABLE_INDEX_DSDT) { /* Global integer width is based upon revision of the DSDT */ - acpi_ut_set_integer_width(table->revision); + acpi_ut_set_integer_width(table_to_install->revision); } unmap_and_exit: - acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); + acpi_os_unmap_memory(mapped_table, sizeof(struct acpi_table_header)); } /******************************************************************************* diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index c3e841f3cde..f3f95e38633 100644 --- a/drivers/acpi/acpica/tbxface.c +++ b/drivers/acpi/acpica/tbxface.c @@ -491,7 +491,6 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_by_index) static acpi_status acpi_tb_load_namespace(void) { acpi_status status; - struct acpi_table_header *table; u32 i; ACPI_FUNCTION_TRACE(tb_load_namespace); @@ -515,41 +514,13 @@ static acpi_status acpi_tb_load_namespace(void) goto unlock_and_exit; } - /* - * Find DSDT table - */ - status = - acpi_os_table_override(acpi_gbl_root_table_list. - tables[ACPI_TABLE_INDEX_DSDT].pointer, - &table); - if (ACPI_SUCCESS(status) && table) { - /* - * DSDT table has been found - */ - acpi_tb_delete_table(&acpi_gbl_root_table_list. - tables[ACPI_TABLE_INDEX_DSDT]); - acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer = - table; - acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].length = - table->length; - acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].flags = - ACPI_TABLE_ORIGIN_UNKNOWN; - - ACPI_INFO((AE_INFO, "Table DSDT replaced by host OS")); - acpi_tb_print_table_header(0, table); - - if (no_auto_ssdt == 0) { - printk(KERN_WARNING "ACPI: DSDT override uses original SSDTs unless \"acpi_no_auto_ssdt\"\n"); - } - } + /* A valid DSDT is required */ status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT]); if (ACPI_FAILURE(status)) { - /* A valid DSDT is required */ - status = AE_NO_ACPI_TABLES; goto unlock_and_exit; } -- cgit v1.2.3 From 97cbb7d196845ec9a6c0e3cc33ec20503f8c4e73 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Feb 2009 14:41:03 +0800 Subject: ACPICA: Remove extraneous parameter in table manager Removed the Flags parameter from several internal functions since it was not being used. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/actables.h | 7 +++---- drivers/acpi/acpica/tbfadt.c | 7 +++---- drivers/acpi/acpica/tbutils.c | 14 +++++++------- drivers/acpi/acpica/tbxface.c | 3 +-- 4 files changed, 14 insertions(+), 17 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h index 7ce6e33c7f7..d8f8c5df4fb 100644 --- a/drivers/acpi/acpica/actables.h +++ b/drivers/acpi/acpica/actables.h @@ -49,7 +49,7 @@ acpi_status acpi_allocate_root_table(u32 initial_table_count); /* * tbfadt - FADT parse/convert/validate */ -void acpi_tb_parse_fadt(u32 table_index, u8 flags); +void acpi_tb_parse_fadt(u32 table_index); void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length); @@ -109,9 +109,8 @@ acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length); void acpi_tb_install_table(acpi_physical_address address, - u8 flags, char *signature, u32 table_index); + char *signature, u32 table_index); -acpi_status -acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags); +acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address); #endif /* __ACTABLES_H__ */ diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index 3636e4f8fb7..4b683ccd4a9 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -172,7 +172,6 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, * FUNCTION: acpi_tb_parse_fadt * * PARAMETERS: table_index - Index for the FADT - * Flags - Flags * * RETURN: None * @@ -181,7 +180,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, * ******************************************************************************/ -void acpi_tb_parse_fadt(u32 table_index, u8 flags) +void acpi_tb_parse_fadt(u32 table_index) { u32 length; struct acpi_table_header *table; @@ -219,10 +218,10 @@ void acpi_tb_parse_fadt(u32 table_index, u8 flags) /* Obtain the DSDT and FACS tables via their addresses within the FADT */ acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt, - flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); + ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs, - flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); + ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); } /******************************************************************************* diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index e285bedbb98..a0b424356b9 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c @@ -280,7 +280,6 @@ u8 acpi_tb_checksum(u8 *buffer, u32 length) * FUNCTION: acpi_tb_install_table * * PARAMETERS: Address - Physical address of DSDT or FACS - * Flags - Flags * Signature - Table signature, NULL if no need to * match * table_index - Index into root table array @@ -296,8 +295,9 @@ u8 acpi_tb_checksum(u8 *buffer, u32 length) void acpi_tb_install_table(acpi_physical_address address, - u8 flags, char *signature, u32 table_index) + char *signature, u32 table_index) { + u8 flags; acpi_status status; struct acpi_table_header *table_to_install; struct acpi_table_header *mapped_table; @@ -344,12 +344,13 @@ acpi_tb_install_table(acpi_physical_address address, acpi_gbl_root_table_list.tables[table_index].pointer = override_table; - flags = ACPI_TABLE_ORIGIN_OVERRIDE; address = ACPI_PTR_TO_PHYSADDR(override_table); table_to_install = override_table; + flags = ACPI_TABLE_ORIGIN_OVERRIDE; } else { table_to_install = mapped_table; + flags = ACPI_TABLE_ORIGIN_MAPPED; } /* Initialize the table entry */ @@ -435,7 +436,6 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) * FUNCTION: acpi_tb_parse_root_table * * PARAMETERS: Rsdp - Pointer to the RSDP - * Flags - Flags * * RETURN: Status * @@ -449,7 +449,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) ******************************************************************************/ acpi_status __init -acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) +acpi_tb_parse_root_table(acpi_physical_address rsdp_address) { struct acpi_table_rsdp *rsdp; u32 table_entry_size; @@ -600,14 +600,14 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) */ for (i = 2; i < acpi_gbl_root_table_list.count; i++) { acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. - address, flags, NULL, i); + address, NULL, i); /* Special case for FADT - get the DSDT and FACS */ if (ACPI_COMPARE_NAME (&acpi_gbl_root_table_list.tables[i].signature, ACPI_SIG_FADT)) { - acpi_tb_parse_fadt(i, flags); + acpi_tb_parse_fadt(i); } } diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index f3f95e38633..416d01d9a97 100644 --- a/drivers/acpi/acpica/tbxface.c +++ b/drivers/acpi/acpica/tbxface.c @@ -150,8 +150,7 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array, * Root Table Array. This array contains the information of the RSDT/XSDT * in a common, more useable format. */ - status = - acpi_tb_parse_root_table(rsdp_address, ACPI_TABLE_ORIGIN_MAPPED); + status = acpi_tb_parse_root_table(rsdp_address); return_ACPI_STATUS(status); } -- cgit v1.2.3 From d3ccaff827cef5a5c5a0f3c97e1e2e6d99f618cb Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Feb 2009 14:43:04 +0800 Subject: ACPICA: Add override for dynamic tables Add a call to acpi_os_table_override during the installation of a dynamic table (loaded via the Load or LoadTable AML operators). Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/tbinstal.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index 37374b21969..ef269a297b5 100644 --- a/drivers/acpi/acpica/tbinstal.c +++ b/drivers/acpi/acpica/tbinstal.c @@ -103,7 +103,9 @@ acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) * * RETURN: Status * - * DESCRIPTION: This function is called to add the ACPI table + * DESCRIPTION: This function is called to add an ACPI table. It is used to + * dynamically load tables via the Load and load_table AML + * operators. * ******************************************************************************/ @@ -112,6 +114,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) { u32 i; acpi_status status = AE_OK; + struct acpi_table_header *override_table = NULL; ACPI_FUNCTION_TRACE(tb_add_table); @@ -201,6 +204,29 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) } } + /* + * ACPI Table Override: + * Allow the host to override dynamically loaded tables. + */ + status = acpi_os_table_override(table_desc->pointer, &override_table); + if (ACPI_SUCCESS(status) && override_table) { + ACPI_INFO((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + table_desc->pointer->signature, + ACPI_CAST_PTR(void, table_desc->address))); + + /* We can delete the table that was passed as a parameter */ + + acpi_tb_delete_table(table_desc); + + /* Setup descriptor for the new table */ + + table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table); + table_desc->pointer = override_table; + table_desc->length = override_table->length; + table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + /* Add the table to the global root table list */ status = acpi_tb_store_table(table_desc->address, table_desc->pointer, -- cgit v1.2.3 From 531c633d2be8e79087335a46d3c017ca5837e588 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:06:12 +0800 Subject: ACPICA: Split out PM1 status registers from the FADT Add new globals for the PM1 status registers (A/B), similar to the way the PM1 enable registers are handled. Instead of overloading the FADT Event Register blocks. This makes the code clearer and less prone to error. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/acglobal.h | 5 +- drivers/acpi/acpica/hwregs.c | 18 +-- drivers/acpi/acpica/tbfadt.c | 246 ++++++++++++++++++++++------------------- 3 files changed, 147 insertions(+), 122 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 634fb0785e7..f3e87ba43db 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h @@ -148,9 +148,12 @@ ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list; ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT; ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS; -/* These addresses are calculated from FADT address values */ +/* These addresses are calculated from the FADT Event Block addresses */ +ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status; ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable; + +ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_status; ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable; /* diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 4dc43b01851..7ef0b8eadbc 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -72,21 +72,23 @@ acpi_status acpi_hw_clear_acpi_status(void) ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", ACPI_BITMASK_ALL_FIXED_STATUS, - (u16) acpi_gbl_FADT.xpm1a_event_block.address)); + (u16) acpi_gbl_xpm1a_status.address)); lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); + /* Clear the fixed events */ + status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, ACPI_BITMASK_ALL_FIXED_STATUS); if (ACPI_FAILURE(status)) { goto unlock_and_exit; } - /* Clear the fixed events */ + /* Write PM1B register if present */ - if (acpi_gbl_FADT.xpm1b_event_block.address) { + if (acpi_gbl_xpm1b_status.address) { status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS, - &acpi_gbl_FADT.xpm1b_event_block); + &acpi_gbl_xpm1b_status); if (ACPI_FAILURE(status)) { goto unlock_and_exit; } @@ -150,14 +152,14 @@ acpi_hw_register_read(u32 register_id, u32 * return_value) switch (register_id) { case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ - status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block); + status = acpi_read(&value1, &acpi_gbl_xpm1a_status); if (ACPI_FAILURE(status)) { goto exit; } /* PM1B is optional */ - status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block); + status = acpi_read(&value2, &acpi_gbl_xpm1b_status); value1 |= value2; break; @@ -267,14 +269,14 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) /* Now we can write the data */ - status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block); + status = acpi_write(value, &acpi_gbl_xpm1a_status); if (ACPI_FAILURE(status)) { goto exit; } /* PM1B is optional */ - status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block); + status = acpi_write(value, &acpi_gbl_xpm1b_status); break; case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index 4b683ccd4a9..a8191efd9aa 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -57,6 +57,8 @@ static void acpi_tb_convert_fadt(void); static void acpi_tb_validate_fadt(void); +static void acpi_tb_setup_fadt_registers(void); + /* Table for conversion of FADT to common internal format and FADT validation */ typedef struct acpi_fadt_info { @@ -132,6 +134,35 @@ static struct acpi_fadt_info fadt_info_table[] = { #define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) +/* Table used to split Event Blocks into separate status/enable registers */ + +typedef struct acpi_fadt_pm_info { + struct acpi_generic_address *target; + u8 source; + u8 register_num; + +} acpi_fadt_pm_info; + +static struct acpi_fadt_pm_info fadt_pm_info_table[] = { + {&acpi_gbl_xpm1a_status, + ACPI_FADT_OFFSET(xpm1a_event_block), + 0}, + + {&acpi_gbl_xpm1a_enable, + ACPI_FADT_OFFSET(xpm1a_event_block), + 1}, + + {&acpi_gbl_xpm1b_status, + ACPI_FADT_OFFSET(xpm1b_event_block), + 0}, + + {&acpi_gbl_xpm1b_enable, + ACPI_FADT_OFFSET(xpm1b_event_block), + 1} +}; + +#define ACPI_FADT_PM_INFO_ENTRIES (sizeof (fadt_pm_info_table) / sizeof (struct acpi_fadt_pm_info)) + /******************************************************************************* * * FUNCTION: acpi_tb_init_generic_address @@ -207,7 +238,7 @@ void acpi_tb_parse_fadt(u32 table_index) */ (void)acpi_tb_verify_checksum(table, length); - /* Obtain a local copy of the FADT in common ACPI 2.0+ format */ + /* Create a local copy of the FADT in common ACPI 2.0+ format */ acpi_tb_create_local_fadt(table, length); @@ -265,11 +296,17 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) ACPI_MEMCPY(&acpi_gbl_FADT, table, ACPI_MIN(length, sizeof(struct acpi_table_fadt))); - /* - * 1) Convert the local copy of the FADT to the common internal format - * 2) Validate some of the important values within the FADT - */ + /* Convert the local copy of the FADT to the common internal format */ + acpi_tb_convert_fadt(); + + /* Validate FADT values now, before we make any changes */ + + acpi_tb_validate_fadt(); + + /* Initialize the global ACPI register structures */ + + acpi_tb_setup_fadt_registers(); } /******************************************************************************* @@ -303,8 +340,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) static void acpi_tb_convert_fadt(void) { - u8 pm1_register_bit_width; - u8 pm1_register_byte_width; struct acpi_generic_address *target64; u32 i; @@ -379,112 +414,6 @@ static void acpi_tb_convert_fadt(void) address32)); } } - - /* Validate FADT values now, before we make any changes */ - - acpi_tb_validate_fadt(); - - /* - * Optionally check all register lengths against the default values and - * update them if they are incorrect. - */ - if (acpi_gbl_use_default_register_widths) { - for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { - target64 = - ACPI_ADD_PTR(struct acpi_generic_address, - &acpi_gbl_FADT, - fadt_info_table[i].address64); - - /* - * If a valid register (Address != 0) and the (default_length > 0) - * (Not a GPE register), then check the width against the default. - */ - if ((target64->address) && - (fadt_info_table[i].default_length > 0) && - (fadt_info_table[i].default_length != - target64->bit_width)) { - ACPI_WARNING((AE_INFO, - "Invalid length for %s: %d, using default %d", - fadt_info_table[i].name, - target64->bit_width, - fadt_info_table[i]. - default_length)); - - /* Incorrect size, set width to the default */ - - target64->bit_width = - fadt_info_table[i].default_length; - } - } - } - - /* - * Get the length of the individual PM1 registers (enable and status). - * Each register is defined to be (event block length / 2). - */ - pm1_register_bit_width = - (u8)ACPI_DIV_2(acpi_gbl_FADT.xpm1a_event_block.bit_width); - pm1_register_byte_width = (u8)ACPI_DIV_8(pm1_register_bit_width); - - /* - * Adjust the lengths of the PM1 Event Blocks so that they can be used to - * access the PM1 status register(s). Use (width / 2) - */ - acpi_gbl_FADT.xpm1a_event_block.bit_width = pm1_register_bit_width; - acpi_gbl_FADT.xpm1b_event_block.bit_width = pm1_register_bit_width; - - /* - * Calculate separate GAS structs for the PM1 Enable registers. - * These addresses do not appear (directly) in the FADT, so it is - * useful to calculate them once, here. - * - * The PM event blocks are split into two register blocks, first is the - * PM Status Register block, followed immediately by the PM Enable - * Register block. Each is of length (xpm1x_event_block.bit_width/2). - * - * On various systems the v2 fields (and particularly the bit widths) - * cannot be relied upon, though. Hence resort to using the v1 length - * here (and warn about the inconsistency). - */ - if (acpi_gbl_FADT.xpm1a_event_block.bit_width - != acpi_gbl_FADT.pm1_event_length * 8) - printk(KERN_WARNING "FADT: " - "X_PM1a_EVT_BLK.bit_width (%u) does not match" - " PM1_EVT_LEN (%u)\n", - acpi_gbl_FADT.xpm1a_event_block.bit_width, - acpi_gbl_FADT.pm1_event_length); - - /* The PM1A register block is required */ - - acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable, - acpi_gbl_FADT.xpm1a_event_block.space_id, - pm1_register_byte_width, - (acpi_gbl_FADT.xpm1a_event_block.address + - pm1_register_byte_width)); - /* Don't forget to copy space_id of the GAS */ - acpi_gbl_xpm1a_enable.space_id = - acpi_gbl_FADT.xpm1a_event_block.space_id; - - /* The PM1B register block is optional, ignore if not present */ - - if (acpi_gbl_FADT.xpm1b_event_block.address) { - if (acpi_gbl_FADT.xpm1b_event_block.bit_width - != acpi_gbl_FADT.pm1_event_length * 8) - printk(KERN_WARNING "FADT: " - "X_PM1b_EVT_BLK.bit_width (%u) does not match" - " PM1_EVT_LEN (%u)\n", - acpi_gbl_FADT.xpm1b_event_block.bit_width, - acpi_gbl_FADT.pm1_event_length); - acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, - acpi_gbl_FADT.xpm1b_event_block.space_id, - pm1_register_byte_width, - (acpi_gbl_FADT.xpm1b_event_block. - address + pm1_register_byte_width)); - /* Don't forget to copy space_id of the GAS */ - acpi_gbl_xpm1b_enable.space_id = - acpi_gbl_FADT.xpm1b_event_block.space_id; - - } } /****************************************************************************** @@ -607,3 +536,94 @@ static void acpi_tb_validate_fadt(void) } } } + +/****************************************************************************** + * + * FUNCTION: acpi_tb_setup_fadt_registers + * + * PARAMETERS: None, uses acpi_gbl_FADT. + * + * RETURN: None + * + * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally, + * force FADT register definitions to their default lengths. + * + ******************************************************************************/ + +static void acpi_tb_setup_fadt_registers(void) +{ + struct acpi_generic_address *target64; + struct acpi_generic_address *source64; + u8 pm1_register_byte_width; + u32 i; + + /* + * Optionally check all register lengths against the default values and + * update them if they are incorrect. + */ + if (acpi_gbl_use_default_register_widths) { + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { + target64 = + ACPI_ADD_PTR(struct acpi_generic_address, + &acpi_gbl_FADT, + fadt_info_table[i].address64); + + /* + * If a valid register (Address != 0) and the (default_length > 0) + * (Not a GPE register), then check the width against the default. + */ + if ((target64->address) && + (fadt_info_table[i].default_length > 0) && + (fadt_info_table[i].default_length != + target64->bit_width)) { + ACPI_WARNING((AE_INFO, + "Invalid length for %s: %d, using default %d", + fadt_info_table[i].name, + target64->bit_width, + fadt_info_table[i]. + default_length)); + + /* Incorrect size, set width to the default */ + + target64->bit_width = + fadt_info_table[i].default_length; + } + } + } + + /* + * Get the length of the individual PM1 registers (enable and status). + * Each register is defined to be (event block length / 2). Extra divide + * by 8 converts bits to bytes. + */ + pm1_register_byte_width = + (u8)ACPI_DIV_16(acpi_gbl_FADT.xpm1a_event_block.bit_width); + + /* + * Calculate separate GAS structs for the PM1x (A/B) Status and Enable + * registers. These addresses do not appear (directly) in the FADT, so it + * is useful to pre-calculate them from the PM1 Event Block definitions. + * + * The PM event blocks are split into two register blocks, first is the + * PM Status Register block, followed immediately by the PM Enable + * Register block. Each is of length (pm1_event_length/2) + * + * Note: The PM1A event block is required by the ACPI specification. + * However, the PM1B event block is optional and is rarely, if ever, + * used. + */ + + for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) { + source64 = + ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, + fadt_pm_info_table[i].source); + + acpi_tb_init_generic_address(fadt_pm_info_table[i].target, + source64->space_id, + pm1_register_byte_width, + source64->address + + (fadt_pm_info_table[i]. + register_num * + pm1_register_byte_width)); + } +} -- cgit v1.2.3 From 5e053e77f233342b56fda419d347fd2c958b9849 Mon Sep 17 00:00:00 2001 From: Lin Ming Date: Wed, 4 Mar 2009 14:31:25 +0800 Subject: ACPICA: Check for non-zero address before being converted to GAS Reported-by: FreeBSD community Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/tbfadt.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index a8191efd9aa..43fe886b41a 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -618,12 +618,14 @@ static void acpi_tb_setup_fadt_registers(void) ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, fadt_pm_info_table[i].source); - acpi_tb_init_generic_address(fadt_pm_info_table[i].target, - source64->space_id, - pm1_register_byte_width, - source64->address + - (fadt_pm_info_table[i]. - register_num * - pm1_register_byte_width)); + if (source64->address) { + acpi_tb_init_generic_address(fadt_pm_info_table[i]. + target, source64->space_id, + pm1_register_byte_width, + source64->address + + (fadt_pm_info_table[i]. + register_num * + pm1_register_byte_width)); + } } } -- cgit v1.2.3 From d3319d1717a250e92be66a487dc3e0429112c284 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:07:58 +0800 Subject: ACPICA: Update comments in module header Enhance the explanations of the various package return types for clarity. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/acpredef.h | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h index 16a9ca9a66e..63f656ae360 100644 --- a/drivers/acpi/acpica/acpredef.h +++ b/drivers/acpi/acpica/acpredef.h @@ -52,41 +52,44 @@ * 1) PTYPE1 packages do not contain sub-packages. * * ACPI_PTYPE1_FIXED: Fixed length, 1 or 2 object types: - * object type - * count - * object type - * count + * object type + * count + * object type + * count * * ACPI_PTYPE1_VAR: Variable length: - * object type (Int/Buf/Ref) + * object type (Int/Buf/Ref) * - * ACPI_PTYPE1_OPTION: Package has some required and some optional elements: - * Used for _PRW + * ACPI_PTYPE1_OPTION: Package has some required and some optional elements + * (Used for _PRW) * * * 2) PTYPE2 packages contain a variable number of sub-packages. Each of the * different types describe the contents of each of the sub-packages. * * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: - * object type - * count - * object type - * count + * object type + * count + * object type + * count + * (Used for _ALR,_MLS,_PSS,_TRT,_TSS) * * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element: - * object type + * object type + * (Used for _CSD,_PSD,_TSD) * * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types: - * object type - * count - * object type - * count + * object type + * count + * object type + * count + * (Used for _CST) * - * ACPI_PTYPE2_FIXED: Each subpackage is of fixed length: - * Used for _PRT + * ACPI_PTYPE2_FIXED: Each subpackage is of fixed length + * (Used for _PRT) * * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length - * Used for _HPX + * (Used for _HPX) * *****************************************************************************/ -- cgit v1.2.3 From c520abadbc56a2740021910d2c6412f826a10059 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:20:12 +0800 Subject: ACPICA: Fix writes to optional PM1B registers On read, shift B register bits above the A bits. On write, shift B bits down to zero before writing the B register. New: acpi_hw_read_multiple, acpi_hw_write_multiple. These two functions now transparently handle the (possible) split registers for PM1 Status, Enable, and Control. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwregs.c | 205 +++++++++++++++++++++++++++++-------------- 1 file changed, 140 insertions(+), 65 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 7ef0b8eadbc..41f1173e02c 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -51,6 +51,17 @@ #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME("hwregs") +/* Local Prototypes */ +static acpi_status +acpi_hw_read_multiple(u32 *value, + struct acpi_generic_address *register_a, + struct acpi_generic_address *register_b); + +static acpi_status +acpi_hw_write_multiple(u32 value, + struct acpi_generic_address *register_a, + struct acpi_generic_address *register_b); + /******************************************************************************* * * FUNCTION: acpi_hw_clear_acpi_status @@ -63,6 +74,7 @@ ACPI_MODULE_NAME("hwregs") * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ + acpi_status acpi_hw_clear_acpi_status(void) { acpi_status status; @@ -143,64 +155,49 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) acpi_status acpi_hw_register_read(u32 register_id, u32 * return_value) { - u32 value1 = 0; - u32 value2 = 0; + u32 value = 0; acpi_status status; ACPI_FUNCTION_TRACE(hw_register_read); switch (register_id) { - case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ - status = acpi_read(&value1, &acpi_gbl_xpm1a_status); - if (ACPI_FAILURE(status)) { - goto exit; - } - - /* PM1B is optional */ - - status = acpi_read(&value2, &acpi_gbl_xpm1b_status); - value1 |= value2; + status = acpi_hw_read_multiple(&value, + &acpi_gbl_xpm1a_status, + &acpi_gbl_xpm1b_status); break; - case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ - status = acpi_read(&value1, &acpi_gbl_xpm1a_enable); - if (ACPI_FAILURE(status)) { - goto exit; - } - - /* PM1B is optional */ - - status = acpi_read(&value2, &acpi_gbl_xpm1b_enable); - value1 |= value2; + status = acpi_hw_read_multiple(&value, + &acpi_gbl_xpm1a_enable, + &acpi_gbl_xpm1b_enable); break; - case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - - status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block); - if (ACPI_FAILURE(status)) { - goto exit; - } + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ - status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block); - value1 |= value2; + status = acpi_hw_read_multiple(&value, + &acpi_gbl_FADT. + xpm1a_control_block, + &acpi_gbl_FADT. + xpm1b_control_block); break; case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block); + status = acpi_read(&value, &acpi_gbl_FADT.xpm2_control_block); break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block); + status = acpi_read(&value, &acpi_gbl_FADT.xpm_timer_block); break; case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ status = - acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8); + acpi_os_read_port(acpi_gbl_FADT.smi_command, &value, 8); break; default: @@ -209,10 +206,8 @@ acpi_hw_register_read(u32 register_id, u32 * return_value) break; } - exit: - if (ACPI_SUCCESS(status)) { - *return_value = value1; + *return_value = value; } return_ACPI_STATUS(status); @@ -252,12 +247,13 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) ACPI_FUNCTION_TRACE(hw_register_write); switch (register_id) { - case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ /* Perform a read first to preserve certain bits (per ACPI spec) */ - status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, - &read_value); + status = acpi_hw_read_multiple(&read_value, + &acpi_gbl_xpm1a_status, + &acpi_gbl_xpm1b_status); if (ACPI_FAILURE(status)) { goto exit; } @@ -269,35 +265,29 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) /* Now we can write the data */ - status = acpi_write(value, &acpi_gbl_xpm1a_status); - if (ACPI_FAILURE(status)) { - goto exit; - } - - /* PM1B is optional */ - - status = acpi_write(value, &acpi_gbl_xpm1b_status); + status = acpi_hw_write_multiple(value, + &acpi_gbl_xpm1a_status, + &acpi_gbl_xpm1b_status); break; - case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access */ - status = acpi_write(value, &acpi_gbl_xpm1a_enable); - if (ACPI_FAILURE(status)) { - goto exit; - } - - /* PM1B is optional */ - - status = acpi_write(value, &acpi_gbl_xpm1b_enable); + status = acpi_hw_write_multiple(value, + &acpi_gbl_xpm1a_enable, + &acpi_gbl_xpm1b_enable); break; - case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ /* * Perform a read first to preserve certain bits (per ACPI spec) + * Note: This includes SCI_EN, we never want to change this bit */ - status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, - &read_value); + status = acpi_hw_read_multiple(&read_value, + &acpi_gbl_FADT. + xpm1a_control_block, + &acpi_gbl_FADT. + xpm1b_control_block); if (ACPI_FAILURE(status)) { goto exit; } @@ -309,12 +299,11 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) /* Now we can write the data */ - status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block); - if (ACPI_FAILURE(status)) { - goto exit; - } - - status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block); + status = acpi_hw_write_multiple(value, + &acpi_gbl_FADT. + xpm1a_control_block, + &acpi_gbl_FADT. + xpm1b_control_block); break; case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ @@ -346,6 +335,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) break; default: + ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id)); status = AE_BAD_PARAMETER; break; } @@ -353,3 +343,88 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) exit: return_ACPI_STATUS(status); } + +/****************************************************************************** + * + * FUNCTION: acpi_hw_read_multiple + * + * PARAMETERS: Value - Where the register value is returned + * register_a - First ACPI register (required) + * register_b - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static acpi_status +acpi_hw_read_multiple(u32 *value, + struct acpi_generic_address *register_a, + struct acpi_generic_address *register_b) +{ + u32 value_a = 0; + u32 value_b = 0; + acpi_status status; + + /* The first register is always required */ + + status = acpi_read(&value_a, register_a); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* Second register is optional */ + + if (register_b->address) { + status = acpi_read(&value_b, register_b); + if (ACPI_FAILURE(status)) { + return (status); + } + } + + /* Shift the B bits above the A bits */ + + *value = value_a | (value_b << register_a->bit_width); + return (AE_OK); +} + +/****************************************************************************** + * + * FUNCTION: acpi_hw_write_multiple + * + * PARAMETERS: Value - The value to write + * register_a - First ACPI register (required) + * register_b - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static acpi_status +acpi_hw_write_multiple(u32 value, + struct acpi_generic_address *register_a, + struct acpi_generic_address *register_b) +{ + acpi_status status; + + /* The first register is always required */ + + status = acpi_write(value, register_a); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* Second register is optional */ + + if (register_b->address) { + + /* Normalize the B bits before write */ + + status = acpi_write(value >> register_a->bit_width, register_b); + } + + return (status); +} -- cgit v1.2.3 From 227243a04d645377d09eda0dc8501e0d9c26ab89 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:24:50 +0800 Subject: ACPICA: Remove extra write for acpi_hw_clear_acpi_status This function was writing an optional PM1B status register twice. The existing call to the low-level acpi_hw_register_write automatically handles a possibly split PM1 A/B register. ACPICA BZ 751. http://www.acpica.org/bugzilla/show_bug.cgi?id=751 Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwregs.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 41f1173e02c..9c8162128c2 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -71,7 +71,6 @@ acpi_hw_write_multiple(u32 value, * RETURN: Status * * DESCRIPTION: Clears all fixed and general purpose status bits - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ @@ -82,13 +81,13 @@ acpi_status acpi_hw_clear_acpi_status(void) ACPI_FUNCTION_TRACE(hw_clear_acpi_status); - ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", + ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %0llX\n", ACPI_BITMASK_ALL_FIXED_STATUS, - (u16) acpi_gbl_xpm1a_status.address)); + acpi_gbl_xpm1a_status.address)); lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); - /* Clear the fixed events */ + /* Clear the fixed events in PM1 A/B */ status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, ACPI_BITMASK_ALL_FIXED_STATUS); @@ -96,16 +95,6 @@ acpi_status acpi_hw_clear_acpi_status(void) goto unlock_and_exit; } - /* Write PM1B register if present */ - - if (acpi_gbl_xpm1b_status.address) { - status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS, - &acpi_gbl_xpm1b_status); - if (ACPI_FAILURE(status)) { - goto unlock_and_exit; - } - } - /* Clear the GPE Bits in all GPE registers in all GPE blocks */ status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); -- cgit v1.2.3 From aefc7f9a0220a40beff9b6b3b320cbeae128d0e3 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:26:02 +0800 Subject: ACPICA: For PM1B registers, do not shift value read or written The PM1B registers are mirrors of the PM1A registers with different bits actually implemented. From the ACPI specification: "Although the bits can be split between the two register blocks (each register block has a unique pointer within the FADT), the bit positions are maintained. The register block with unimplemented bits (that is, those implemented in the other register block) always returns zeros, and writes have no side effects" Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwregs.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 9c8162128c2..5a64e577975 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -372,9 +372,17 @@ acpi_hw_read_multiple(u32 *value, } } - /* Shift the B bits above the A bits */ - - *value = value_a | (value_b << register_a->bit_width); + /* + * OR the two return values together. No shifting or masking is necessary, + * because of how the PM1 registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ + *value = (value_a | value_b); return (AE_OK); } @@ -406,13 +414,20 @@ acpi_hw_write_multiple(u32 value, return (status); } - /* Second register is optional */ - + /* + * Second register is optional + * + * No bit shifting or clearing is necessary, because of how the PM1 + * registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ if (register_b->address) { - - /* Normalize the B bits before write */ - - status = acpi_write(value >> register_a->bit_width, register_b); + status = acpi_write(value, register_b); } return (status); -- cgit v1.2.3 From ac0c84502697114a378057eed83a9baba879cfc9 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:28:02 +0800 Subject: ACPICA: Fix parameter validation for acpi_read/write Now return AE_BAD_PARAMETER if the input register pointer is null, and AE_BAD_ADDRESS if the register has an address of zero. Previously, these cases simply returned AE_OK. For optional registers such as PM1B status/enable/control, the caller should check for a valid register address before calling. ACPICA BZ 748. http://www.acpica.org/bugzilla/show_bug.cgi?id=748 Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwxface.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index ae597c0ab53..f67562ea001 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -107,19 +107,18 @@ acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) ACPI_FUNCTION_NAME(acpi_read); /* - * Must have a valid pointer to a GAS structure, and - * a non-zero address within. However, don't return an error - * because the PM1A/B code must not fail if B isn't present. + * Must have a valid pointer to a GAS structure, and a non-zero address + * within. */ if (!reg) { - return (AE_OK); + return (AE_BAD_PARAMETER); } /* Get a local copy of the address. Handles possible alignment issues */ ACPI_MOVE_64_TO_64(&address, ®->address); if (!address) { - return (AE_OK); + return (AE_BAD_ADDRESS); } /* Supported widths are 8/16/32 */ @@ -187,19 +186,18 @@ acpi_status acpi_write(u32 value, struct acpi_generic_address *reg) ACPI_FUNCTION_NAME(acpi_write); /* - * Must have a valid pointer to a GAS structure, and - * a non-zero address within. However, don't return an error - * because the PM1A/B code must not fail if B isn't present. + * Must have a valid pointer to a GAS structure, and a non-zero address + * within. */ if (!reg) { - return (AE_OK); + return (AE_BAD_PARAMETER); } /* Get a local copy of the address. Handles possible alignment issues */ ACPI_MOVE_64_TO_64(&address, ®->address); if (!address) { - return (AE_OK); + return (AE_BAD_ADDRESS); } /* Supported widths are 8/16/32 */ -- cgit v1.2.3 From 82d79b86646504a0ab97fe50ac137df65f651a27 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:31:05 +0800 Subject: ACPICA: Remove redundant ACPI_BITREG_SLEEP_TYPE_B This type is the same as TYPE_A. Removed this and all related instances. Renamed SLEEP_TYPE_A to simply SLEEP_TYPE. ACPICA BZ 754. http://www.acpica.org/bugzilla/show_bug.cgi?id=754 Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/aclocal.h | 4 ++-- drivers/acpi/acpica/hwsleep.c | 4 ++-- drivers/acpi/acpica/utglobal.c | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 492d02761bb..b9a0aa67ab1 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -818,7 +818,7 @@ struct acpi_bit_register_info { #define ACPI_BITMASK_SCI_ENABLE 0x0001 #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 -#define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00 +#define ACPI_BITMASK_SLEEP_TYPE 0x1C00 #define ACPI_BITMASK_SLEEP_ENABLE 0x2000 #define ACPI_BITMASK_ARB_DISABLE 0x0001 @@ -844,7 +844,7 @@ struct acpi_bit_register_info { #define ACPI_BITPOSITION_SCI_ENABLE 0x00 #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 -#define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A +#define ACPI_BITPOSITION_SLEEP_TYPE 0x0A #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D #define ACPI_BITPOSITION_ARB_DISABLE 0x00 diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index a2af2a4f2f2..1a7d260f782 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -242,7 +242,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) } sleep_type_reg_info = - acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE); sleep_enable_reg_info = acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); @@ -486,7 +486,7 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) &acpi_gbl_sleep_type_b); if (ACPI_SUCCESS(status)) { sleep_type_reg_info = - acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE); sleep_enable_reg_info = acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index a3ab9d9da29..bec0e21673c 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c @@ -294,12 +294,9 @@ struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = { /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, - /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, - ACPI_BITPOSITION_SLEEP_TYPE_X, - ACPI_BITMASK_SLEEP_TYPE_X}, - /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, - ACPI_BITPOSITION_SLEEP_TYPE_X, - ACPI_BITMASK_SLEEP_TYPE_X}, + /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, + ACPI_BITPOSITION_SLEEP_TYPE, + ACPI_BITMASK_SLEEP_TYPE}, /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, -- cgit v1.2.3 From 32c9ef994d91352b710b948ec369cd18d6bca51b Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:36:05 +0800 Subject: ACPICA: Add function to handle PM1 control registers Added acpi_hw_write_pm1_control. This function writes both of the PM1 control registers (A/B). These registers are different than than the PM1 A/B status and enable registers in that different values can be written to the A/B registers. Most notably, the SLP_TYP bits can be different, as per the values returned from the _Sx predefined methods. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/achware.h | 5 +-- drivers/acpi/acpica/aclocal.h | 10 +++--- drivers/acpi/acpica/hwregs.c | 46 ++++++++++++++++++------ drivers/acpi/acpica/hwsleep.c | 84 ++++++++++++++++++------------------------- 4 files changed, 78 insertions(+), 67 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h index 58c69dc49ab..4fa6ee6b1f7 100644 --- a/drivers/acpi/acpica/achware.h +++ b/drivers/acpi/acpica/achware.h @@ -64,8 +64,9 @@ u32 acpi_hw_get_mode(void); */ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id); -acpi_status -acpi_hw_register_read(u32 register_id, u32 * return_value); +acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control); + +acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value); acpi_status acpi_hw_register_write(u32 register_id, u32 value); diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index b9a0aa67ab1..6feebc8f789 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -781,12 +781,10 @@ struct acpi_bit_register_info { #define ACPI_REGISTER_PM1_STATUS 0x01 #define ACPI_REGISTER_PM1_ENABLE 0x02 #define ACPI_REGISTER_PM1_CONTROL 0x03 -#define ACPI_REGISTER_PM1A_CONTROL 0x04 -#define ACPI_REGISTER_PM1B_CONTROL 0x05 -#define ACPI_REGISTER_PM2_CONTROL 0x06 -#define ACPI_REGISTER_PM_TIMER 0x07 -#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08 -#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09 +#define ACPI_REGISTER_PM2_CONTROL 0x04 +#define ACPI_REGISTER_PM_TIMER 0x05 +#define ACPI_REGISTER_PROCESSOR_BLOCK 0x06 +#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07 /* Masks used to access the bit_registers */ diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 5a64e577975..edc627c9fc0 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -129,6 +129,42 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) return (&acpi_gbl_bit_register_info[register_id]); } +/****************************************************************************** + * + * FUNCTION: acpi_hw_write_pm1_control + * + * PARAMETERS: pm1a_control - Value to be written to PM1A control + * pm1b_control - Value to be written to PM1B control + * + * RETURN: Status + * + * DESCRIPTION: Write the PM1 A/B control registers. These registers are + * different than than the PM1 A/B status and enable registers + * in that different values can be written to the A/B registers. + * Most notably, the SLP_TYP bits can be different, as per the + * values returned from the _Sx predefined methods. + * + ******************************************************************************/ + +acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control) +{ + acpi_status status; + + ACPI_FUNCTION_TRACE(hw_write_pm1_control); + + status = acpi_write(pm1a_control, &acpi_gbl_FADT.xpm1a_control_block); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + if (acpi_gbl_FADT.xpm1b_control_block.address) { + status = + acpi_write(pm1b_control, + &acpi_gbl_FADT.xpm1b_control_block); + } + return_ACPI_STATUS(status); +} + /****************************************************************************** * * FUNCTION: acpi_hw_register_read @@ -295,16 +331,6 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) xpm1b_control_block); break; - case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ - - status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block); - break; - - case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ - - status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block); - break; - case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block); diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 1a7d260f782..51868f48159 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -147,9 +147,8 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep); - /* - * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. - */ + /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ + status = acpi_get_sleep_type_data(sleep_state, &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); @@ -223,8 +222,8 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) ******************************************************************************/ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) { - u32 PM1Acontrol; - u32 PM1Bcontrol; + u32 pm1a_control; + u32 pm1b_control; struct acpi_bit_register_info *sleep_type_reg_info; struct acpi_bit_register_info *sleep_enable_reg_info; u32 in_value; @@ -289,24 +288,25 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) /* Get current value of PM1A control */ - status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); + status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, + &pm1a_control); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Entering sleep state [S%d]\n", sleep_state)); - /* Clear SLP_EN and SLP_TYP fields */ + /* Clear the SLP_EN and SLP_TYP fields */ - PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | - sleep_enable_reg_info->access_bit_mask); - PM1Bcontrol = PM1Acontrol; + pm1a_control &= ~(sleep_type_reg_info->access_bit_mask | + sleep_enable_reg_info->access_bit_mask); + pm1b_control = pm1a_control; - /* Insert SLP_TYP bits */ + /* Insert the SLP_TYP bits */ - PM1Acontrol |= + pm1a_control |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); - PM1Bcontrol |= + pm1b_control |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); /* @@ -314,37 +314,25 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) * poorly implemented hardware. */ - /* Write #1: fill in SLP_TYP data */ - - status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, - PM1Acontrol); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } + /* Write #1: write the SLP_TYP data to the PM1 Control registers */ - status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, - PM1Bcontrol); + status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } - /* Insert SLP_ENABLE bit */ + /* Insert the sleep enable (SLP_EN) bit */ - PM1Acontrol |= sleep_enable_reg_info->access_bit_mask; - PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask; + pm1a_control |= sleep_enable_reg_info->access_bit_mask; + pm1b_control |= sleep_enable_reg_info->access_bit_mask; - /* Write #2: SLP_TYP + SLP_EN */ + /* Flush caches, as per ACPI specification */ ACPI_FLUSH_CPU_CACHE(); - status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, - PM1Acontrol); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } + /* Write #2: Write both SLP_TYP + SLP_EN */ - status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, - PM1Bcontrol); + status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -471,8 +459,8 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) acpi_status status; struct acpi_bit_register_info *sleep_type_reg_info; struct acpi_bit_register_info *sleep_enable_reg_info; - u32 PM1Acontrol; - u32 PM1Bcontrol; + u32 pm1a_control; + u32 pm1b_control; ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); @@ -493,31 +481,29 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) /* Get current value of PM1A control */ status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, - &PM1Acontrol); + &pm1a_control); if (ACPI_SUCCESS(status)) { - /* Clear SLP_EN and SLP_TYP fields */ + /* Clear the SLP_EN and SLP_TYP fields */ - PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | - sleep_enable_reg_info-> - access_bit_mask); - PM1Bcontrol = PM1Acontrol; + pm1a_control &= ~(sleep_type_reg_info->access_bit_mask | + sleep_enable_reg_info-> + access_bit_mask); + pm1b_control = pm1a_control; - /* Insert SLP_TYP bits */ + /* Insert the SLP_TYP bits */ - PM1Acontrol |= + pm1a_control |= (acpi_gbl_sleep_type_a << sleep_type_reg_info-> bit_position); - PM1Bcontrol |= + pm1b_control |= (acpi_gbl_sleep_type_b << sleep_type_reg_info-> bit_position); - /* Just ignore any errors */ + /* Write the control registers and ignore any errors */ - (void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, - PM1Acontrol); - (void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, - PM1Bcontrol); + (void)acpi_hw_write_pm1_control(pm1a_control, + pm1b_control); } } -- cgit v1.2.3 From 3371c19c294a4cb3649aa4e84606be8a1d999e61 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:44:03 +0800 Subject: ACPICA: Remove ACPI_GET_OBJECT_TYPE macro Remove all instances of this obsolete macro, since it is now a simple reference to ->common.type. There were about 150 invocations of the macro across 41 files. ACPICA BZ 755. http://www.acpica.org/bugzilla/show_bug.cgi?id=755 Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/acmacros.h | 4 ---- drivers/acpi/acpica/dsmthdat.c | 2 +- drivers/acpi/acpica/dsobject.c | 6 +++--- drivers/acpi/acpica/dsopcode.c | 8 +++----- drivers/acpi/acpica/dsutils.c | 2 +- drivers/acpi/acpica/dswexec.c | 5 ++--- drivers/acpi/acpica/evgpeblk.c | 8 ++++---- drivers/acpi/acpica/evregion.c | 2 +- drivers/acpi/acpica/exconfig.c | 4 ++-- drivers/acpi/acpica/exconvrt.c | 11 +++++------ drivers/acpi/acpica/exdump.c | 19 ++++++++----------- drivers/acpi/acpica/exfield.c | 29 +++++++++++++---------------- drivers/acpi/acpica/exfldio.c | 8 ++++---- drivers/acpi/acpica/exmisc.c | 14 +++++++------- drivers/acpi/acpica/exoparg1.c | 13 +++++-------- drivers/acpi/acpica/exoparg2.c | 2 +- drivers/acpi/acpica/exoparg3.c | 7 +++---- drivers/acpi/acpica/exprep.c | 2 +- drivers/acpi/acpica/exresnte.c | 8 ++++---- drivers/acpi/acpica/exresolv.c | 9 ++++----- drivers/acpi/acpica/exresop.c | 23 +++++++++++------------ drivers/acpi/acpica/exstore.c | 18 ++++++++---------- drivers/acpi/acpica/exstoren.c | 29 ++++++++++++----------------- drivers/acpi/acpica/exutils.c | 2 +- drivers/acpi/acpica/hwxface.c | 6 +++--- drivers/acpi/acpica/nsaccess.c | 3 +-- drivers/acpi/acpica/nsdump.c | 2 +- drivers/acpi/acpica/nsobject.c | 18 ++++++++---------- drivers/acpi/acpica/nspredef.c | 8 ++++---- drivers/acpi/acpica/nsxfeval.c | 3 +-- drivers/acpi/acpica/rscalc.c | 7 +++---- drivers/acpi/acpica/rscreate.c | 15 +++++++-------- drivers/acpi/acpica/utcopy.c | 25 ++++++++++++------------- drivers/acpi/acpica/utdelete.c | 6 +++--- drivers/acpi/acpica/uteval.c | 12 ++++++------ drivers/acpi/acpica/utglobal.c | 2 +- drivers/acpi/acpica/utmisc.c | 3 +-- drivers/acpi/acpica/utobject.c | 7 +++---- 38 files changed, 158 insertions(+), 194 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index 9c127e8e2d6..91ac7d7b440 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h @@ -292,10 +292,6 @@ #define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type) #define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t) -/* Macro to test the object type */ - -#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type) - /* * Macros for the master AML opcode table */ diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c index da0f5468184..22b1a3ce2c9 100644 --- a/drivers/acpi/acpica/dsmthdat.c +++ b/drivers/acpi/acpica/dsmthdat.c @@ -713,6 +713,6 @@ acpi_ds_method_data_get_type(u16 opcode, /* Get the object type */ - return_VALUE(ACPI_GET_OBJECT_TYPE(object)); + return_VALUE(object->type); } #endif diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c index 15c628e6aa0..dab3f48f0b4 100644 --- a/drivers/acpi/acpica/dsobject.c +++ b/drivers/acpi/acpica/dsobject.c @@ -565,7 +565,7 @@ acpi_ds_create_node(struct acpi_walk_state *walk_state, /* Re-type the object according to its argument */ - node->type = ACPI_GET_OBJECT_TYPE(obj_desc); + node->type = obj_desc->common.type; /* Attach obj to node */ @@ -619,7 +619,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, /* Perform per-object initialization */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_BUFFER: /* @@ -803,7 +803,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, default: ACPI_ERROR((AE_INFO, "Unimplemented data type: %X", - ACPI_GET_OBJECT_TYPE(obj_desc))); + obj_desc->common.type)); status = AE_AML_OPERAND_TYPE; break; diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c index 0c3b4dd60e8..602ddaa10c2 100644 --- a/drivers/acpi/acpica/dsopcode.c +++ b/drivers/acpi/acpica/dsopcode.c @@ -484,7 +484,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode, /* Host object must be a Buffer */ - if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { + if (buffer_desc->common.type != ACPI_TYPE_BUFFER) { ACPI_ERROR((AE_INFO, "Target of Create Field is not a Buffer object - %s", acpi_ut_get_object_type_name(buffer_desc))); @@ -1365,10 +1365,8 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) - && - (ACPI_GET_OBJECT_TYPE - (walk_state->results->results.obj_desc[0]) == - ACPI_TYPE_LOCAL_REFERENCE) + && ((walk_state->results->results.obj_desc[0])-> + common.type == ACPI_TYPE_LOCAL_REFERENCE) && ((walk_state->results->results.obj_desc[0])-> reference.class != ACPI_REFCLASS_INDEX)) { status = diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c index dabc23a4617..dfa10410292 100644 --- a/drivers/acpi/acpica/dsutils.c +++ b/drivers/acpi/acpica/dsutils.c @@ -816,7 +816,7 @@ acpi_status acpi_ds_evaluate_name_path(struct acpi_walk_state *walk_state) goto push_result; } - type = ACPI_GET_OBJECT_TYPE(*operand); + type = (*operand)->common.type; status = acpi_ex_resolve_to_value(operand, walk_state); if (ACPI_FAILURE(status)) { diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c index 350e6656bc8..f0280856dc0 100644 --- a/drivers/acpi/acpica/dswexec.c +++ b/drivers/acpi/acpica/dswexec.c @@ -138,11 +138,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, goto cleanup; } - if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) { + if (local_obj_desc->common.type != ACPI_TYPE_INTEGER) { ACPI_ERROR((AE_INFO, "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X", - obj_desc, walk_state, - ACPI_GET_OBJECT_TYPE(obj_desc))); + obj_desc, walk_state, obj_desc->common.type)); status = AE_AML_OPERAND_TYPE; goto cleanup; diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index 484cc0565d5..f7b3d2af940 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c @@ -408,7 +408,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, */ obj_desc = pkg_desc->package.elements[0]; - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + if (obj_desc->common.type == ACPI_TYPE_INTEGER) { /* Use FADT-defined GPE device (from definition of _PRW) */ @@ -417,14 +417,14 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, /* Integer is the GPE number in the FADT described GPE blocks */ gpe_number = (u32) obj_desc->integer.value; - } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { + } else if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { /* Package contains a GPE reference and GPE number within a GPE block */ if ((obj_desc->package.count < 2) || - (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[0]) != + ((obj_desc->package.elements[0])->common.type != ACPI_TYPE_LOCAL_REFERENCE) - || (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[1]) != + || ((obj_desc->package.elements[1])->common.type != ACPI_TYPE_INTEGER)) { goto cleanup; } diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c index 665c0887ab4..86cbbdbfc5c 100644 --- a/drivers/acpi/acpica/evregion.c +++ b/drivers/acpi/acpica/evregion.c @@ -691,7 +691,7 @@ acpi_ev_install_handler(acpi_handle obj_handle, /* Devices are handled different than regions */ - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) { + if (obj_desc->common.type == ACPI_TYPE_DEVICE) { /* Check if this Device already has a handler for this address space */ diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c index 932bbc26aa0..70b39c7daea 100644 --- a/drivers/acpi/acpica/exconfig.c +++ b/drivers/acpi/acpica/exconfig.c @@ -291,7 +291,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, /* Source Object can be either an op_region or a Buffer/Field */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_REGION: ACPI_DEBUG_PRINT((ACPI_DB_EXEC, @@ -501,7 +501,7 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) */ if ((!ddb_handle) || (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { + (ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE)) { return_ACPI_STATUS(AE_BAD_PARAMETER); } diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c index 0be10188316..37d0d39e60a 100644 --- a/drivers/acpi/acpica/exconvrt.c +++ b/drivers/acpi/acpica/exconvrt.c @@ -82,7 +82,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, ACPI_FUNCTION_TRACE_PTR(ex_convert_to_integer, obj_desc); - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_INTEGER: /* No conversion necessary */ @@ -116,7 +116,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, /* String conversion is different than Buffer conversion */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_STRING: /* @@ -206,7 +206,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, ACPI_FUNCTION_TRACE_PTR(ex_convert_to_buffer, obj_desc); - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_BUFFER: /* No conversion necessary */ @@ -409,7 +409,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, ACPI_FUNCTION_TRACE_PTR(ex_convert_to_string, obj_desc); - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_STRING: /* No conversion necessary */ @@ -605,8 +605,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, default: /* No conversion allowed for these types */ - if (destination_type != - ACPI_GET_OBJECT_TYPE(source_desc)) { + if (destination_type != source_desc->common.type) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Explicit operator, will store (%s) over existing type (%s)\n", acpi_ut_get_object_type_name diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c index aa313574b0d..193d23312e1 100644 --- a/drivers/acpi/acpica/exdump.c +++ b/drivers/acpi/acpica/exdump.c @@ -492,7 +492,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) /* Decode object type */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_LOCAL_REFERENCE: acpi_os_printf("Reference: [%s] ", @@ -531,7 +531,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) acpi_os_printf("%X", obj_desc->reference.value); - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + if (obj_desc->common.type == ACPI_TYPE_INTEGER) { /* Value is an Integer */ @@ -548,7 +548,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) acpi_os_printf("%X", obj_desc->reference.value); - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + if (obj_desc->common.type == ACPI_TYPE_INTEGER) { /* Value is an Integer */ @@ -686,9 +686,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) if (!obj_desc->buffer_field.buffer_obj) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n")); - } else - if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) - != ACPI_TYPE_BUFFER) { + } else if ((obj_desc->buffer_field.buffer_obj)->common.type != + ACPI_TYPE_BUFFER) { acpi_os_printf("*not a Buffer*\n"); } else { acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, @@ -737,8 +736,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) default: /* Unknown Type */ - acpi_os_printf("Unknown Type %X\n", - ACPI_GET_OBJECT_TYPE(obj_desc)); + acpi_os_printf("Unknown Type %X\n", obj_desc->common.type); break; } @@ -939,7 +937,7 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, /* Packages may only contain a few object types */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_INTEGER: acpi_os_printf("[Integer] = %8.8X%8.8X\n", @@ -990,8 +988,7 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, default: - acpi_os_printf("[Unknown Type] %X\n", - ACPI_GET_OBJECT_TYPE(obj_desc)); + acpi_os_printf("[Unknown Type] %X\n", obj_desc->common.type); break; } } diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index a352d023385..546dcdd8678 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c @@ -84,7 +84,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, return_ACPI_STATUS(AE_BAD_PARAMETER); } - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { + if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { /* * If the buffer_field arguments have not been previously evaluated, * evaluate them now and save the results. @@ -95,9 +95,8 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, return_ACPI_STATUS(status); } } - } else - if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) - && (obj_desc->field.region_obj->region.space_id == + } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) { /* * This is an SMBus read. We must create a buffer to hold the data @@ -163,7 +162,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", - obj_desc, ACPI_GET_OBJECT_TYPE(obj_desc), buffer, + obj_desc, obj_desc->common.type, buffer, (u32) length)); ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", @@ -222,7 +221,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, return_ACPI_STATUS(AE_AML_NO_OPERAND); } - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { + if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { /* * If the buffer_field arguments have not been previously evaluated, * evaluate them now and save the results. @@ -233,9 +232,8 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, return_ACPI_STATUS(status); } } - } else - if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) - && (obj_desc->field.region_obj->region.space_id == + } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) { /* * This is an SMBus write. We will bypass the entire field mechanism @@ -243,7 +241,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, * * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). */ - if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { + if (source_desc->common.type != ACPI_TYPE_BUFFER) { ACPI_ERROR((AE_INFO, "SMBus write requires Buffer, found type %s", acpi_ut_get_object_type_name(source_desc))); @@ -291,7 +289,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, /* Get a pointer to the data to be written */ - switch (ACPI_GET_OBJECT_TYPE(source_desc)) { + switch (source_desc->common.type) { case ACPI_TYPE_INTEGER: buffer = &source_desc->integer.value; length = sizeof(source_desc->integer.value); @@ -314,15 +312,14 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", source_desc, - acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE - (source_desc)), - ACPI_GET_OBJECT_TYPE(source_desc), buffer, length)); + acpi_ut_get_type_name(source_desc->common.type), + source_desc->common.type, buffer, length)); ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", obj_desc, - acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)), - ACPI_GET_OBJECT_TYPE(obj_desc), + acpi_ut_get_type_name(obj_desc->common.type), + obj_desc->common.type, obj_desc->common_field.bit_length, obj_desc->common_field.start_field_bit_offset, obj_desc->common_field.base_byte_offset)); diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index ef58ac4e687..1053e7cd92a 100644 --- a/drivers/acpi/acpica/exfldio.c +++ b/drivers/acpi/acpica/exfldio.c @@ -94,9 +94,9 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, /* We must have a valid region */ - if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) { + if (rgn_desc->common.type != ACPI_TYPE_REGION) { ACPI_ERROR((AE_INFO, "Needed Region, found type %X (%s)", - ACPI_GET_OBJECT_TYPE(rgn_desc), + rgn_desc->common.type, acpi_ut_get_object_type_name(rgn_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); @@ -390,7 +390,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, * index_field - Write to an Index Register, then read/write from/to a * Data Register */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_BUFFER_FIELD: /* * If the buffer_field arguments have not been previously evaluated, @@ -527,7 +527,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, default: ACPI_ERROR((AE_INFO, "Wrong object type in field I/O %X", - ACPI_GET_OBJECT_TYPE(obj_desc))); + obj_desc->common.type)); status = AE_AML_INTERNAL; break; } diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c index 6b0747ac683..998eac32993 100644 --- a/drivers/acpi/acpica/exmisc.c +++ b/drivers/acpi/acpica/exmisc.c @@ -80,7 +80,7 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { case ACPI_DESC_TYPE_OPERAND: - if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) { + if (obj_desc->common.type != ACPI_TYPE_LOCAL_REFERENCE) { return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -260,7 +260,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism. */ - switch (ACPI_GET_OBJECT_TYPE(operand0)) { + switch (operand0->common.type) { case ACPI_TYPE_INTEGER: status = acpi_ex_convert_to_integer(operand1, &local_operand1, 16); @@ -277,7 +277,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, default: ACPI_ERROR((AE_INFO, "Invalid object type: %X", - ACPI_GET_OBJECT_TYPE(operand0))); + operand0->common.type)); status = AE_AML_INTERNAL; } @@ -298,7 +298,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, * 2) Two Strings concatenated to produce a new String * 3) Two Buffers concatenated to produce a new Buffer */ - switch (ACPI_GET_OBJECT_TYPE(operand0)) { + switch (operand0->common.type) { case ACPI_TYPE_INTEGER: /* Result of two Integers is a Buffer */ @@ -379,7 +379,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, /* Invalid object type, should not happen here */ ACPI_ERROR((AE_INFO, "Invalid object type: %X", - ACPI_GET_OBJECT_TYPE(operand0))); + operand0->common.type)); status = AE_AML_INTERNAL; goto cleanup; } @@ -581,7 +581,7 @@ acpi_ex_do_logical_op(u16 opcode, * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism. */ - switch (ACPI_GET_OBJECT_TYPE(operand0)) { + switch (operand0->common.type) { case ACPI_TYPE_INTEGER: status = acpi_ex_convert_to_integer(operand1, &local_operand1, 16); @@ -608,7 +608,7 @@ acpi_ex_do_logical_op(u16 opcode, /* * Two cases: 1) Both Integers, 2) Both Strings or Buffers */ - if (ACPI_GET_OBJECT_TYPE(operand0) == ACPI_TYPE_INTEGER) { + if (operand0->common.type == ACPI_TYPE_INTEGER) { /* * 1) Both operands are of type integer * Note: local_operand1 may have changed above diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c index b530480cc7d..9635d21e568 100644 --- a/drivers/acpi/acpica/exoparg1.c +++ b/drivers/acpi/acpica/exoparg1.c @@ -807,11 +807,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) acpi_namespace_node *) operand[0]); if (temp_desc - && - ((ACPI_GET_OBJECT_TYPE(temp_desc) == - ACPI_TYPE_STRING) - || (ACPI_GET_OBJECT_TYPE(temp_desc) == - ACPI_TYPE_LOCAL_REFERENCE))) { + && ((temp_desc->common.type == ACPI_TYPE_STRING) + || (temp_desc->common.type == + ACPI_TYPE_LOCAL_REFERENCE))) { operand[0] = temp_desc; acpi_ut_add_reference(temp_desc); } else { @@ -819,7 +817,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) goto cleanup; } } else { - switch (ACPI_GET_OBJECT_TYPE(operand[0])) { + switch ((operand[0])->common.type) { case ACPI_TYPE_LOCAL_REFERENCE: /* * This is a deref_of (local_x | arg_x) @@ -877,8 +875,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) != ACPI_DESC_TYPE_NAMED) { - if (ACPI_GET_OBJECT_TYPE(operand[0]) == - ACPI_TYPE_STRING) { + if ((operand[0])->common.type == ACPI_TYPE_STRING) { /* * This is a deref_of (String). The string is a reference * to a named ACPI object. diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c index 0b4f513ca88..85d95c92dfd 100644 --- a/drivers/acpi/acpica/exoparg2.c +++ b/drivers/acpi/acpica/exoparg2.c @@ -399,7 +399,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) * At this point, the Source operand is a String, Buffer, or Package. * Verify that the index is within range. */ - switch (ACPI_GET_OBJECT_TYPE(operand[0])) { + switch ((operand[0])->common.type) { case ACPI_TYPE_STRING: if (index >= operand[0]->string.length) { diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c index c6520bbf882..253f9e12258 100644 --- a/drivers/acpi/acpica/exoparg3.c +++ b/drivers/acpi/acpica/exoparg3.c @@ -161,9 +161,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) * Create the return object. The Source operand is guaranteed to be * either a String or a Buffer, so just use its type. */ - return_desc = - acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE - (operand[0])); + return_desc = acpi_ut_create_internal_object((operand[0])-> + common.type); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -191,7 +190,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) /* Strings always have a sub-pointer, not so for buffers */ - switch (ACPI_GET_OBJECT_TYPE(operand[0])) { + switch ((operand[0])->common.type) { case ACPI_TYPE_STRING: /* Always allocate a new buffer for the String */ diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c index a226f74d4a5..52fec07064f 100644 --- a/drivers/acpi/acpica/exprep.c +++ b/drivers/acpi/acpica/exprep.c @@ -279,7 +279,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, return_UINT32(0); } - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { + if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { /* * buffer_field access can be on any byte boundary, so the * byte_alignment is always 1 byte -- regardless of any byte_alignment diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c index a063a74006f..607958ff467 100644 --- a/drivers/acpi/acpica/exresnte.c +++ b/drivers/acpi/acpica/exresnte.c @@ -136,7 +136,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, switch (entry_type) { case ACPI_TYPE_PACKAGE: - if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) { + if (source_desc->common.type != ACPI_TYPE_PACKAGE) { ACPI_ERROR((AE_INFO, "Object not a Package, type %s", acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); @@ -154,7 +154,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_BUFFER: - if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { + if (source_desc->common.type != ACPI_TYPE_BUFFER) { ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s", acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); @@ -172,7 +172,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_STRING: - if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) { + if (source_desc->common.type != ACPI_TYPE_STRING) { ACPI_ERROR((AE_INFO, "Object not a String, type %s", acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); @@ -186,7 +186,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_INTEGER: - if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) { + if (source_desc->common.type != ACPI_TYPE_INTEGER) { ACPI_ERROR((AE_INFO, "Object not a Integer, type %s", acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c index f6105a6d612..c93b54ce7f7 100644 --- a/drivers/acpi/acpica/exresolv.c +++ b/drivers/acpi/acpica/exresolv.c @@ -149,7 +149,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, /* This is a union acpi_operand_object */ - switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { + switch (stack_desc->common.type) { case ACPI_TYPE_LOCAL_REFERENCE: ref_type = stack_desc->reference.class; @@ -297,8 +297,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", - stack_desc, - ACPI_GET_OBJECT_TYPE(stack_desc))); + stack_desc, stack_desc->common.type)); status = acpi_ex_read_data_from_field(walk_state, stack_desc, @@ -386,7 +385,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, * specification of the object_type and size_of operators). This means * traversing the list of possibly many nested references. */ - while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { + while (obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) { switch (obj_desc->reference.class) { case ACPI_REFCLASS_REFOF: case ACPI_REFCLASS_NAME: @@ -518,7 +517,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, * Now we are guaranteed to have an object that has not been created * via the ref_of or Index operators. */ - type = ACPI_GET_OBJECT_TYPE(obj_desc); + type = obj_desc->common.type; exit: /* Convert internal types to external types */ diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c index 3c3802764bf..5c729a9e913 100644 --- a/drivers/acpi/acpica/exresop.c +++ b/drivers/acpi/acpica/exresop.c @@ -212,7 +212,7 @@ acpi_ex_resolve_operands(u16 opcode, /* ACPI internal object */ - object_type = ACPI_GET_OBJECT_TYPE(obj_desc); + object_type = obj_desc->common.type; /* Check for bad acpi_object_type */ @@ -287,8 +287,7 @@ acpi_ex_resolve_operands(u16 opcode, if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) - && (ACPI_GET_OBJECT_TYPE(obj_desc) == - ACPI_TYPE_STRING)) { + && (obj_desc->common.type == ACPI_TYPE_STRING)) { /* * String found - the string references a named object and * must be resolved to a node @@ -336,7 +335,7 @@ acpi_ex_resolve_operands(u16 opcode, * -- All others must be resolved below. */ if ((opcode == AML_STORE_OP) && - (ACPI_GET_OBJECT_TYPE(*stack_ptr) == + ((*stack_ptr)->common.type == ACPI_TYPE_LOCAL_REFERENCE) && ((*stack_ptr)->reference.class == ACPI_REFCLASS_INDEX)) { goto next_operand; @@ -490,7 +489,7 @@ acpi_ex_resolve_operands(u16 opcode, /* Need an operand of type INTEGER, STRING or BUFFER */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -512,7 +511,7 @@ acpi_ex_resolve_operands(u16 opcode, /* Need an operand of type STRING or BUFFER */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -553,7 +552,7 @@ acpi_ex_resolve_operands(u16 opcode, * The only reference allowed here is a direct reference to * a namespace node. */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -576,7 +575,7 @@ acpi_ex_resolve_operands(u16 opcode, /* Need a buffer or package or (ACPI 2.0) String */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: @@ -598,7 +597,7 @@ acpi_ex_resolve_operands(u16 opcode, /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_BUFFER: case ACPI_TYPE_REGION: @@ -619,7 +618,7 @@ acpi_ex_resolve_operands(u16 opcode, /* Used by the Store() operator only */ - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: @@ -677,8 +676,8 @@ acpi_ex_resolve_operands(u16 opcode, * required object type (Simple cases only). */ status = acpi_ex_check_object_type(type_needed, - ACPI_GET_OBJECT_TYPE - (*stack_ptr), *stack_ptr); + (*stack_ptr)->common.type, + *stack_ptr); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c index e35e9b4f6a4..90d606196c9 100644 --- a/drivers/acpi/acpica/exstore.c +++ b/drivers/acpi/acpica/exstore.c @@ -129,7 +129,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, /* source_desc is of type ACPI_DESC_TYPE_OPERAND */ - switch (ACPI_GET_OBJECT_TYPE(source_desc)) { + switch (source_desc->common.type) { case ACPI_TYPE_INTEGER: /* Output correct integer width */ @@ -324,7 +324,7 @@ acpi_ex_store(union acpi_operand_object *source_desc, /* Destination object must be a Reference or a Constant object */ - switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { + switch (dest_desc->common.type) { case ACPI_TYPE_LOCAL_REFERENCE: break; @@ -460,9 +460,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, */ obj_desc = *(index_desc->reference.where); - if (ACPI_GET_OBJECT_TYPE(source_desc) == - ACPI_TYPE_LOCAL_REFERENCE - && source_desc->reference.class == ACPI_REFCLASS_TABLE) { + if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE && + source_desc->reference.class == ACPI_REFCLASS_TABLE) { /* This is a DDBHandle, just add a reference to it */ @@ -520,8 +519,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, * by the INDEX_OP code. */ obj_desc = index_desc->reference.object; - if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) && - (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) { + if ((obj_desc->common.type != ACPI_TYPE_BUFFER) && + (obj_desc->common.type != ACPI_TYPE_STRING)) { return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -529,7 +528,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, * The assignment of the individual elements will be slightly * different for each source type. */ - switch (ACPI_GET_OBJECT_TYPE(source_desc)) { + switch (source_desc->common.type) { case ACPI_TYPE_INTEGER: /* Use the least-significant byte of the integer */ @@ -707,8 +706,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc, /* No conversions for all other types. Just attach the source object */ status = acpi_ns_attach_object(node, source_desc, - ACPI_GET_OBJECT_TYPE - (source_desc)); + source_desc->common.type); break; } diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c index 145d15305f7..608e838d537 100644 --- a/drivers/acpi/acpica/exstoren.c +++ b/drivers/acpi/acpica/exstoren.c @@ -96,8 +96,7 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, * are all essentially the same. This case handles the * "interchangeable" types Integer, String, and Buffer. */ - if (ACPI_GET_OBJECT_TYPE(source_desc) == - ACPI_TYPE_LOCAL_REFERENCE) { + if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) { /* Resolve a reference object first */ @@ -117,13 +116,11 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, /* Must have a Integer, Buffer, or String */ - if ((ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) && - (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) && - (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) && - !((ACPI_GET_OBJECT_TYPE(source_desc) == - ACPI_TYPE_LOCAL_REFERENCE) - && (source_desc->reference.class == - ACPI_REFCLASS_TABLE))) { + if ((source_desc->common.type != ACPI_TYPE_INTEGER) && + (source_desc->common.type != ACPI_TYPE_BUFFER) && + (source_desc->common.type != ACPI_TYPE_STRING) && + !((source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && + (source_desc->reference.class == ACPI_REFCLASS_TABLE))) { /* Conversion successful but still not a valid type */ @@ -218,8 +215,7 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE(source_desc) != - ACPI_GET_OBJECT_TYPE(dest_desc)) { + if (source_desc->common.type != dest_desc->common.type) { /* * The source type does not match the type of the destination. * Perform the "implicit conversion" of the source to the current type @@ -229,11 +225,10 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, * Otherwise, actual_src_desc is a temporary object to hold the * converted object. */ - status = - acpi_ex_convert_to_target_type(ACPI_GET_OBJECT_TYPE - (dest_desc), source_desc, - &actual_src_desc, - walk_state); + status = acpi_ex_convert_to_target_type(dest_desc->common.type, + source_desc, + &actual_src_desc, + walk_state); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -252,7 +247,7 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, * We now have two objects of identical types, and we can perform a * copy of the *value* of the source object. */ - switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { + switch (dest_desc->common.type) { case ACPI_TYPE_INTEGER: dest_desc->integer.value = actual_src_desc->integer.value; diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c index 32b85d68e75..87730e94413 100644 --- a/drivers/acpi/acpica/exutils.c +++ b/drivers/acpi/acpica/exutils.c @@ -221,7 +221,7 @@ void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) */ if ((!obj_desc) || (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) { + (obj_desc->common.type != ACPI_TYPE_INTEGER)) { return; } diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index f67562ea001..4df9eacb7c8 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -532,7 +532,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) /* It must be of type Package */ - else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { + else if (info->return_object->common.type != ACPI_TYPE_PACKAGE) { ACPI_ERROR((AE_INFO, "Sleep State return object is not a Package")); status = AE_AML_OPERAND_TYPE; @@ -553,9 +553,9 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) /* The first two elements must both be of type Integer */ - else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) + else if (((info->return_object->package.elements[0])->common.type != ACPI_TYPE_INTEGER) || - (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1]) + ((info->return_object->package.elements[1])->common.type != ACPI_TYPE_INTEGER)) { ACPI_ERROR((AE_INFO, "Sleep State return package elements are not both Integers (%s, %s)", diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index 88303ebe924..b6968a65cd4 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c @@ -234,8 +234,7 @@ acpi_status acpi_ns_root_initialize(void) /* Store pointer to value descriptor in the Node */ status = acpi_ns_attach_object(new_node, obj_desc, - ACPI_GET_OBJECT_TYPE - (obj_desc)); + obj_desc->common.type); /* Remove local reference to the object */ diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c index e96d37a596b..7bfa6c1286f 100644 --- a/drivers/acpi/acpica/nsdump.c +++ b/drivers/acpi/acpica/nsdump.c @@ -515,7 +515,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, case ACPI_DESC_TYPE_OPERAND: - obj_type = ACPI_GET_OBJECT_TYPE(obj_desc); + obj_type = obj_desc->common.type; if (obj_type > ACPI_TYPE_LOCAL_MAX) { acpi_os_printf diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c index 08a97a57f8f..3eb20bfda9d 100644 --- a/drivers/acpi/acpica/nsobject.c +++ b/drivers/acpi/acpica/nsobject.c @@ -209,8 +209,7 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node) obj_desc = node->object; - if (!obj_desc || - (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA)) { + if (!obj_desc || (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { return_VOID; } @@ -220,8 +219,7 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node) if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) { node->object = obj_desc->common.next_object; if (node->object && - (ACPI_GET_OBJECT_TYPE(node->object) != - ACPI_TYPE_LOCAL_DATA)) { + ((node->object)->common.type != ACPI_TYPE_LOCAL_DATA)) { node->object = node->object->common.next_object; } } @@ -267,7 +265,7 @@ union acpi_operand_object *acpi_ns_get_attached_object(struct ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND) && (ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_NAMED)) - || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) { + || ((node->object)->common.type == ACPI_TYPE_LOCAL_DATA)) { return_PTR(NULL); } @@ -294,9 +292,9 @@ union acpi_operand_object *acpi_ns_get_secondary_object(union ACPI_FUNCTION_TRACE_PTR(ns_get_secondary_object, obj_desc); if ((!obj_desc) || - (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) || + (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) || (!obj_desc->common.next_object) || - (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) == + ((obj_desc->common.next_object)->common.type == ACPI_TYPE_LOCAL_DATA)) { return_PTR(NULL); } @@ -331,7 +329,7 @@ acpi_ns_attach_data(struct acpi_namespace_node *node, prev_obj_desc = NULL; obj_desc = node->object; while (obj_desc) { - if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && + if ((obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) && (obj_desc->data.handler == handler)) { return (AE_ALREADY_EXISTS); } @@ -385,7 +383,7 @@ acpi_ns_detach_data(struct acpi_namespace_node * node, prev_obj_desc = NULL; obj_desc = node->object; while (obj_desc) { - if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && + if ((obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) && (obj_desc->data.handler == handler)) { if (prev_obj_desc) { prev_obj_desc->common.next_object = @@ -428,7 +426,7 @@ acpi_ns_get_attached_data(struct acpi_namespace_node * node, obj_desc = node->object; while (obj_desc) { - if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && + if ((obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) && (obj_desc->data.handler == handler)) { *data = obj_desc->data.pointer; return (AE_OK); diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 452703290d3..72dd7b19852 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c @@ -221,7 +221,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, /* For returned Package objects, check the type of all sub-objects */ - if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) { + if (return_object->common.type == ACPI_TYPE_PACKAGE) { status = acpi_ns_check_package(pathname, return_object_ptr, predefined); @@ -858,7 +858,7 @@ acpi_ns_check_object_type(char *pathname, * from all of the predefined names (including elements of returned * packages) */ - switch (ACPI_GET_OBJECT_TYPE(return_object)) { + switch (return_object->common.type) { case ACPI_TYPE_INTEGER: return_btype = ACPI_RTYPE_INTEGER; break; @@ -901,7 +901,7 @@ acpi_ns_check_object_type(char *pathname, /* For reference objects, check that the reference type is correct */ - if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_LOCAL_REFERENCE) { + if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { status = acpi_ns_check_reference(pathname, return_object); } @@ -1006,7 +1006,7 @@ acpi_ns_repair_object(u32 expected_btypes, union acpi_operand_object *new_object; acpi_size length; - switch (ACPI_GET_OBJECT_TYPE(return_object)) { + switch (return_object->common.type) { case ACPI_TYPE_BUFFER: if (!(expected_btypes & ACPI_RTYPE_STRING)) { diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 22a7171ac1e..2583a66a60a 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c @@ -387,8 +387,7 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info) /* We are interested in reference objects only */ - if (ACPI_GET_OBJECT_TYPE(info->return_object) != - ACPI_TYPE_LOCAL_REFERENCE) { + if ((info->return_object)->common.type != ACPI_TYPE_LOCAL_REFERENCE) { return; } diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index 52865ee6bc7..b6667ff059e 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c @@ -557,9 +557,9 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, table_index++) { if (*sub_object_list && /* Null object allowed */ ((ACPI_TYPE_STRING == - ACPI_GET_OBJECT_TYPE(*sub_object_list)) || + (*sub_object_list)->common.type) || ((ACPI_TYPE_LOCAL_REFERENCE == - ACPI_GET_OBJECT_TYPE(*sub_object_list)) && + (*sub_object_list)->common.type) && ((*sub_object_list)->reference.class == ACPI_REFCLASS_NAME)))) { name_found = TRUE; @@ -575,8 +575,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, /* Was a String type found? */ if (name_found) { - if (ACPI_GET_OBJECT_TYPE(*sub_object_list) == - ACPI_TYPE_STRING) { + if ((*sub_object_list)->common.type == ACPI_TYPE_STRING) { /* * The length String.Length field does not include the * terminating NULL, add 1 diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c index 61566b1a061..663f692fffc 100644 --- a/drivers/acpi/acpica/rscreate.c +++ b/drivers/acpi/acpica/rscreate.c @@ -212,7 +212,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, /* Each element of the top-level package must also be a package */ - if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { + if ((*top_object_list)->common.type != ACPI_TYPE_PACKAGE) { ACPI_ERROR((AE_INFO, "(PRT[%X]) Need sub-package, found %s", index, @@ -240,7 +240,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, /* 1) First subobject: Dereference the PRT.Address */ obj_desc = sub_object_list[0]; - if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER) { + if (obj_desc->common.type != ACPI_TYPE_INTEGER) { ACPI_ERROR((AE_INFO, "(PRT[%X].Address) Need Integer, found %s", index, @@ -253,7 +253,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, /* 2) Second subobject: Dereference the PRT.Pin */ obj_desc = sub_object_list[1]; - if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER) { + if (obj_desc->common.type != ACPI_TYPE_INTEGER) { ACPI_ERROR((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s", index, @@ -265,7 +265,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, * If BIOS erroneously reversed the _PRT source_name and source_index, * then reverse them back. */ - if (ACPI_GET_OBJECT_TYPE(sub_object_list[3]) != + if ((sub_object_list[3])->common.type != ACPI_TYPE_INTEGER) { if (acpi_gbl_enable_interpreter_slack) { source_name_index = 3; @@ -291,8 +291,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, * other ACPI implementations. */ obj_desc = sub_object_list[3]; - if (!obj_desc - || (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) { + if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) { sub_object_list[3] = sub_object_list[2]; sub_object_list[2] = obj_desc; @@ -307,7 +306,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, */ obj_desc = sub_object_list[source_name_index]; if (obj_desc) { - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_LOCAL_REFERENCE: if (obj_desc->reference.class != @@ -380,7 +379,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, /* 4) Fourth subobject: Dereference the PRT.source_index */ obj_desc = sub_object_list[source_index_index]; - if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER) { + if (obj_desc->common.type != ACPI_TYPE_INTEGER) { ACPI_ERROR((AE_INFO, "(PRT[%X].SourceIndex) Need Integer, found %s", index, diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c index b0dcfd3c872..cabe860ce00 100644 --- a/drivers/acpi/acpica/utcopy.c +++ b/drivers/acpi/acpica/utcopy.c @@ -135,11 +135,11 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, * In general, the external object will be the same type as * the internal object */ - external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); + external_object->type = internal_object->common.type; /* However, only a limited number of external types are supported */ - switch (ACPI_GET_OBJECT_TYPE(internal_object)) { + switch (internal_object->common.type) { case ACPI_TYPE_STRING: external_object->string.pointer = (char *)data_space; @@ -222,8 +222,8 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, */ ACPI_ERROR((AE_INFO, "Unsupported object type, cannot convert to external object: %s", - acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE - (internal_object)))); + acpi_ut_get_type_name(internal_object->common. + type))); return_ACPI_STATUS(AE_SUPPORT); } @@ -355,7 +355,7 @@ acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object, info.object_space = 0; info.num_packages = 1; - external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); + external_object->type = internal_object->common.type; external_object->package.count = internal_object->package.count; external_object->package.elements = ACPI_CAST_PTR(union acpi_object, info.free_space); @@ -399,7 +399,7 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object, ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject); - if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) { + if (internal_object->common.type == ACPI_TYPE_PACKAGE) { /* * Package object: Copy all subobjects (including * nested packages) @@ -697,7 +697,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, /* Handle the objects with extra data */ - switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { + switch (dest_desc->common.type) { case ACPI_TYPE_BUFFER: /* * Allocate and copy the actual buffer if and only if: @@ -814,8 +814,8 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type, * This is a simple object, just copy it */ target_object = - acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE - (source_object)); + acpi_ut_create_internal_object(source_object-> + common.type); if (!target_object) { return (AE_NO_MEMORY); } @@ -892,7 +892,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage); - dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj); + dest_obj->common.type = source_obj->common.type; dest_obj->common.flags = source_obj->common.flags; dest_obj->package.count = source_obj->package.count; @@ -950,15 +950,14 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc, /* Create the top level object */ - *dest_desc = - acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc)); + *dest_desc = acpi_ut_create_internal_object(source_desc->common.type); if (!*dest_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } /* Copy the object and possible subobjects */ - if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) { + if (source_desc->common.type == ACPI_TYPE_PACKAGE) { status = acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc, walk_state); diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c index a0be9e39531..a5ee23bc4f5 100644 --- a/drivers/acpi/acpica/utdelete.c +++ b/drivers/acpi/acpica/utdelete.c @@ -86,7 +86,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) * Must delete or free any pointers within the object that are not * actual ACPI objects (for example, a raw buffer pointer). */ - switch (ACPI_GET_OBJECT_TYPE(object)) { + switch (object->common.type) { case ACPI_TYPE_STRING: ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, @@ -382,7 +382,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) object, new_count)); } - if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) { + if (object->common.type == ACPI_TYPE_METHOD) { ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n", object, new_count)); @@ -469,7 +469,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) * All sub-objects must have their reference count incremented also. * Different object types have different subobjects. */ - switch (ACPI_GET_OBJECT_TYPE(object)) { + switch (object->common.type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c index 9c9897dbe90..99bfbd23258 100644 --- a/drivers/acpi/acpica/uteval.c +++ b/drivers/acpi/acpica/uteval.c @@ -248,7 +248,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, /* Map the return object type to the bitmapped type */ - switch (ACPI_GET_OBJECT_TYPE(info->return_object)) { + switch ((info->return_object)->common.type) { case ACPI_TYPE_INTEGER: return_btype = ACPI_BTYPE_INTEGER; break; @@ -418,7 +418,7 @@ acpi_ut_execute_HID(struct acpi_namespace_node *device_node, return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + if (obj_desc->common.type == ACPI_TYPE_INTEGER) { /* Convert the Numeric HID to string */ @@ -459,7 +459,7 @@ acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, struct acpi_compatible_id *one_cid) { - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + switch (obj_desc->common.type) { case ACPI_TYPE_INTEGER: /* Convert the Numeric CID to string */ @@ -527,7 +527,7 @@ acpi_ut_execute_CID(struct acpi_namespace_node * device_node, /* Get the number of _CIDs returned */ count = 1; - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { + if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { count = obj_desc->package.count; } @@ -555,7 +555,7 @@ acpi_ut_execute_CID(struct acpi_namespace_node * device_node, /* The _CID object can be either a single CID or a package (list) of CIDs */ - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { + if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { /* Translate each package element */ @@ -620,7 +620,7 @@ acpi_ut_execute_UID(struct acpi_namespace_node *device_node, return_ACPI_STATUS(status); } - if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + if (obj_desc->common.type == ACPI_TYPE_INTEGER) { /* Convert the Numeric UID to string */ diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index bec0e21673c..7fc35d33adb 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c @@ -473,7 +473,7 @@ char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) return ("[NULL Object Descriptor]"); } - return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc))); + return (acpi_ut_get_type_name(obj_desc->common.type)); } /******************************************************************************* diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c index c1f7f4e1a72..1c9e250caef 100644 --- a/drivers/acpi/acpica/utmisc.c +++ b/drivers/acpi/acpica/utmisc.c @@ -938,8 +938,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object, if ((!this_source_obj) || (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != ACPI_DESC_TYPE_OPERAND) - || (ACPI_GET_OBJECT_TYPE(this_source_obj) != - ACPI_TYPE_PACKAGE)) { + || (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) { status = walk_callback(ACPI_COPY_TYPE_SIMPLE, this_source_obj, state, context); diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c index fd5ea7543e5..ae337a71743 100644 --- a/drivers/acpi/acpica/utobject.c +++ b/drivers/acpi/acpica/utobject.c @@ -457,7 +457,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, * must be accessed bytewise or there may be alignment problems on * certain processors */ - switch (ACPI_GET_OBJECT_TYPE(internal_object)) { + switch (internal_object->common.type) { case ACPI_TYPE_STRING: length += (acpi_size) internal_object->string.length + 1; @@ -518,8 +518,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, ACPI_ERROR((AE_INFO, "Cannot convert to external object - " "unsupported type [%s] %X in object %p", acpi_ut_get_object_type_name(internal_object), - ACPI_GET_OBJECT_TYPE(internal_object), - internal_object)); + internal_object->common.type, internal_object)); status = AE_TYPE; break; } @@ -664,7 +663,7 @@ acpi_ut_get_object_size(union acpi_operand_object *internal_object, if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_OPERAND) - && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) { + && (internal_object->common.type == ACPI_TYPE_PACKAGE)) { status = acpi_ut_get_package_object_size(internal_object, obj_length); -- cgit v1.2.3 From 4f70e371cdf6ab4f988fbaf2257e6259422ba662 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:52:43 +0800 Subject: ACPICA: Conditionally compile acpi_set_firmware_waking_vector64 This function is only needed on 64-bit host operating systems. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwsleep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 51868f48159..26e249e69ea 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -90,6 +90,7 @@ acpi_set_firmware_waking_vector(u32 physical_address) ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) +#if ACPI_MACHINE_WIDTH == 64 /******************************************************************************* * * FUNCTION: acpi_set_firmware_waking_vector64 @@ -100,7 +101,8 @@ ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) * RETURN: Status * * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if - * it exists in the table. + * it exists in the table. This function is intended for use with + * 64-bit host operating systems. * ******************************************************************************/ acpi_status @@ -124,6 +126,7 @@ acpi_set_firmware_waking_vector64(u64 physical_address) } ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64) +#endif /******************************************************************************* * -- cgit v1.2.3 From c114e4b6c606c7f174b752f946fcfb0e7e61a347 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 23 Feb 2009 11:00:00 +0800 Subject: ACPICA: Debug output: print result of _OSI invocations Print input strings and the result (supported or not supported) for invocations of the _OSI method. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/uteval.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c index 99bfbd23258..9c4ae6f26b9 100644 --- a/drivers/acpi/acpica/uteval.c +++ b/drivers/acpi/acpica/uteval.c @@ -98,6 +98,7 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) acpi_status status; union acpi_operand_object *string_desc; union acpi_operand_object *return_desc; + u32 return_value; u32 i; ACPI_FUNCTION_TRACE(ut_osi_implementation); @@ -116,10 +117,9 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) return_ACPI_STATUS(AE_NO_MEMORY); } - /* Default return value is 0, NOT-SUPPORTED */ + /* Default return value is 0, NOT SUPPORTED */ - return_desc->integer.value = 0; - walk_state->return_desc = return_desc; + return_value = 0; /* Compare input string to static table of supported interfaces */ @@ -127,8 +127,11 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) if (!ACPI_STRCMP (string_desc->string.pointer, acpi_interfaces_supported[i])) { - return_desc->integer.value = ACPI_UINT32_MAX; - goto done; + + /* The interface is supported */ + + return_value = ACPI_UINT32_MAX; + goto exit; } } @@ -139,15 +142,22 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) */ status = acpi_os_validate_interface(string_desc->string.pointer); if (ACPI_SUCCESS(status)) { - return_desc->integer.value = ACPI_UINT32_MAX; + + /* The interface is supported */ + + return_value = ACPI_UINT32_MAX; } -done: - ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, "ACPI: BIOS _OSI(%s) %ssupported\n", - string_desc->string.pointer, - return_desc->integer.value == 0 ? "not-" : "")); +exit: + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, + "ACPI: BIOS _OSI(%s) is %ssupported\n", + string_desc->string.pointer, return_value == 0 ? "not " : "")); - return_ACPI_STATUS(AE_OK); + /* Complete the return value */ + + return_desc->integer.value = return_value; + walk_state->return_desc = return_desc; + return_ACPI_STATUS (AE_OK); } /******************************************************************************* -- cgit v1.2.3 From 7bcc06e845479bde939059bafa088bf25ede9dbf Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 14:58:08 +0800 Subject: ACPICA: Debug output: decrease verbosity of DB_INFO debug level Removed some of the extraneous debug prints using the DB_INFO level. This should make the DB_INFO more useful. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/nseval.c | 2 +- drivers/acpi/acpica/nsutils.c | 2 +- drivers/acpi/acpica/utobject.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c index 0f3d5f9b596..8e7dec1176c 100644 --- a/drivers/acpi/acpica/nseval.c +++ b/drivers/acpi/acpica/nseval.c @@ -155,7 +155,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) } - ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:", + ACPI_DUMP_PATHNAME(info->resolved_node, "ACPI: Execute Method", ACPI_LV_INFO, _COMPONENT); ACPI_DEBUG_PRINT((ACPI_DB_EXEC, diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index 3e1149bf4aa..d30b0e65ab3 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c @@ -872,7 +872,7 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node, (flags | ACPI_NS_DONT_OPEN_SCOPE), NULL, return_node); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s, %s\n", + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s, %s\n", pathname, acpi_format_exception(status))); } diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c index ae337a71743..0207b625274 100644 --- a/drivers/acpi/acpica/utobject.c +++ b/drivers/acpi/acpica/utobject.c @@ -310,7 +310,7 @@ u8 acpi_ut_valid_internal_object(void *object) /* Check for a null pointer */ if (!object) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Null Object Ptr\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "**** Null Object Ptr\n")); return (FALSE); } @@ -324,7 +324,7 @@ u8 acpi_ut_valid_internal_object(void *object) return (TRUE); default: - ACPI_DEBUG_PRINT((ACPI_DB_INFO, + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p is not not an ACPI operand obj [%s]\n", object, acpi_ut_get_descriptor_name(object))); break; -- cgit v1.2.3 From ec41f193eadb6301f3c052b5e0dbc0b5636982e8 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 15:03:30 +0800 Subject: ACPICA: Formatting update - no functional changes Split some long lines. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/tbfadt.c | 33 ++++++++++++++++++++------------- drivers/acpi/acpica/tbinstal.c | 9 +++++---- drivers/acpi/acpica/tbutils.c | 17 +++++++++-------- drivers/acpi/acpica/tbxface.c | 37 ++++++++++++++++--------------------- drivers/acpi/acpica/tbxfroot.c | 4 ++-- drivers/acpi/acpica/utcopy.c | 5 +++-- drivers/acpi/acpica/uteval.c | 5 ++--- drivers/acpi/acpica/utglobal.c | 5 ++++- 8 files changed, 61 insertions(+), 54 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index 43fe886b41a..af8fbe12d8b 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -132,7 +132,8 @@ static struct acpi_fadt_info fadt_info_table[] = { ACPI_FADT_SEPARATE_LENGTH} }; -#define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) +#define ACPI_FADT_INFO_ENTRIES \ + (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) /* Table used to split Event Blocks into separate status/enable registers */ @@ -161,7 +162,8 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = { 1} }; -#define ACPI_FADT_PM_INFO_ENTRIES (sizeof (fadt_pm_info_table) / sizeof (struct acpi_fadt_pm_info)) +#define ACPI_FADT_PM_INFO_ENTRIES \ + (sizeof (fadt_pm_info_table) / sizeof (struct acpi_fadt_pm_info)) /******************************************************************************* * @@ -416,7 +418,7 @@ static void acpi_tb_convert_fadt(void) } } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: acpi_tb_validate_fadt * @@ -503,7 +505,8 @@ static void acpi_tb_validate_fadt(void) */ if (!address64->address || !length) { ACPI_ERROR((AE_INFO, - "Required field %s has zero address and/or length: %8.8X%8.8X/%X", + "Required field %s has zero address and/or length:" + " %8.8X%8.8X/%X", name, ACPI_FORMAT_UINT64(address64-> address), @@ -512,12 +515,14 @@ static void acpi_tb_validate_fadt(void) } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) { /* * Field is optional (PM2Control, GPE0, GPE1) AND has its own - * length field. If present, both the address and length must be valid. + * length field. If present, both the address and length must + * be valid. */ - if ((address64->address && !length) - || (!address64->address && length)) { + if ((address64->address && !length) || + (!address64->address && length)) { ACPI_WARNING((AE_INFO, - "Optional field %s has zero address or length: %8.8X%8.8X/%X", + "Optional field %s has zero address or length: " + "%8.8X%8.8X/%X", name, ACPI_FORMAT_UINT64(address64-> address), @@ -525,8 +530,10 @@ static void acpi_tb_validate_fadt(void) } } - /* If both 32- and 64-bit addresses are valid (non-zero), they must match */ - + /* + * If both 32- and 64-bit addresses are valid (non-zero), + * they must match + */ if (address64->address && *address32 && (address64->address != (u64) * address32)) { ACPI_ERROR((AE_INFO, @@ -537,7 +544,7 @@ static void acpi_tb_validate_fadt(void) } } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: acpi_tb_setup_fadt_registers * @@ -596,8 +603,8 @@ static void acpi_tb_setup_fadt_registers(void) * Each register is defined to be (event block length / 2). Extra divide * by 8 converts bits to bytes. */ - pm1_register_byte_width = - (u8)ACPI_DIV_16(acpi_gbl_FADT.xpm1a_event_block.bit_width); + pm1_register_byte_width = (u8) + ACPI_DIV_16(acpi_gbl_FADT.xpm1a_event_block.bit_width); /* * Calculate separate GAS structs for the PM1x (A/B) Status and Enable diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index ef269a297b5..c37993003f2 100644 --- a/drivers/acpi/acpica/tbinstal.c +++ b/drivers/acpi/acpica/tbinstal.c @@ -273,8 +273,9 @@ acpi_status acpi_tb_resize_root_table_list(void) /* Increase the Table Array size */ tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. - size + ACPI_ROOT_TABLE_SIZE_INCREMENT) - * sizeof(struct acpi_table_desc)); + size + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof(struct acpi_table_desc)); if (!tables) { ACPI_ERROR((AE_INFO, "Could not allocate new root table array")); @@ -561,8 +562,8 @@ u8 acpi_tb_is_table_loaded(u32 table_index) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); if (table_index < acpi_gbl_root_table_list.count) { is_loaded = (u8) - (acpi_gbl_root_table_list.tables[table_index]. - flags & ACPI_TABLE_IS_LOADED); + (acpi_gbl_root_table_list.tables[table_index].flags & + ACPI_TABLE_IS_LOADED); } (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index a0b424356b9..dc45b49e5cb 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c @@ -413,7 +413,8 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) } else { /* * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return - * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit + * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, + * return 64-bit */ ACPI_MOVE_64_TO_64(&address64, table_entry); @@ -423,7 +424,8 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) /* Will truncate 64-bit address to 32 bits, issue warning */ ACPI_WARNING((AE_INFO, - "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating", + "64-bit Physical Address in XSDT is too large (%8.8X%8.8X)," + " truncating", ACPI_FORMAT_UINT64(address64))); } #endif @@ -546,13 +548,12 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address) /* Calculate the number of tables described in the root table */ - table_count = - (u32) ((table->length - - sizeof(struct acpi_table_header)) / table_entry_size); - + table_count = (u32)((table->length - sizeof(struct acpi_table_header)) / + table_entry_size); /* - * First two entries in the table array are reserved for the DSDT and FACS, - * which are not actually present in the RSDT/XSDT - they come from the FADT + * First two entries in the table array are reserved for the DSDT + * and FACS, which are not actually present in the RSDT/XSDT - they + * come from the FADT */ table_entry = ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index 416d01d9a97..dbca2265150 100644 --- a/drivers/acpi/acpica/tbxface.c +++ b/drivers/acpi/acpica/tbxface.c @@ -246,7 +246,7 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr) ACPI_EXPORT_SYMBOL(acpi_load_table) -/****************************************************************************** +/******************************************************************************* * * FUNCTION: acpi_get_table_header * @@ -261,7 +261,7 @@ ACPI_EXPORT_SYMBOL(acpi_load_table) * NOTE: Caller is responsible in unmapping the header with * acpi_os_unmap_memory * - *****************************************************************************/ + ******************************************************************************/ acpi_status acpi_get_table_header(char *signature, u32 instance, struct acpi_table_header *out_table_header) @@ -276,9 +276,8 @@ acpi_get_table_header(char *signature, return (AE_BAD_PARAMETER); } - /* - * Walk the root table list - */ + /* Walk the root table list */ + for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { if (!ACPI_COMPARE_NAME (&(acpi_gbl_root_table_list.tables[i].signature), @@ -291,8 +290,8 @@ acpi_get_table_header(char *signature, } if (!acpi_gbl_root_table_list.tables[i].pointer) { - if ((acpi_gbl_root_table_list.tables[i]. - flags & ACPI_TABLE_ORIGIN_MASK) == + if ((acpi_gbl_root_table_list.tables[i].flags & + ACPI_TABLE_ORIGIN_MASK) == ACPI_TABLE_ORIGIN_MAPPED) { header = acpi_os_map_memory(acpi_gbl_root_table_list. @@ -323,7 +322,7 @@ acpi_get_table_header(char *signature, ACPI_EXPORT_SYMBOL(acpi_get_table_header) -/****************************************************************************** +/******************************************************************************* * * FUNCTION: acpi_unload_table_id * @@ -374,7 +373,7 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id) * * DESCRIPTION: Finds and verifies an ACPI table. * - *****************************************************************************/ + ******************************************************************************/ acpi_status acpi_get_table(char *signature, u32 instance, struct acpi_table_header **out_table) @@ -389,9 +388,8 @@ acpi_get_table(char *signature, return (AE_BAD_PARAMETER); } - /* - * Walk the root table list - */ + /* Walk the root table list */ + for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { if (!ACPI_COMPARE_NAME (&(acpi_gbl_root_table_list.tables[i].signature), @@ -526,17 +524,15 @@ static acpi_status acpi_tb_load_namespace(void) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); - /* - * Load and parse tables. - */ + /* Load and parse tables */ + status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } - /* - * Load any SSDT or PSDT tables. Note: Loop leaves tables locked - */ + /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ + (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { if ((!ACPI_COMPARE_NAME @@ -589,9 +585,8 @@ acpi_status acpi_load_tables(void) ACPI_FUNCTION_TRACE(acpi_load_tables); - /* - * Load the namespace from the tables - */ + /* Load the namespace from the tables */ + status = acpi_tb_load_namespace(); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c index b7fc8dd4334..85ea834199e 100644 --- a/drivers/acpi/acpica/tbxfroot.c +++ b/drivers/acpi/acpica/tbxfroot.c @@ -75,8 +75,8 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) * Note: Sometimes there exists more than one RSDP in memory; the valid * RSDP has a valid checksum, all others have an invalid checksum. */ - if (ACPI_STRNCMP((char *)rsdp, ACPI_SIG_RSDP, sizeof(ACPI_SIG_RSDP) - 1) - != 0) { + if (ACPI_STRNCMP((char *)rsdp, ACPI_SIG_RSDP, + sizeof(ACPI_SIG_RSDP) - 1) != 0) { /* Nope, BAD Signature */ diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c index cabe860ce00..919624f123d 100644 --- a/drivers/acpi/acpica/utcopy.c +++ b/drivers/acpi/acpica/utcopy.c @@ -496,8 +496,9 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object, case ACPI_TYPE_STRING: internal_object->string.pointer = - ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string. - length + 1); + ACPI_ALLOCATE_ZEROED((acpi_size) + external_object->string.length + 1); + if (!internal_object->string.pointer) { goto error_exit; } diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c index 9c4ae6f26b9..3b9152579d0 100644 --- a/drivers/acpi/acpica/uteval.c +++ b/drivers/acpi/acpica/uteval.c @@ -124,9 +124,8 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) /* Compare input string to static table of supported interfaces */ for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { - if (!ACPI_STRCMP - (string_desc->string.pointer, - acpi_interfaces_supported[i])) { + if (!ACPI_STRCMP(string_desc->string.pointer, + acpi_interfaces_supported[i])) { /* The interface is supported */ diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index 7fc35d33adb..256ce777856 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c @@ -746,7 +746,10 @@ acpi_status acpi_ut_init_globals(void) for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) { acpi_gbl_owner_id_mask[i] = 0; } - acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */ + + /* Last owner_iD is never valid */ + + acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* GPE support */ -- cgit v1.2.3 From 9892dd23cbbfab1f7d4818622296e415979a9c77 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 15:10:07 +0800 Subject: ACPICA: Optimize ACPI register locking Removed locking for reads from the ACPI bit registers in PM1 Status, Enable, Control, and PM2 Control. The lock is not required when reading the single-bit registers. The acpi_get_register_unlocked function is no longer needed and has been removed. This will improve performance for reads on these registers. ACPICA BZ 760. http://www.acpica.org/bugzilla/show_bug.cgi?id=760 Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/acpica/hwxface.c | 65 ++++++++++++++++++------------------------- 2 files changed, 28 insertions(+), 39 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 26e249e69ea..677ccb6bcee 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -365,7 +365,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) /* Wait until we enter sleep state */ do { - status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS, + status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index 4df9eacb7c8..c8100199634 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -242,24 +242,35 @@ ACPI_EXPORT_SYMBOL(acpi_write) /******************************************************************************* * - * FUNCTION: acpi_get_register_unlocked + * FUNCTION: acpi_get_register * - * PARAMETERS: register_id - ID of ACPI bit_register to access - * return_value - Value that was read from the register + * PARAMETERS: register_id - ID of ACPI Bit Register to access + * return_value - Value that was read from the register, + * normalized to bit position zero. * - * RETURN: Status and the value read from specified Register. Value + * RETURN: Status and the value read from the specified Register. Value * returned is normalized to bit0 (is shifted all the way right) * * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock. * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note: The hardware lock is not required when reading the ACPI bit registers + * since almost all of them are single bit and it does not matter that + * the parent hardware register can be split across two physical + * registers. The only multi-bit field is SLP_TYP in the PM1 control + * register, but this field does not cross an 8-bit boundary (nor does + * it make much sense to actually read this field.) + * ******************************************************************************/ -acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value) +acpi_status acpi_get_register(u32 register_id, u32 *return_value) { u32 register_value = 0; struct acpi_bit_register_info *bit_reg_info; acpi_status status; - ACPI_FUNCTION_TRACE(acpi_get_register_unlocked); + ACPI_FUNCTION_TRACE(acpi_get_register); /* Get the info structure corresponding to the requested ACPI Register */ @@ -268,7 +279,7 @@ acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value) return_ACPI_STATUS(AE_BAD_PARAMETER); } - /* Read from the register */ + /* Read the entire parent register */ status = acpi_hw_register_read(bit_reg_info->parent_register, ®ister_value); @@ -291,46 +302,24 @@ acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value) return_ACPI_STATUS(status); } -ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked) - -/******************************************************************************* - * - * FUNCTION: acpi_get_register - * - * PARAMETERS: register_id - ID of ACPI bit_register to access - * return_value - Value that was read from the register - * - * RETURN: Status and the value read from specified Register. Value - * returned is normalized to bit0 (is shifted all the way right) - * - * DESCRIPTION: ACPI bit_register read function. - * - ******************************************************************************/ -acpi_status acpi_get_register(u32 register_id, u32 *return_value) -{ - acpi_status status; - acpi_cpu_flags flags; - - flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); - status = acpi_get_register_unlocked(register_id, return_value); - acpi_os_release_lock(acpi_gbl_hardware_lock, flags); - - return (status); -} - ACPI_EXPORT_SYMBOL(acpi_get_register) /******************************************************************************* * * FUNCTION: acpi_set_register * - * PARAMETERS: register_id - ID of ACPI bit_register to access - * Value - (only used on write) value to write to the - * Register, NOT pre-normalized to the bit pos + * PARAMETERS: register_id - ID of ACPI Bit Register to access + * Value - Value to write to the register, in bit + * position zero. The bit is automaticallly + * shifted to the correct position. * * RETURN: Status * - * DESCRIPTION: ACPI Bit Register write function. + * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock + * since most operations require a read/modify/write sequence. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. * ******************************************************************************/ acpi_status acpi_set_register(u32 register_id, u32 value) -- cgit v1.2.3 From 50ffba1bd3120b069617455545bc27bcf3cf7579 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 23 Feb 2009 15:02:07 +0800 Subject: ACPICA: Rename ACPI bit register access functions Rename acpi_get_register and acpi_set_register to clarify the purpose of these functions. New names are acpi_read_bit_register and acpi_write_bit_register. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/evevent.c | 12 ++++++------ drivers/acpi/acpica/evmisc.c | 4 ++-- drivers/acpi/acpica/evxfevnt.c | 24 ++++++++++++------------ drivers/acpi/acpica/hwacpi.c | 2 +- drivers/acpi/acpica/hwsleep.c | 15 ++++++++------- drivers/acpi/acpica/hwxface.c | 16 ++++++++-------- 6 files changed, 37 insertions(+), 36 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c index 803edd9e3f6..246f8775ec1 100644 --- a/drivers/acpi/acpica/evevent.c +++ b/drivers/acpi/acpica/evevent.c @@ -204,8 +204,8 @@ static acpi_status acpi_ev_fixed_event_initialize(void) if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) { status = - acpi_set_register(acpi_gbl_fixed_event_info[i]. - enable_register_id, 0); + acpi_write_bit_register(acpi_gbl_fixed_event_info + [i].enable_register_id, 0); if (ACPI_FAILURE(status)) { return (status); } @@ -288,16 +288,16 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event) /* Clear the status bit */ - (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. - status_register_id, 1); + (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. + status_register_id, 1); /* * Make sure we've got a handler. If not, report an error. The event is * disabled to prevent further interrupts. */ if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { - (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, 0); + (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, 0); ACPI_ERROR((AE_INFO, "No installed handler for fixed event [%08X]", diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c index 5f893057bcc..0e9e12b2f2b 100644 --- a/drivers/acpi/acpica/evmisc.c +++ b/drivers/acpi/acpica/evmisc.c @@ -534,8 +534,8 @@ acpi_status acpi_ev_release_global_lock(void) */ if (pending) { status = - acpi_set_register(ACPI_BITREG_GLOBAL_LOCK_RELEASE, - 1); + acpi_write_bit_register + (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1); } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c index 35485e4b60a..484c9793ca0 100644 --- a/drivers/acpi/acpica/evxfevnt.c +++ b/drivers/acpi/acpica/evxfevnt.c @@ -172,8 +172,8 @@ acpi_status acpi_enable_event(u32 event, u32 flags) * register bit) */ status = - acpi_set_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, 1); + acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, 1); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -181,8 +181,8 @@ acpi_status acpi_enable_event(u32 event, u32 flags) /* Make sure that the hardware responded */ status = - acpi_get_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, &value); + acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, &value); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -354,15 +354,15 @@ acpi_status acpi_disable_event(u32 event, u32 flags) * register bit) */ status = - acpi_set_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, 0); + acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, 0); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } status = - acpi_get_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, &value); + acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. + enable_register_id, &value); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -407,8 +407,8 @@ acpi_status acpi_clear_event(u32 event) * register bit) */ status = - acpi_set_register(acpi_gbl_fixed_event_info[event]. - status_register_id, 1); + acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. + status_register_id, 1); return_ACPI_STATUS(status); } @@ -495,7 +495,7 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) /* Get the status of the requested fixed event */ status = - acpi_get_register(acpi_gbl_fixed_event_info[event]. + acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. enable_register_id, &value); if (ACPI_FAILURE(status)) return_ACPI_STATUS(status); @@ -503,7 +503,7 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) *event_status = value; status = - acpi_get_register(acpi_gbl_fixed_event_info[event]. + acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. status_register_id, &value); if (ACPI_FAILURE(status)) return_ACPI_STATUS(status); diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c index a9d4fea4167..8902db8c670 100644 --- a/drivers/acpi/acpica/hwacpi.c +++ b/drivers/acpi/acpica/hwacpi.c @@ -172,7 +172,7 @@ u32 acpi_hw_get_mode(void) return_UINT32(ACPI_SYS_MODE_ACPI); } - status = acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value); + status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value); if (ACPI_FAILURE(status)) { return_UINT32(ACPI_SYS_MODE_LEGACY); } diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 677ccb6bcee..78d62b8a5c3 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -250,7 +250,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) /* Clear wake status */ - status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); + status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -365,7 +365,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) /* Wait until we enter sleep state */ do { - status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, + status = acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); @@ -399,7 +399,7 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); - status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); + status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -431,7 +431,8 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) do { acpi_os_stall(1000); - status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value); + status = + acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -592,18 +593,18 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) * it to determine whether the system is rebooting or resuming. Clear * it for compatibility. */ - acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); + acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); acpi_gbl_system_awake_and_running = TRUE; /* Enable power button */ (void) - acpi_set_register(acpi_gbl_fixed_event_info + acpi_write_bit_register(acpi_gbl_fixed_event_info [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1); (void) - acpi_set_register(acpi_gbl_fixed_event_info + acpi_write_bit_register(acpi_gbl_fixed_event_info [ACPI_EVENT_POWER_BUTTON].status_register_id, 1); arg.integer.value = ACPI_SST_WORKING; diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index c8100199634..529251c7f91 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -242,7 +242,7 @@ ACPI_EXPORT_SYMBOL(acpi_write) /******************************************************************************* * - * FUNCTION: acpi_get_register + * FUNCTION: acpi_read_bit_register * * PARAMETERS: register_id - ID of ACPI Bit Register to access * return_value - Value that was read from the register, @@ -264,13 +264,13 @@ ACPI_EXPORT_SYMBOL(acpi_write) * it make much sense to actually read this field.) * ******************************************************************************/ -acpi_status acpi_get_register(u32 register_id, u32 *return_value) +acpi_status acpi_read_bit_register(u32 register_id, u32 *return_value) { u32 register_value = 0; struct acpi_bit_register_info *bit_reg_info; acpi_status status; - ACPI_FUNCTION_TRACE(acpi_get_register); + ACPI_FUNCTION_TRACE(acpi_read_bit_register); /* Get the info structure corresponding to the requested ACPI Register */ @@ -302,11 +302,11 @@ acpi_status acpi_get_register(u32 register_id, u32 *return_value) return_ACPI_STATUS(status); } -ACPI_EXPORT_SYMBOL(acpi_get_register) +ACPI_EXPORT_SYMBOL(acpi_read_bit_register) /******************************************************************************* * - * FUNCTION: acpi_set_register + * FUNCTION: acpi_write_bit_register * * PARAMETERS: register_id - ID of ACPI Bit Register to access * Value - Value to write to the register, in bit @@ -322,14 +322,14 @@ ACPI_EXPORT_SYMBOL(acpi_get_register) * PM2 Control. * ******************************************************************************/ -acpi_status acpi_set_register(u32 register_id, u32 value) +acpi_status acpi_write_bit_register(u32 register_id, u32 value) { u32 register_value = 0; struct acpi_bit_register_info *bit_reg_info; acpi_status status; acpi_cpu_flags lock_flags; - ACPI_FUNCTION_TRACE_U32(acpi_set_register, register_id); + ACPI_FUNCTION_TRACE_U32(acpi_write_bit_register, register_id); /* Get the info structure corresponding to the requested ACPI Register */ @@ -459,7 +459,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value) return_ACPI_STATUS(status); } -ACPI_EXPORT_SYMBOL(acpi_set_register) +ACPI_EXPORT_SYMBOL(acpi_write_bit_register) /******************************************************************************* * -- cgit v1.2.3 From 88dcb04a813265e1a5a1bc74af2db7efa7d62ee6 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 18 Feb 2009 16:01:04 +0800 Subject: ACPICA: Restructure bit register access functions Update code for acpi_read_bit_register and acpi_write_bit_register. Simplified code path, condensed duplicate code. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwxface.c | 177 +++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 115 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index 529251c7f91..caad51680bd 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -133,8 +133,8 @@ acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) *value = 0; /* - * Two address spaces supported: Memory or IO. - * PCI_Config is not supported here because the GAS struct is insufficient + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient */ switch (reg->space_id) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: @@ -266,11 +266,12 @@ ACPI_EXPORT_SYMBOL(acpi_write) ******************************************************************************/ acpi_status acpi_read_bit_register(u32 register_id, u32 *return_value) { - u32 register_value = 0; struct acpi_bit_register_info *bit_reg_info; + u32 register_value; + u32 value; acpi_status status; - ACPI_FUNCTION_TRACE(acpi_read_bit_register); + ACPI_FUNCTION_TRACE_U32(acpi_read_bit_register, register_id); /* Get the info structure corresponding to the requested ACPI Register */ @@ -283,23 +284,22 @@ acpi_status acpi_read_bit_register(u32 register_id, u32 *return_value) status = acpi_hw_register_read(bit_reg_info->parent_register, ®ister_value); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } - if (ACPI_SUCCESS(status)) { - - /* Normalize the value that was read */ - - register_value = - ((register_value & bit_reg_info->access_bit_mask) - >> bit_reg_info->bit_position); + /* Normalize the value that was read, mask off other bits */ - *return_value = register_value; + value = ((register_value & bit_reg_info->access_bit_mask) + >> bit_reg_info->bit_position); - ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n", - register_value, - bit_reg_info->parent_register)); - } + ACPI_DEBUG_PRINT((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n", + register_id, bit_reg_info->parent_register, + register_value, value)); - return_ACPI_STATUS(status); + *return_value = value; + return_ACPI_STATUS(AE_OK); } ACPI_EXPORT_SYMBOL(acpi_read_bit_register) @@ -321,13 +321,16 @@ ACPI_EXPORT_SYMBOL(acpi_read_bit_register) * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and * PM2 Control. * + * Note that at this level, the fact that there may be actually two + * hardware registers (A and B - and B may not exist) is abstracted. + * ******************************************************************************/ acpi_status acpi_write_bit_register(u32 register_id, u32 value) { - u32 register_value = 0; struct acpi_bit_register_info *bit_reg_info; - acpi_status status; acpi_cpu_flags lock_flags; + u32 register_value; + acpi_status status = AE_OK; ACPI_FUNCTION_TRACE_U32(acpi_write_bit_register, register_id); @@ -335,127 +338,71 @@ acpi_status acpi_write_bit_register(u32 register_id, u32 value) bit_reg_info = acpi_hw_get_bit_register_info(register_id); if (!bit_reg_info) { - ACPI_ERROR((AE_INFO, "Bad ACPI HW RegisterId: %X", - register_id)); return_ACPI_STATUS(AE_BAD_PARAMETER); } lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); - /* Always do a register read first so we can insert the new bits */ - - status = acpi_hw_register_read(bit_reg_info->parent_register, - ®ister_value); - if (ACPI_FAILURE(status)) { - goto unlock_and_exit; - } - /* - * Decode the Register ID - * Register ID = [Register block ID] | [bit ID] - * - * Check bit ID to fine locate Register offset. - * Check Mask to determine Register offset, and then read-write. + * At this point, we know that the parent register is one of the + * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control */ - switch (bit_reg_info->parent_register) { - case ACPI_REGISTER_PM1_STATUS: - - /* - * Status Registers are different from the rest. Clear by - * writing 1, and writing 0 has no effect. So, the only relevant - * information is the single bit we're interested in, all others should - * be written as 0 so they will be left unchanged. - */ - value = ACPI_REGISTER_PREPARE_BITS(value, - bit_reg_info->bit_position, - bit_reg_info-> - access_bit_mask); - if (value) { - status = - acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, - (u16) value); - register_value = 0; - } - break; - - case ACPI_REGISTER_PM1_ENABLE: - - ACPI_REGISTER_INSERT_VALUE(register_value, - bit_reg_info->bit_position, - bit_reg_info->access_bit_mask, - value); - - status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE, - (u16) register_value); - break; - - case ACPI_REGISTER_PM1_CONTROL: - + if (bit_reg_info->parent_register != ACPI_REGISTER_PM1_STATUS) { /* - * Write the PM1 Control register. - * Note that at this level, the fact that there are actually TWO - * registers (A and B - and B may not exist) is abstracted. + * 1) Case for PM1 Enable, PM1 Control, and PM2 Control + * + * Perform a register read to preserve the bits that we are not + * interested in */ - ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n", - register_value)); - - ACPI_REGISTER_INSERT_VALUE(register_value, - bit_reg_info->bit_position, - bit_reg_info->access_bit_mask, - value); - - status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, - (u16) register_value); - break; - - case ACPI_REGISTER_PM2_CONTROL: - - status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL, + status = acpi_hw_register_read(bit_reg_info->parent_register, ®ister_value); if (ACPI_FAILURE(status)) { goto unlock_and_exit; } - ACPI_DEBUG_PRINT((ACPI_DB_IO, - "PM2 control: Read %X from %8.8X%8.8X\n", - register_value, - ACPI_FORMAT_UINT64(acpi_gbl_FADT. - xpm2_control_block. - address))); - + /* + * Insert the input bit into the value that was just read + * and write the register + */ ACPI_REGISTER_INSERT_VALUE(register_value, bit_reg_info->bit_position, bit_reg_info->access_bit_mask, value); - ACPI_DEBUG_PRINT((ACPI_DB_IO, - "About to write %4.4X to %8.8X%8.8X\n", - register_value, - ACPI_FORMAT_UINT64(acpi_gbl_FADT. - xpm2_control_block. - address))); + status = acpi_hw_register_write(bit_reg_info->parent_register, + register_value); + } else { + /* + * 2) Case for PM1 Status + * + * The Status register is different from the rest. Clear an event + * by writing 1, writing 0 has no effect. So, the only relevant + * information is the single bit we're interested in, all others + * should be written as 0 so they will be left unchanged. + */ + register_value = ACPI_REGISTER_PREPARE_BITS(value, + bit_reg_info-> + bit_position, + bit_reg_info-> + access_bit_mask); - status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL, - (u8) (register_value)); - break; + /* No need to write the register if value is all zeros */ - default: - break; + if (register_value) { + status = + acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, + register_value); + } } - unlock_and_exit: - - acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); - - /* Normalize the value that was read */ + ACPI_DEBUG_PRINT((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n", + register_id, bit_reg_info->parent_register, value, + register_value)); - ACPI_DEBUG_EXEC(register_value = - ((register_value & bit_reg_info->access_bit_mask) >> - bit_reg_info->bit_position)); +unlock_and_exit: - ACPI_DEBUG_PRINT((ACPI_DB_IO, - "Set bits: %8.8X actual %8.8X register %X\n", value, - register_value, bit_reg_info->parent_register)); + acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); return_ACPI_STATUS(status); } -- cgit v1.2.3 From b6bc342dd543f40b6feccbaf6719d9f836c9964a Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 23 Feb 2009 10:26:19 +0800 Subject: ACPICA: Update table header print function Cleanup table header output. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/tbutils.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index dc45b49e5cb..ef7d2c2d8f0 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c @@ -177,19 +177,23 @@ acpi_tb_print_table_header(acpi_physical_address address, struct acpi_table_header *header) { + /* + * The reason that the Address is cast to a void pointer is so that we + * can use %p which will work properly on both 32-bit and 64-bit hosts. + */ if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { - /* FACS only has signature and length fields of common table header */ + /* FACS only has signature and length fields */ - ACPI_INFO((AE_INFO, "%4.4s %08lX, %04X", - header->signature, (unsigned long)address, + ACPI_INFO((AE_INFO, "%4.4s %p %05X", + header->signature, ACPI_CAST_PTR(void, address), header->length)); } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { /* RSDP has no common fields */ - ACPI_INFO((AE_INFO, "RSDP %08lX, %04X (r%d %6.6s)", - (unsigned long)address, + ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", + ACPI_CAST_PTR (void, address), (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> revision > 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, @@ -202,8 +206,8 @@ acpi_tb_print_table_header(acpi_physical_address address, /* Standard ACPI table with full common header */ ACPI_INFO((AE_INFO, - "%4.4s %08lX, %04X (r%d %6.6s %8.8s %8X %4.4s %8X)", - header->signature, (unsigned long)address, + "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", + header->signature, ACPI_CAST_PTR (void, address), header->length, header->revision, header->oem_id, header->oem_table_id, header->oem_revision, header->asl_compiler_id, -- cgit v1.2.3 From 768aaaf196e8a40f5cfc792d9d365795cc52ed13 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 6 Mar 2009 09:49:25 +0800 Subject: ACPICA: Add manifest constants for bit register values Add and deploy constants for the PM status/enable/control registers. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/evevent.c | 12 +++++++----- drivers/acpi/acpica/evmisc.c | 3 ++- drivers/acpi/acpica/evxfevnt.c | 6 +++--- drivers/acpi/acpica/hwsleep.c | 14 ++++++++++---- 4 files changed, 22 insertions(+), 13 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c index 246f8775ec1..cd55c774e88 100644 --- a/drivers/acpi/acpica/evevent.c +++ b/drivers/acpi/acpica/evevent.c @@ -183,7 +183,7 @@ acpi_status acpi_ev_install_xrupt_handlers(void) * * RETURN: Status * - * DESCRIPTION: Install the fixed event handlers and enable the fixed events. + * DESCRIPTION: Install the fixed event handlers and disable all fixed events. * ******************************************************************************/ @@ -200,12 +200,13 @@ static acpi_status acpi_ev_fixed_event_initialize(void) acpi_gbl_fixed_event_handlers[i].handler = NULL; acpi_gbl_fixed_event_handlers[i].context = NULL; - /* Enable the fixed event */ + /* Disable the fixed event */ if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) { status = acpi_write_bit_register(acpi_gbl_fixed_event_info - [i].enable_register_id, 0); + [i].enable_register_id, + ACPI_DISABLE_EVENT); if (ACPI_FAILURE(status)) { return (status); } @@ -289,7 +290,7 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event) /* Clear the status bit */ (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. - status_register_id, 1); + status_register_id, ACPI_CLEAR_STATUS); /* * Make sure we've got a handler. If not, report an error. The event is @@ -297,7 +298,8 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event) */ if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, 0); + enable_register_id, + ACPI_DISABLE_EVENT); ACPI_ERROR((AE_INFO, "No installed handler for fixed event [%08X]", diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c index 0e9e12b2f2b..417a9b920dd 100644 --- a/drivers/acpi/acpica/evmisc.c +++ b/drivers/acpi/acpica/evmisc.c @@ -535,7 +535,8 @@ acpi_status acpi_ev_release_global_lock(void) if (pending) { status = acpi_write_bit_register - (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1); + (ACPI_BITREG_GLOBAL_LOCK_RELEASE, + ACPI_ENABLE_EVENT); } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c index 484c9793ca0..d0a080747ec 100644 --- a/drivers/acpi/acpica/evxfevnt.c +++ b/drivers/acpi/acpica/evxfevnt.c @@ -173,7 +173,7 @@ acpi_status acpi_enable_event(u32 event, u32 flags) */ status = acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, 1); + enable_register_id, ACPI_ENABLE_EVENT); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -355,7 +355,7 @@ acpi_status acpi_disable_event(u32 event, u32 flags) */ status = acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. - enable_register_id, 0); + enable_register_id, ACPI_DISABLE_EVENT); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -408,7 +408,7 @@ acpi_status acpi_clear_event(u32 event) */ status = acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. - status_register_id, 1); + status_register_id, ACPI_CLEAR_STATUS); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 78d62b8a5c3..4d14b49a0f6 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -250,7 +250,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) /* Clear wake status */ - status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); + status = + acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -399,7 +400,10 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); - status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); + /* Clear the wake status bit (PM1) */ + + status = + acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -601,11 +605,13 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) (void) acpi_write_bit_register(acpi_gbl_fixed_event_info - [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1); + [ACPI_EVENT_POWER_BUTTON]. + enable_register_id, ACPI_ENABLE_EVENT); (void) acpi_write_bit_register(acpi_gbl_fixed_event_info - [ACPI_EVENT_POWER_BUTTON].status_register_id, 1); + [ACPI_EVENT_POWER_BUTTON]. + status_register_id, ACPI_CLEAR_STATUS); arg.integer.value = ACPI_SST_WORKING; status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); -- cgit v1.2.3 From d4913dc6d0c680aa106d1d80b5ad2a9325367afd Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 6 Mar 2009 10:05:18 +0800 Subject: ACPICA: Formatting update - no functional changes Split long lines, update comments. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/evgpe.c | 7 +++-- drivers/acpi/acpica/evgpeblk.c | 64 ++++++++++++++++++++---------------------- drivers/acpi/acpica/evmisc.c | 11 ++++---- drivers/acpi/acpica/evregion.c | 3 +- drivers/acpi/acpica/evrgnini.c | 22 +++++++-------- drivers/acpi/acpica/evxface.c | 3 +- drivers/acpi/acpica/evxfregn.c | 3 +- drivers/acpi/acpica/hwacpi.c | 3 +- drivers/acpi/acpica/hwgpe.c | 21 ++++++-------- drivers/acpi/acpica/hwsleep.c | 14 ++++----- drivers/acpi/acpica/hwxface.c | 3 +- drivers/acpi/acpica/nsaccess.c | 51 ++++++++++++++++----------------- drivers/acpi/acpica/nsalloc.c | 24 ++++++---------- drivers/acpi/acpica/nsdump.c | 16 +++++------ drivers/acpi/acpica/nsinit.c | 19 +++++++------ drivers/acpi/acpica/nsload.c | 4 +-- drivers/acpi/acpica/nsparse.c | 10 +++---- drivers/acpi/acpica/nspredef.c | 6 ++-- drivers/acpi/acpica/nssearch.c | 14 ++++----- drivers/acpi/acpica/nsutils.c | 25 ++++++++--------- drivers/acpi/acpica/nswalk.c | 12 ++++---- 21 files changed, 161 insertions(+), 174 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index f345ced3647..b9d8ee69ca6 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c @@ -88,10 +88,10 @@ acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type) status = acpi_ev_disable_gpe(gpe_event_info); - /* Type was validated above */ + /* Clear the type bits and insert the new Type */ - gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ - gpe_event_info->flags |= type; /* Insert type */ + gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; + gpe_event_info->flags |= type; return_ACPI_STATUS(status); } @@ -122,6 +122,7 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info, if (!gpe_register_info) { return_ACPI_STATUS(AE_NOT_EXIST); } + register_bit = (u8) (1 << (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number)); diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index f7b3d2af940..7b346363942 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c @@ -104,9 +104,9 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info) while (gpe_block) { if ((&gpe_block->event_info[0] <= gpe_event_info) && - (&gpe_block-> - event_info[((acpi_size) gpe_block-> - register_count) * 8] > + (&gpe_block->event_info[((acpi_size) + gpe_block-> + register_count) * 8] > gpe_event_info)) { return (TRUE); } @@ -210,10 +210,9 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, /* Now look at the individual GPEs in this byte register */ for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - gpe_event_info = - &gpe_block-> - event_info[((acpi_size) i * - ACPI_GPE_REGISTER_WIDTH) + j]; + gpe_event_info = &gpe_block->event_info[((acpi_size) i * + ACPI_GPE_REGISTER_WIDTH) + + j]; if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { @@ -293,8 +292,8 @@ acpi_ev_save_method_info(acpi_handle obj_handle, /* Unknown method type, just ignore it! */ ACPI_DEBUG_PRINT((ACPI_DB_LOAD, - "Ignoring unknown GPE method type: %s (name not of form _Lxx or _Exx)", - name)); + "Ignoring unknown GPE method type: %s " + "(name not of form _Lxx or _Exx)", name)); return_ACPI_STATUS(AE_OK); } @@ -306,17 +305,16 @@ acpi_ev_save_method_info(acpi_handle obj_handle, /* Conversion failed; invalid method, just ignore it */ ACPI_DEBUG_PRINT((ACPI_DB_LOAD, - "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)", - name)); + "Could not extract GPE number from name: %s " + "(name is not of form _Lxx or _Exx)", name)); return_ACPI_STATUS(AE_OK); } /* Ensure that we have a valid GPE number for this GPE block */ if ((gpe_number < gpe_block->block_base_number) || - (gpe_number >= - (gpe_block->block_base_number + - (gpe_block->register_count * 8)))) { + (gpe_number >= (gpe_block->block_base_number + + (gpe_block->register_count * 8)))) { /* * Not valid for this GPE block, just ignore it. However, it may be * valid for a different GPE block, since GPE0 and GPE1 methods both @@ -423,9 +421,9 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, if ((obj_desc->package.count < 2) || ((obj_desc->package.elements[0])->common.type != - ACPI_TYPE_LOCAL_REFERENCE) - || ((obj_desc->package.elements[1])->common.type != - ACPI_TYPE_INTEGER)) { + ACPI_TYPE_LOCAL_REFERENCE) || + ((obj_desc->package.elements[1])->common.type != + ACPI_TYPE_INTEGER)) { goto cleanup; } @@ -450,11 +448,11 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, */ if ((gpe_device == target_gpe_device) && (gpe_number >= gpe_block->block_base_number) && - (gpe_number < - gpe_block->block_base_number + (gpe_block->register_count * 8))) { - gpe_event_info = - &gpe_block->event_info[gpe_number - - gpe_block->block_base_number]; + (gpe_number < gpe_block->block_base_number + + (gpe_block->register_count * 8))) { + gpe_event_info = &gpe_block->event_info[gpe_number - + gpe_block-> + block_base_number]; /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ @@ -1033,8 +1031,8 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, * 1) are "runtime" or "run/wake" GPEs, and * 2) have a corresponding _Lxx or _Exx method * - * Any other GPEs within this block must be enabled via the acpi_enable_gpe() - * external interface. + * Any other GPEs within this block must be enabled via the + * acpi_enable_gpe() external interface. */ wake_gpe_count = 0; gpe_enabled_count = 0; @@ -1044,14 +1042,13 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, /* Get the info block for this particular GPE */ - gpe_event_info = - &gpe_block-> - event_info[((acpi_size) i * - ACPI_GPE_REGISTER_WIDTH) + j]; + gpe_event_info = &gpe_block->event_info[((acpi_size) i * + ACPI_GPE_REGISTER_WIDTH) + + j]; if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == - ACPI_GPE_DISPATCH_METHOD) - && (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { + ACPI_GPE_DISPATCH_METHOD) && + (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { gpe_enabled_count++; } @@ -1105,8 +1102,8 @@ acpi_status acpi_ev_gpe_initialize(void) /* * Initialize the GPE Block(s) defined in the FADT * - * Why the GPE register block lengths are divided by 2: From the ACPI Spec, - * section "General-Purpose Event Registers", we have: + * Why the GPE register block lengths are divided by 2: From the ACPI + * Spec, section "General-Purpose Event Registers", we have: * * "Each register block contains two registers of equal length * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the @@ -1163,7 +1160,8 @@ acpi_status acpi_ev_gpe_initialize(void) if ((register_count0) && (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) { ACPI_ERROR((AE_INFO, - "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1", + "GPE0 block (GPE 0 to %d) overlaps the GPE1 block " + "(GPE %d to %d) - Ignoring GPE1", gpe_number_max, acpi_gbl_FADT.gpe1_base, acpi_gbl_FADT.gpe1_base + ((register_count1 * diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c index 417a9b920dd..ce224e1eaa8 100644 --- a/drivers/acpi/acpica/evmisc.c +++ b/drivers/acpi/acpica/evmisc.c @@ -163,10 +163,10 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, * 2) Global device notify handler * 3) Per-device notify handler */ - if ((acpi_gbl_system_notify.handler - && (notify_value <= ACPI_MAX_SYS_NOTIFY)) - || (acpi_gbl_device_notify.handler - && (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) { + if ((acpi_gbl_system_notify.handler && + (notify_value <= ACPI_MAX_SYS_NOTIFY)) || + (acpi_gbl_device_notify.handler && + (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) { notify_info = acpi_ut_create_generic_state(); if (!notify_info) { return (AE_NO_MEMORY); @@ -174,7 +174,8 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, if (!handler_obj) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Executing system notify handler for Notify (%4.4s, %X) node %p\n", + "Executing system notify handler for Notify (%4.4s, %X) " + "node %p\n", acpi_ut_get_node_name(node), notify_value, node)); } diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c index 86cbbdbfc5c..538d6326455 100644 --- a/drivers/acpi/acpica/evregion.c +++ b/drivers/acpi/acpica/evregion.c @@ -703,7 +703,8 @@ acpi_ev_install_handler(acpi_handle obj_handle, if (next_handler_obj->address_space.space_id == handler_obj->address_space.space_id) { ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, - "Found handler for region [%s] in device %p(%p) handler %p\n", + "Found handler for region [%s] in device %p(%p) " + "handler %p\n", acpi_ut_get_region_name (handler_obj->address_space. space_id), obj_desc, diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c index f3f1fb45c3d..284a7becbe9 100644 --- a/drivers/acpi/acpica/evrgnini.c +++ b/drivers/acpi/acpica/evrgnini.c @@ -241,7 +241,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, status = AE_OK; } else { ACPI_EXCEPTION((AE_INFO, status, - "Could not install PciConfig handler for Root Bridge %4.4s", + "Could not install PciConfig handler " + "for Root Bridge %4.4s", acpi_ut_get_node_name (pci_root_node))); } @@ -293,9 +294,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, * Get the PCI device and function numbers from the _ADR object contained * in the parent's scope. */ - status = - acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, pci_device_node, - &pci_value); + status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, + pci_device_node, &pci_value); /* * The default is zero, and since the allocation above zeroed the data, @@ -308,18 +308,16 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, /* The PCI segment number comes from the _SEG method */ - status = - acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node, - &pci_value); + status = acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, + pci_root_node, &pci_value); if (ACPI_SUCCESS(status)) { pci_id->segment = ACPI_LOWORD(pci_value); } /* The PCI bus number comes from the _BBN method */ - status = - acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node, - &pci_value); + status = acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, + pci_root_node, &pci_value); if (ACPI_SUCCESS(status)) { pci_id->bus = ACPI_LOWORD(pci_value); } @@ -632,8 +630,8 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj, acpi_ns_locked); /* - * Tell all users that this region is usable by running the _REG - * method + * Tell all users that this region is usable by + * running the _REG method */ if (acpi_ns_locked) { status = diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c index 3aca9010a11..10b8543dd46 100644 --- a/drivers/acpi/acpica/evxface.c +++ b/drivers/acpi/acpica/evxface.c @@ -631,7 +631,8 @@ acpi_install_gpe_handler(acpi_handle gpe_device, /* Setup up dispatch flags to indicate handler (vs. method) */ - gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ + gpe_event_info->flags &= + ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); acpi_os_release_lock(acpi_gbl_gpe_lock, flags); diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c index 479e7a3721b..7c3d2d356ff 100644 --- a/drivers/acpi/acpica/evxfregn.c +++ b/drivers/acpi/acpica/evxfregn.c @@ -193,7 +193,8 @@ acpi_remove_address_space_handler(acpi_handle device, /* Matched space_id, first dereference this in the Regions */ ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, - "Removing address handler %p(%p) for region %s on Device %p(%p)\n", + "Removing address handler %p(%p) for region %s " + "on Device %p(%p)\n", handler_obj, handler, acpi_ut_get_region_name(space_id), node, obj_desc)); diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c index 8902db8c670..e7949b13336 100644 --- a/drivers/acpi/acpica/hwacpi.c +++ b/drivers/acpi/acpica/hwacpi.c @@ -86,7 +86,8 @@ acpi_status acpi_hw_set_mode(u32 mode) */ if (!acpi_gbl_FADT.acpi_enable && !acpi_gbl_FADT.acpi_disable) { ACPI_ERROR((AE_INFO, - "No ACPI mode transition supported in this system (enable/disable both zero)")); + "No ACPI mode transition supported in this system " + "(enable/disable both zero)")); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c index 2013b66745d..d3b7e37c9ee 100644 --- a/drivers/acpi/acpica/hwgpe.c +++ b/drivers/acpi/acpica/hwgpe.c @@ -89,10 +89,9 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) /* Clear just the bit that corresponds to this GPE */ - ACPI_CLEAR_BIT(enable_mask, - ((u32) 1 << - (gpe_event_info->gpe_number - - gpe_register_info->base_gpe_number))); + ACPI_CLEAR_BIT(enable_mask, ((u32)1 << + (gpe_event_info->gpe_number - + gpe_register_info->base_gpe_number))); /* Write the updated enable mask */ @@ -156,10 +155,9 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) ACPI_FUNCTION_ENTRY(); - register_bit = (u8) - (1 << - (gpe_event_info->gpe_number - - gpe_event_info->register_info->base_gpe_number)); + register_bit = (u8)(1 << + (gpe_event_info->gpe_number - + gpe_event_info->register_info->base_gpe_number)); /* * Write a one to the appropriate bit in the status register to @@ -206,10 +204,9 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, /* Get the register bitmask for this GPE */ - register_bit = (u8) - (1 << - (gpe_event_info->gpe_number - - gpe_event_info->register_info->base_gpe_number)); + register_bit = (u8)(1 << + (gpe_event_info->gpe_number - + gpe_event_info->register_info->base_gpe_number)); /* GPE currently enabled? (enabled for runtime?) */ diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 4d14b49a0f6..2ea4c59e883 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -349,8 +349,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) * Wait ten seconds, then try again. This is to get S4/S5 to work on * all machines. * - * We wait so long to allow chipsets that poll this reg very slowly to - * still read the right value. Ideally, this block would go + * We wait so long to allow chipsets that poll this reg very slowly + * to still read the right value. Ideally, this block would go * away entirely. */ acpi_os_stall(10000000); @@ -501,12 +501,10 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) /* Insert the SLP_TYP bits */ - pm1a_control |= - (acpi_gbl_sleep_type_a << sleep_type_reg_info-> - bit_position); - pm1b_control |= - (acpi_gbl_sleep_type_b << sleep_type_reg_info-> - bit_position); + pm1a_control |= (acpi_gbl_sleep_type_a << + sleep_type_reg_info->bit_position); + pm1b_control |= (acpi_gbl_sleep_type_b << + sleep_type_reg_info->bit_position); /* Write the control registers and ignore any errors */ diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index caad51680bd..26e66427f4f 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -494,7 +494,8 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) ((info->return_object->package.elements[1])->common.type != ACPI_TYPE_INTEGER)) { ACPI_ERROR((AE_INFO, - "Sleep State return package elements are not both Integers (%s, %s)", + "Sleep State return package elements are not both Integers " + "(%s, %s)", acpi_ut_get_object_type_name(info->return_object-> package.elements[0]), acpi_ut_get_object_type_name(info->return_object-> diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index b6968a65cd4..9c3cdbe2d82 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c @@ -118,9 +118,8 @@ acpi_status acpi_ns_root_initialize(void) } /* - * Name entered successfully. - * If entry in pre_defined_names[] specifies an - * initial value, create the initial value. + * Name entered successfully. If entry in pre_defined_names[] specifies + * an initial value, create the initial value. */ if (init_val->val) { status = acpi_os_predefined_override(init_val, &val); @@ -178,9 +177,8 @@ acpi_status acpi_ns_root_initialize(void) case ACPI_TYPE_STRING: - /* - * Build an object around the static string - */ + /* Build an object around the static string */ + obj_desc->string.length = (u32) ACPI_STRLEN(val); obj_desc->string.pointer = val; @@ -314,10 +312,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, return_ACPI_STATUS(AE_NO_NAMESPACE); } - /* - * Get the prefix scope. - * A null scope means use the root scope - */ + /* Get the prefix scope. A null scope means use the root scope */ + if ((!scope_info) || (!scope_info->scope.node)) { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Null scope prefix, using root node (%p)\n", @@ -337,8 +333,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) { /* * This node might not be a actual "scope" node (such as a - * Device/Method, etc.) It could be a Package or other object node. - * Backup up the tree to find the containing scope node. + * Device/Method, etc.) It could be a Package or other object + * node. Backup up the tree to find the containing scope node. */ while (!acpi_ns_opens_scope(prefix_node->type) && prefix_node->type != ACPI_TYPE_ANY) { @@ -348,7 +344,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, } } - /* Save type TBD: may be no longer necessary */ + /* Save type. TBD: may be no longer necessary */ type_to_check_for = type; @@ -413,6 +409,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, /* Name is fully qualified, no search rules apply */ search_parent_flag = ACPI_NS_NO_UPSEARCH; + /* * Point past this prefix to the name segment * part or the next Parent Prefix @@ -428,7 +425,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, /* Current scope has no parent scope */ ACPI_ERROR((AE_INFO, - "ACPI path has too many parent prefixes (^) - reached beyond root node")); + "ACPI path has too many parent prefixes (^) " + "- reached beyond root node")); return_ACPI_STATUS(AE_NOT_FOUND); } } @@ -530,9 +528,9 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, while (num_segments && current_node) { num_segments--; if (!num_segments) { - /* - * This is the last segment, enable typechecking - */ + + /* This is the last segment, enable typechecking */ + this_search_type = type; /* @@ -583,9 +581,9 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, if (num_segments > 0) { /* * If we have an alias to an object that opens a scope (such as a - * device or processor), we need to dereference the alias here so that - * we can access any children of the original node (via the remaining - * segments). + * device or processor), we need to dereference the alias here so + * that we can access any children of the original node (via the + * remaining segments). */ if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) { if (!this_node->object) { @@ -593,8 +591,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, } if (acpi_ns_opens_scope - (((struct acpi_namespace_node *)this_node-> - object)->type)) { + (((struct acpi_namespace_node *) + this_node->object)->type)) { this_node = (struct acpi_namespace_node *) this_node->object; @@ -638,8 +636,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, /* * If this is the last name segment and we are not looking for a - * specific type, but the type of found object is known, use that type - * to (later) see if it opens a scope. + * specific type, but the type of found object is known, use that + * type to (later) see if it opens a scope. */ if (type == ACPI_TYPE_ANY) { type = this_node->type; @@ -652,9 +650,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, current_node = this_node; } - /* - * Always check if we need to open a new scope - */ + /* Always check if we need to open a new scope */ + if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) { /* * If entry is a type which opens a scope, push the new scope on the diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c index f976d848fe8..aceb9311196 100644 --- a/drivers/acpi/acpica/nsalloc.c +++ b/drivers/acpi/acpica/nsalloc.c @@ -76,8 +76,7 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name) ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++); #ifdef ACPI_DBG_TRACK_ALLOCATIONS - temp = - acpi_gbl_ns_node_list->total_allocated - + temp = acpi_gbl_ns_node_list->total_allocated - acpi_gbl_ns_node_list->total_freed; if (temp > acpi_gbl_ns_node_list->max_occupied) { acpi_gbl_ns_node_list->max_occupied = temp; @@ -145,9 +144,8 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node) ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); - /* - * Detach an object if there is one, then delete the node - */ + /* Detach an object if there is one, then delete the node */ + acpi_ns_detach_object(node); (void)acpi_os_release_object(acpi_gbl_namespace_cache, node); return_VOID; @@ -183,9 +181,8 @@ void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namesp ACPI_FUNCTION_TRACE(ns_install_node); /* - * Get the owner ID from the Walk state - * The owner ID is used to track table deletion and - * deletion of objects created by methods + * Get the owner ID from the Walk state. The owner ID is used to track + * table deletion and deletion of objects created by methods. */ if (walk_state) { owner_id = walk_state->owner_id; @@ -260,9 +257,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) return_VOID; } - /* - * Deallocate all children at this level - */ + /* Deallocate all children at this level */ + do { /* Get the things we need */ @@ -285,9 +281,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) "Object %p, Remaining %X\n", child_node, acpi_gbl_current_node_count)); - /* - * Detach an object if there is one, then free the child node - */ + /* Detach an object if there is one, then free the child node */ + acpi_ns_detach_object(child_node); /* Now we can delete the node */ @@ -304,7 +299,6 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) /* Clear the parent's child pointer */ parent_node->child = NULL; - return_VOID; } diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c index 7bfa6c1286f..2bad613db73 100644 --- a/drivers/acpi/acpica/nsdump.c +++ b/drivers/acpi/acpica/nsdump.c @@ -220,9 +220,8 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); } - /* - * Now we can print out the pertinent information - */ + /* Now we can print out the pertinent information */ + acpi_os_printf(" %-12s %p %2.2X ", acpi_ut_get_type_name(type), this_node, this_node->owner_id); @@ -545,9 +544,8 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, goto cleanup; } - /* - * Valid object, get the pointer to next level, if any - */ + /* Valid object, get the pointer to next level, if any */ + switch (obj_type) { case ACPI_TYPE_BUFFER: case ACPI_TYPE_STRING: @@ -608,14 +606,14 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, * display_type - 0 or ACPI_DISPLAY_SUMMARY * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX * for an effectively unlimited depth. - * owner_id - Dump only objects owned by this ID. Use + * owner_id - Dump only objects owned by this ID. Use * ACPI_UINT32_MAX to match all owners. * start_handle - Where in namespace to start/end search * * RETURN: None * - * DESCRIPTION: Dump typed objects within the loaded namespace. - * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object. + * DESCRIPTION: Dump typed objects within the loaded namespace. Uses + * acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object. * ******************************************************************************/ diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c index 13501cb8186..2adfcf329e1 100644 --- a/drivers/acpi/acpica/nsinit.c +++ b/drivers/acpi/acpica/nsinit.c @@ -103,7 +103,8 @@ acpi_status acpi_ns_initialize_objects(void) } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, - "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", + "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " + "Buffers %hd/%hd Packages (%hd nodes)\n", info.op_region_init, info.op_region_count, info.field_init, info.field_count, info.buffer_init, info.buffer_count, @@ -148,7 +149,8 @@ acpi_status acpi_ns_initialize_devices(void) info.num_INI = 0; ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, - "Initializing Device/Processor/Thermal objects by executing _INI methods:")); + "Initializing Device/Processor/Thermal objects " + "by executing _INI methods:")); /* Tree analysis: find all subtrees that contain _INI methods */ @@ -180,7 +182,8 @@ acpi_status acpi_ns_initialize_devices(void) } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, - "\nExecuted %hd _INI methods requiring %hd _STA executions (examined %hd objects)\n", + "\nExecuted %hd _INI methods requiring %hd _STA executions " + "(examined %hd objects)\n", info.num_INI, info.num_STA, info.device_count)); return_ACPI_STATUS(status); @@ -263,16 +266,14 @@ acpi_ns_init_one_object(acpi_handle obj_handle, return (AE_OK); } - /* - * If the object is already initialized, nothing else to do - */ + /* If the object is already initialized, nothing else to do */ + if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { return (AE_OK); } - /* - * Must lock the interpreter before executing AML code - */ + /* Must lock the interpreter before executing AML code */ + acpi_ex_enter_interpreter(); /* diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c index a0ba9e12379..dcd7a6adbbb 100644 --- a/drivers/acpi/acpica/nsload.c +++ b/drivers/acpi/acpica/nsload.c @@ -128,12 +128,12 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node) * parse trees. */ ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "**** Begin Table Method Parsing and Object Initialization ****\n")); + "**** Begin Table Method Parsing and Object Initialization\n")); status = acpi_ds_initialize_objects(table_index, node); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "**** Completed Table Method Parsing and Object Initialization ****\n")); + "**** Completed Table Method Parsing and Object Initialization\n")); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c index b9e8d0070b6..662a4bd5b62 100644 --- a/drivers/acpi/acpica/nsparse.c +++ b/drivers/acpi/acpica/nsparse.c @@ -176,9 +176,8 @@ acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node) * performs another complete parse of the AML. */ ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n")); - status = - acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS1, table_index, - start_node); + status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS1, + table_index, start_node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -193,9 +192,8 @@ acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node) * parse objects are all cached. */ ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n")); - status = - acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS2, table_index, - start_node); + status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS2, + table_index, start_node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 72dd7b19852..0d0b4ee1358 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c @@ -302,7 +302,8 @@ acpi_ns_check_parameter_count(char *pathname, if ((user_param_count != required_params_current) && (user_param_count != required_params_old)) { ACPI_WARNING((AE_INFO, - "%s: Parameter count mismatch - caller passed %d, ACPI requires %d", + "%s: Parameter count mismatch - " + "caller passed %d, ACPI requires %d", pathname, user_param_count, required_params_current)); } @@ -974,7 +975,8 @@ acpi_ns_check_reference(char *pathname, } ACPI_WARNING((AE_INFO, - "%s: Return type mismatch - unexpected reference object type [%s] %2.2X", + "%s: Return type mismatch - " + "unexpected reference object type [%s] %2.2X", pathname, acpi_ut_get_reference_name(return_object), return_object->reference.class)); diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c index 6fea13f3f52..f9b4f51bf8f 100644 --- a/drivers/acpi/acpica/nssearch.c +++ b/drivers/acpi/acpica/nssearch.c @@ -167,7 +167,8 @@ acpi_ns_search_one_scope(u32 target_name, /* Searched entire namespace level, not found */ ACPI_DEBUG_PRINT((ACPI_DB_NAMES, - "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", + "Name [%4.4s] (%s) not found in search in scope [%4.4s] " + "%p first child %p\n", ACPI_CAST_PTR(char, &target_name), acpi_ut_get_type_name(type), acpi_ut_get_node_name(parent_node), parent_node, @@ -239,9 +240,8 @@ acpi_ns_search_parent_tree(u32 target_name, acpi_ut_get_node_name(parent_node), ACPI_CAST_PTR(char, &target_name))); - /* - * Search parents until target is found or we have backed up to the root - */ + /* Search parents until target is found or we have backed up to the root */ + while (parent_node) { /* * Search parent scope. Use TYPE_ANY because we don't care about the @@ -395,9 +395,9 @@ acpi_ns_search_and_enter(u32 target_name, return_ACPI_STATUS(AE_NO_MEMORY); } #ifdef ACPI_ASL_COMPILER - /* - * Node is an object defined by an External() statement - */ + + /* Node is an object defined by an External() statement */ + if (flags & ACPI_NS_EXTERNAL) { new_node->flags |= ANOBJ_IS_EXTERNAL; } diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index d30b0e65ab3..78277ed0833 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c @@ -325,9 +325,8 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info) next_external_char++; } } else { - /* - * Handle Carat prefixes - */ + /* Handle Carat prefixes */ + while (*next_external_char == '^') { info->num_carats++; next_external_char++; @@ -552,9 +551,8 @@ acpi_ns_externalize_name(u32 internal_name_length, return_ACPI_STATUS(AE_BAD_PARAMETER); } - /* - * Check for a prefix (one '\' | one or more '^'). - */ + /* Check for a prefix (one '\' | one or more '^') */ + switch (internal_name[0]) { case '\\': prefix_length = 1; @@ -580,7 +578,7 @@ acpi_ns_externalize_name(u32 internal_name_length, } /* - * Check for object names. Note that there could be 0-255 of these + * Check for object names. Note that there could be 0-255 of these * 4-byte elements. */ if (prefix_length < internal_name_length) { @@ -637,9 +635,8 @@ acpi_ns_externalize_name(u32 internal_name_length, return_ACPI_STATUS(AE_BAD_PATHNAME); } - /* - * Build converted_name - */ + /* Build the converted_name */ + *converted_name = ACPI_ALLOCATE_ZEROED(required_length); if (!(*converted_name)) { return_ACPI_STATUS(AE_NO_MEMORY); @@ -685,6 +682,9 @@ acpi_ns_externalize_name(u32 internal_name_length, * and keep all pointers within this subsystem - however this introduces * more (and perhaps unnecessary) overhead. * + * The current implemenation is basically a placeholder until such time comes + * that it is needed. + * ******************************************************************************/ struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle) @@ -692,9 +692,8 @@ struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle) ACPI_FUNCTION_ENTRY(); - /* - * Simple implementation - */ + /* Parameter validation */ + if ((!handle) || (handle == ACPI_ROOT_OBJECT)) { return (acpi_gbl_root_node); } diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c index 200895fa272..83e3aa6d4b9 100644 --- a/drivers/acpi/acpica/nswalk.c +++ b/drivers/acpi/acpica/nswalk.c @@ -135,8 +135,8 @@ struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct * starting (and ending) at the node specified by start_handle. * The user_function is called whenever a node that matches * the type parameter is found. If the user function returns - * a non-zero value, the search is terminated immediately and this - * value is returned to the caller. + * a non-zero value, the search is terminated immediately and + * this value is returned to the caller. * * The point of this procedure is to provide a generic namespace * walk routine that can be called from multiple places to @@ -200,10 +200,10 @@ acpi_ns_walk_namespace(acpi_object_type type, /* * Ignore all temporary namespace nodes (created during control * method execution) unless told otherwise. These temporary nodes - * can cause a race condition because they can be deleted during the - * execution of the user function (if the namespace is unlocked before - * invocation of the user function.) Only the debugger namespace dump - * will examine the temporary nodes. + * can cause a race condition because they can be deleted during + * the execution of the user function (if the namespace is + * unlocked before invocation of the user function.) Only the + * debugger namespace dump will examine the temporary nodes. */ if ((child_node->flags & ANOBJ_TEMPORARY) && !(flags & ACPI_NS_WALK_TEMP_NODES)) { -- cgit v1.2.3 From aab61b676a024d3527f6201e2b31285a96f7a1d2 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 6 Mar 2009 10:09:00 +0800 Subject: ACPICA: FADT: Fix extraneous length mismatch warning Incorrect register length mismatch between the 32 and 64 bit registers in some cases. Code was was checking the wrong pointer for non-zero, should be looking at the address within the GAS structure. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/tbfadt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index af8fbe12d8b..ff89cfee0e7 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -491,7 +491,8 @@ static void acpi_tb_validate_fadt(void) * For each extended field, check for length mismatch between the * legacy length field and the corresponding 64-bit X length field. */ - if (address64 && (address64->bit_width != ACPI_MUL_8(length))) { + if (address64->address && + (address64->bit_width != ACPI_MUL_8(length))) { ACPI_WARNING((AE_INFO, "32/64X length mismatch in %s: %d/%d", name, ACPI_MUL_8(length), -- cgit v1.2.3 From 8a335a2331c72e60c6b3ef09b2dedd3ba00da1b1 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 9 Mar 2009 16:31:04 +0800 Subject: ACPICA: Fix AcpiWalkNamespace race condition with table unload Added a reader/writer locking mechanism to allow multiple concurrent namespace walks (readers), but a dynamic table unload will have exclusive access to the namespace. This fixes a problem where a table unload could delete the portion of the namespace that is currently being examined by a walk. Adds a new file, utlock.c that implements the reader/writer lock mechanism. ACPICA BZ 749. http://www.acpica.org/bugzilla/show_bug.cgi?id=749 Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/Makefile | 2 +- drivers/acpi/acpica/acglobal.h | 4 + drivers/acpi/acpica/aclocal.h | 8 ++ drivers/acpi/acpica/actables.h | 2 +- drivers/acpi/acpica/acutils.h | 15 ++++ drivers/acpi/acpica/dsinit.c | 16 +++- drivers/acpi/acpica/exconfig.c | 13 +-- drivers/acpi/acpica/nsxfeval.c | 33 ++++++-- drivers/acpi/acpica/tbinstal.c | 45 +++++++++-- drivers/acpi/acpica/utlock.c | 175 +++++++++++++++++++++++++++++++++++++++++ drivers/acpi/acpica/utmutex.c | 23 ++++-- 11 files changed, 303 insertions(+), 33 deletions(-) create mode 100644 drivers/acpi/acpica/utlock.c (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 3f23298ee3f..290be74b774 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile @@ -41,4 +41,4 @@ obj-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o obj-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ - utstate.o utmutex.o utobject.o utresrc.o + utstate.o utmutex.o utobject.o utresrc.o utlock.o diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index f3e87ba43db..f431b997d2f 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h @@ -165,6 +165,10 @@ ACPI_EXTERN u8 acpi_gbl_integer_bit_width; ACPI_EXTERN u8 acpi_gbl_integer_byte_width; ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; +/* Reader/Writer lock is used for namespace walk and dynamic table unload */ + +ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock; + /***************************************************************************** * * Mutual exlusion within ACPICA subsystem diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 6feebc8f789..18a8d96eaa4 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -108,6 +108,14 @@ static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = { #endif #endif +/* Lock structure for reader/writer interfaces */ + +struct acpi_rw_lock { + acpi_mutex writer_mutex; + acpi_mutex reader_mutex; + u32 num_readers; +}; + /* * Predefined handles for spinlocks used within the subsystem. * These spinlocks are created by acpi_ut_mutex_initialize diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h index d8f8c5df4fb..01c76b8ea7b 100644 --- a/drivers/acpi/acpica/actables.h +++ b/drivers/acpi/acpica/actables.h @@ -79,7 +79,7 @@ void acpi_tb_delete_table(struct acpi_table_desc *table_desc); void acpi_tb_terminate(void); -void acpi_tb_delete_namespace_by_owner(u32 table_index); +acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index); acpi_status acpi_tb_allocate_owner_id(u32 table_index); diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 80d8813484f..897810ba0cc 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h @@ -345,6 +345,21 @@ acpi_ut_execute_UID(struct acpi_namespace_node *device_node, acpi_status acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest); +/* + * utlock - reader/writer locks + */ +acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock); + +void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock); + +acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock); + +acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock); + +acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock); + +void acpi_ut_release_write_lock(struct acpi_rw_lock *lock); + /* * utobject - internal object create/delete/cache routines */ diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c index eb144b13d8f..3aae13f30c5 100644 --- a/drivers/acpi/acpica/dsinit.c +++ b/drivers/acpi/acpica/dsinit.c @@ -180,11 +180,23 @@ acpi_ds_initialize_objects(u32 table_index, /* Walk entire namespace from the supplied root */ - status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, - acpi_ds_init_one_object, &info, NULL); + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + /* + * We don't use acpi_walk_namespace since we do not want to acquire + * the namespace reader lock. + */ + status = + acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object, + &info, NULL); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); } + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); status = acpi_get_table_by_index(table_index, &table); if (ACPI_FAILURE(status)) { diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c index 70b39c7daea..3deb20a126b 100644 --- a/drivers/acpi/acpica/exconfig.c +++ b/drivers/acpi/acpica/exconfig.c @@ -520,13 +520,14 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) } } - /* - * Delete the entire namespace under this table Node - * (Offset contains the table_id) - */ - acpi_tb_delete_namespace_by_owner(table_index); - (void)acpi_tb_release_owner_id(table_index); + /* Delete the portion of the namespace owned by this table */ + + status = acpi_tb_delete_namespace_by_owner(table_index); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + (void)acpi_tb_release_owner_id(table_index); acpi_tb_set_table_loaded_flag(table_index, FALSE); /* Table unloaded, remove a reference to the ddb_handle object */ diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 2583a66a60a..045054037c2 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c @@ -475,21 +475,40 @@ acpi_walk_namespace(acpi_object_type type, } /* - * Lock the namespace around the walk. - * The namespace will be unlocked/locked around each call - * to the user function - since this function - * must be allowed to make Acpi calls itself. + * Need to acquire the namespace reader lock to prevent interference + * with any concurrent table unloads (which causes the deletion of + * namespace objects). We cannot allow the deletion of a namespace node + * while the user function is using it. The exception to this are the + * nodes created and deleted during control method execution -- these + * nodes are marked as temporary nodes and are ignored by the namespace + * walk. Thus, control methods can be executed while holding the + * namespace deletion lock (and the user function can execute control + * methods.) + */ + status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock); + if (ACPI_FAILURE(status)) { + return status; + } + + /* + * Lock the namespace around the walk. The namespace will be + * unlocked/locked around each call to the user function - since the user + * function must be allowed to make ACPICA calls itself (for example, it + * will typically execute control methods during device enumeration.) */ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto unlock_and_exit; } status = acpi_ns_walk_namespace(type, start_object, max_depth, - ACPI_NS_WALK_UNLOCK, - user_function, context, return_value); + ACPI_NS_WALK_UNLOCK, user_function, + context, return_value); (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + + unlock_and_exit: + (void)acpi_ut_release_read_lock(&acpi_gbl_namespace_rw_lock); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index c37993003f2..f865d5a096d 100644 --- a/drivers/acpi/acpica/tbinstal.c +++ b/drivers/acpi/acpica/tbinstal.c @@ -434,27 +434,56 @@ void acpi_tb_terminate(void) * * PARAMETERS: table_index - Table index * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Delete all namespace objects created when this table was loaded. * ******************************************************************************/ -void acpi_tb_delete_namespace_by_owner(u32 table_index) +acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index) { acpi_owner_id owner_id; + acpi_status status; + + ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner); + + status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + if (table_index >= acpi_gbl_root_table_list.count) { + + /* The table index does not exist */ - (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); - if (table_index < acpi_gbl_root_table_list.count) { - owner_id = - acpi_gbl_root_table_list.tables[table_index].owner_id; - } else { (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); - return; + return_ACPI_STATUS(AE_NOT_EXIST); } + /* Get the owner ID for this table, used to delete namespace nodes */ + + owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id; (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); + + /* + * Need to acquire the namespace writer lock to prevent interference + * with any concurrent namespace walks. The interpreter must be + * released during the deletion since the acquisition of the deletion + * lock may block, and also since the execution of a namespace walk + * must be allowed to use the interpreter. + */ + acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); + status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock); + acpi_ns_delete_namespace_by_owner(owner_id); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock); + + status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); + return_ACPI_STATUS(status); } /******************************************************************************* diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c new file mode 100644 index 00000000000..25e03120686 --- /dev/null +++ b/drivers/acpi/acpica/utlock.c @@ -0,0 +1,175 @@ +/****************************************************************************** + * + * Module Name: utlock - Reader/Writer lock interfaces + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2009, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES +ACPI_MODULE_NAME("utlock") + +/******************************************************************************* + * + * FUNCTION: acpi_ut_create_rw_lock + * acpi_ut_delete_rw_lock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader/writer lock creation and deletion interfaces. + * + ******************************************************************************/ +acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock) +{ + acpi_status status; + + lock->num_readers = 0; + status = acpi_os_create_mutex(&lock->reader_mutex); + if (ACPI_FAILURE(status)) { + return status; + } + + status = acpi_os_create_mutex(&lock->writer_mutex); + return status; +} + +void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock) +{ + + acpi_os_delete_mutex(lock->reader_mutex); + acpi_os_delete_mutex(lock->writer_mutex); + + lock->num_readers = 0; + lock->reader_mutex = NULL; + lock->writer_mutex = NULL; +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_acquire_read_lock + * acpi_ut_release_read_lock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition, + * only the first reader acquires the write mutex. On release, + * only the last reader releases the write mutex. Although this + * algorithm can in theory starve writers, this should not be a + * problem with ACPICA since the subsystem is infrequently used + * in comparison to (for example) an I/O system. + * + ******************************************************************************/ + +acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock) +{ + acpi_status status; + + status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE(status)) { + return status; + } + + /* Acquire the write lock only for the first reader */ + + lock->num_readers++; + if (lock->num_readers == 1) { + status = + acpi_os_acquire_mutex(lock->writer_mutex, + ACPI_WAIT_FOREVER); + } + + acpi_os_release_mutex(lock->reader_mutex); + return status; +} + +acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock) +{ + acpi_status status; + + status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE(status)) { + return status; + } + + /* Release the write lock only for the very last reader */ + + lock->num_readers--; + if (lock->num_readers == 0) { + acpi_os_release_mutex(lock->writer_mutex); + } + + acpi_os_release_mutex(lock->reader_mutex); + return status; +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_acquire_write_lock + * acpi_ut_release_write_lock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or + * release the writer mutex associated with the lock. Acquisition + * of the lock is fully exclusive and will block all readers and + * writers until it is released. + * + ******************************************************************************/ + +acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock) +{ + acpi_status status; + + status = acpi_os_acquire_mutex(lock->writer_mutex, ACPI_WAIT_FOREVER); + return status; +} + +void acpi_ut_release_write_lock(struct acpi_rw_lock *lock) +{ + + acpi_os_release_mutex(lock->writer_mutex); +} diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c index 14eb52c4d64..26c93a748e6 100644 --- a/drivers/acpi/acpica/utmutex.c +++ b/drivers/acpi/acpica/utmutex.c @@ -60,7 +60,8 @@ static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id); * * RETURN: Status * - * DESCRIPTION: Create the system mutex objects. + * DESCRIPTION: Create the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. * ******************************************************************************/ @@ -71,9 +72,8 @@ acpi_status acpi_ut_mutex_initialize(void) ACPI_FUNCTION_TRACE(ut_mutex_initialize); - /* - * Create each of the predefined mutex objects - */ + /* Create each of the predefined mutex objects */ + for (i = 0; i < ACPI_NUM_MUTEX; i++) { status = acpi_ut_create_mutex(i); if (ACPI_FAILURE(status)) { @@ -86,6 +86,9 @@ acpi_status acpi_ut_mutex_initialize(void) spin_lock_init(acpi_gbl_gpe_lock); spin_lock_init(acpi_gbl_hardware_lock); + /* Create the reader/writer lock for namespace access */ + + status = acpi_ut_create_rw_lock(&acpi_gbl_namespace_rw_lock); return_ACPI_STATUS(status); } @@ -97,7 +100,8 @@ acpi_status acpi_ut_mutex_initialize(void) * * RETURN: None. * - * DESCRIPTION: Delete all of the system mutex objects. + * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. * ******************************************************************************/ @@ -107,9 +111,8 @@ void acpi_ut_mutex_terminate(void) ACPI_FUNCTION_TRACE(ut_mutex_terminate); - /* - * Delete each predefined mutex object - */ + /* Delete each predefined mutex object */ + for (i = 0; i < ACPI_NUM_MUTEX; i++) { (void)acpi_ut_delete_mutex(i); } @@ -118,6 +121,10 @@ void acpi_ut_mutex_terminate(void) acpi_os_delete_lock(acpi_gbl_gpe_lock); acpi_os_delete_lock(acpi_gbl_hardware_lock); + + /* Delete the reader/writer lock */ + + acpi_ut_delete_rw_lock(&acpi_gbl_namespace_rw_lock); return_VOID; } -- cgit v1.2.3 From 8636f8d257b3edf5a1529df93119cdc630ed85c7 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 9 Mar 2009 16:32:20 +0800 Subject: ACPICA: Change handling of PM1 Status register ignored bit Ignored bits must be preserved according to the ACPI spec. Usually this means a read/modify/write when writing to the register. However, for status registers, writing a one means clear the event. Writing a zero means preserve the event (do not clear.) This behavior is clarified in the ACPI 4.0 spec, and the ACPICA code now simply always writes a zero to the ignored bit. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwregs.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index edc627c9fc0..fd7abe277db 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -273,22 +273,17 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) switch (register_id) { case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ - - /* Perform a read first to preserve certain bits (per ACPI spec) */ - - status = acpi_hw_read_multiple(&read_value, - &acpi_gbl_xpm1a_status, - &acpi_gbl_xpm1b_status); - if (ACPI_FAILURE(status)) { - goto exit; - } - - /* Insert the bits to be preserved */ - - ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS, - read_value); - - /* Now we can write the data */ + /* + * Handle the "ignored" bit in PM1 Status. According to the ACPI + * specification, ignored bits are to be preserved when writing. + * Normally, this would mean a read/modify/write sequence. However, + * preserving a bit in the status register is different. Writing a + * one clears the status, and writing a zero preserves the status. + * Therefore, we must always write zero to the ignored bit. + * + * This behavior is clarified in the ACPI 4.0 specification. + */ + value &= ~ACPI_PM1_STATUS_PRESERVED_BITS; status = acpi_hw_write_multiple(value, &acpi_gbl_xpm1a_status, -- cgit v1.2.3 From 20869dcfde204e1c21b642608d708d82472fee2b Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 13 Mar 2009 09:10:46 +0800 Subject: ACPICA: Preserve all PM control reserved and ignored bits As per the ACPI specification, preserve (read/modify/write) all bits that are defined as either reserved or ignored (PM control control registers only.) Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/aclocal.h | 10 +++++++++- drivers/acpi/acpica/hwregs.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 18a8d96eaa4..f01e155b2bc 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -780,7 +780,15 @@ struct acpi_bit_register_info { * must be preserved. */ #define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ -#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0200 /* Bit 9 (whatever) */ + +/* For control registers, both ignored and reserved bits must be preserved */ + +#define ACPI_PM1_CONTROL_IGNORED_BITS 0x0201 /* Bits 9, 0(SCI_EN) */ +#define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */ +#define ACPI_PM1_CONTROL_PRESERVED_BITS \ + (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS) + +#define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */ /* * Register IDs diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index fd7abe277db..611736266f9 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -328,6 +328,21 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ + /* + * For control registers, all reserved bits must be preserved, + * as per the ACPI spec. + */ + status = + acpi_read(&read_value, &acpi_gbl_FADT.xpm2_control_block); + if (ACPI_FAILURE(status)) { + goto exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS(value, ACPI_PM2_CONTROL_PRESERVED_BITS, + read_value); + status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block); break; -- cgit v1.2.3 From 7f0719039085cc40114abce84cf29fe57da226f4 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 09:37:47 +0800 Subject: ACPICA: New: I/O port protection Protect certain I/O ports from reads/writes. Provides MS compatibility. New module, hwvalid.c Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/Makefile | 2 +- drivers/acpi/acpica/acglobal.h | 1 + drivers/acpi/acpica/achware.h | 7 ++ drivers/acpi/acpica/aclocal.h | 24 +++++ drivers/acpi/acpica/exregion.c | 4 +- drivers/acpi/acpica/hwacpi.c | 4 +- drivers/acpi/acpica/hwregs.c | 4 +- drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/acpica/hwvalid.c | 240 +++++++++++++++++++++++++++++++++++++++++ drivers/acpi/acpica/hwxface.c | 4 +- drivers/acpi/acpica/uteval.c | 55 ++++++---- drivers/acpi/acpica/utglobal.c | 1 + 12 files changed, 319 insertions(+), 29 deletions(-) create mode 100644 drivers/acpi/acpica/hwvalid.c (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 290be74b774..17e50824a6f 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile @@ -18,7 +18,7 @@ obj-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\ excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \ exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o -obj-y += hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o +obj-y += hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o hwvalid.o obj-$(ACPI_FUTURE_USAGE) += hwtimer.o diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index f431b997d2f..16e5210ae93 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h @@ -252,6 +252,7 @@ ACPI_EXTERN u8 acpi_gbl_step_to_next_call; ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; ACPI_EXTERN u8 acpi_gbl_events_initialized; ACPI_EXTERN u8 acpi_gbl_system_awake_and_running; +ACPI_EXTERN u8 acpi_gbl_osi_data; #ifndef DEFINE_ACPI_GLOBALS diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h index 4fa6ee6b1f7..4afa3d8e0ef 100644 --- a/drivers/acpi/acpica/achware.h +++ b/drivers/acpi/acpica/achware.h @@ -72,6 +72,13 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value); acpi_status acpi_hw_clear_acpi_status(void); +/* + * hwvalid - Port I/O with validation + */ +acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width); + +acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width); + /* * hwgpe - GPE support */ diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index f01e155b2bc..42ef0cbf70f 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -863,6 +863,30 @@ struct acpi_bit_register_info { #define ACPI_BITPOSITION_ARB_DISABLE 0x00 +/* Structs and definitions for _OSI support and I/O port validation */ + +#define ACPI_OSI_WIN_2000 0x01 +#define ACPI_OSI_WIN_XP 0x02 +#define ACPI_OSI_WIN_XP_SP1 0x03 +#define ACPI_OSI_WINSRV_2003 0x04 +#define ACPI_OSI_WIN_XP_SP2 0x05 +#define ACPI_OSI_WINSRV_2003_SP1 0x06 +#define ACPI_OSI_WIN_VISTA 0x07 + +#define ACPI_ALWAYS_ILLEGAL 0x00 + +struct acpi_interface_info { + char *name; + u8 value; +}; + +struct acpi_port_info { + char *name; + u16 start; + u16 end; + u8 osi_dependency; +}; + /***************************************************************************** * * Resource descriptors diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c index 76ec8ff903b..3a54b737d2d 100644 --- a/drivers/acpi/acpica/exregion.c +++ b/drivers/acpi/acpica/exregion.c @@ -294,14 +294,14 @@ acpi_ex_system_io_space_handler(u32 function, switch (function) { case ACPI_READ: - status = acpi_os_read_port((acpi_io_address) address, + status = acpi_hw_read_port((acpi_io_address) address, &value32, bit_width); *value = value32; break; case ACPI_WRITE: - status = acpi_os_write_port((acpi_io_address) address, + status = acpi_hw_write_port((acpi_io_address) address, (u32) * value, bit_width); break; diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c index e7949b13336..9af361a191e 100644 --- a/drivers/acpi/acpica/hwacpi.c +++ b/drivers/acpi/acpica/hwacpi.c @@ -96,7 +96,7 @@ acpi_status acpi_hw_set_mode(u32 mode) /* BIOS should have disabled ALL fixed and GP events */ - status = acpi_os_write_port(acpi_gbl_FADT.smi_command, + status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, (u32) acpi_gbl_FADT.acpi_enable, 8); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); @@ -108,7 +108,7 @@ acpi_status acpi_hw_set_mode(u32 mode) * BIOS should clear all fixed status bits and restore fixed event * enable bits to default */ - status = acpi_os_write_port(acpi_gbl_FADT.smi_command, + status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, (u32) acpi_gbl_FADT.acpi_disable, 8); ACPI_DEBUG_PRINT((ACPI_DB_INFO, diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 611736266f9..f8ee0a7fd44 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -222,7 +222,7 @@ acpi_hw_register_read(u32 register_id, u32 * return_value) case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ status = - acpi_os_read_port(acpi_gbl_FADT.smi_command, &value, 8); + acpi_hw_read_port(acpi_gbl_FADT.smi_command, &value, 8); break; default: @@ -356,7 +356,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) /* SMI_CMD is currently always in IO space */ status = - acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8); + acpi_hw_write_port(acpi_gbl_FADT.smi_command, value, 8); break; default: diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 2ea4c59e883..baa5fc05e12 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -430,7 +430,7 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) ACPI_FLUSH_CPU_CACHE(); - status = acpi_os_write_port(acpi_gbl_FADT.smi_command, + status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, (u32) acpi_gbl_FADT.S4bios_request, 8); do { diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c new file mode 100644 index 00000000000..e0b562fbe7c --- /dev/null +++ b/drivers/acpi/acpica/hwvalid.c @@ -0,0 +1,240 @@ + +/****************************************************************************** + * + * Module Name: hwvalid - I/O request validation + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2009, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE +ACPI_MODULE_NAME("hwvalid") + +/* Local prototypes */ +static acpi_status +acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width); + +/* + * Protected I/O ports. Some ports are always illegal, and some are + * conditionally illegal. This table must remain ordered by port address. + * + * The table is used to implement the Microsoft port access rules that + * first appeared in Windows XP. Some ports are always illegal, and some + * ports are only illegal if the BIOS calls _OSI with a win_xP string or + * later (meaning that the BIOS itelf is post-XP.) + * + * This provides ACPICA with the desired port protections and + * Microsoft compatibility. + */ +static const struct acpi_port_info acpi_protected_ports[] = { + {"DMA1", 0x0000, 0x000F, ACPI_OSI_WIN_XP}, + {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL}, + {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP}, + {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, + {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, + {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, + {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP}, + {"DMA1", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, + {"DMA2", 0x0089, 0x0089, ACPI_OSI_WIN_XP}, + {"DMA2", 0x008A, 0x008B, ACPI_OSI_WIN_XP}, + {"DMA2", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, + {"Arb", 0x0090, 0x0091, ACPI_OSI_WIN_XP}, + {"Setup", 0x0093, 0x0094, ACPI_OSI_WIN_XP}, + {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP}, + {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL}, + {"DMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, + {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL}, + {"PCI", 0x0CF8, 0x0D00, ACPI_OSI_WIN_XP} +}; + +#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (acpi_protected_ports) + +/****************************************************************************** + * + * FUNCTION: acpi_hw_validate_io_request + * + * PARAMETERS: Address Address of I/O port/register + * bit_width Number of bits (8,16,32) + * + * RETURN: Status + * + * DESCRIPTION: Validates an I/O request (address/length). Certain ports are + * always illegal and some ports are only illegal depending on + * the requests the BIOS AML code makes to the predefined + * _OSI method. + * + ******************************************************************************/ + +static acpi_status +acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) +{ + u32 i; + u32 byte_width; + acpi_io_address last_address; + const struct acpi_port_info *port_info; + + ACPI_FUNCTION_TRACE(hw_validate_io_request); + + /* Supported widths are 8/16/32 */ + + if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) { + return AE_BAD_PARAMETER; + } + + port_info = acpi_protected_ports; + byte_width = ACPI_DIV_8(bit_width); + last_address = address + byte_width - 1; + + ACPI_DEBUG_PRINT((ACPI_DB_IO, "Address %p LastAddress %p Length %X", + ACPI_CAST_PTR(void, address), ACPI_CAST_PTR(void, + last_address), + byte_width)); + + /* Maximum 16-bit address in I/O space */ + + if (last_address > ACPI_UINT16_MAX) { + ACPI_ERROR((AE_INFO, + "Illegal I/O port address/length above 64K: 0x%p/%X", + ACPI_CAST_PTR(void, address), byte_width)); + return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); + } + + /* Exit if requested address is not within the protected port table */ + + if (address > acpi_protected_ports[ACPI_PORT_INFO_ENTRIES - 1].end) { + return_ACPI_STATUS(AE_OK); + } + + /* Check request against the list of protected I/O ports */ + + for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, port_info++) { + /* + * Check if the requested address range will write to a reserved + * port. Four cases to consider: + * + * 1) Address range is contained completely in the port address range + * 2) Address range overlaps port range at the port range start + * 3) Address range overlaps port range at the port range end + * 4) Address range completely encompasses the port range + */ + if ((address <= port_info->end) + && (last_address >= port_info->start)) { + + /* Port illegality may depend on the _OSI calls made by the BIOS */ + + if (acpi_gbl_osi_data >= port_info->osi_dependency) { + ACPI_ERROR((AE_INFO, + "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", + ACPI_CAST_PTR(void, address), + byte_width, port_info->name, + port_info->start, port_info->end)); + + return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); + } + } + + /* Finished if address range ends before the end of this port */ + + if (last_address <= port_info->end) { + break; + } + } + + return_ACPI_STATUS(AE_OK); +} + +/****************************************************************************** + * + * FUNCTION: acpi_hw_read_port + * + * PARAMETERS: Address Address of I/O port/register to read + * Value Where value is placed + * Width Number of bits + * + * RETURN: Value read from port + * + * DESCRIPTION: Read data from an I/O port or register. This is a front-end + * to acpi_os_read_port that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) +{ + acpi_status status; + + status = acpi_hw_validate_io_request(address, width); + if (ACPI_FAILURE(status)) { + return status; + } + + status = acpi_os_read_port(address, value, width); + return status; +} + +/****************************************************************************** + * + * FUNCTION: acpi_hw_write_port + * + * PARAMETERS: Address Address of I/O port/register to write + * Value Value to write + * Width Number of bits + * + * RETURN: None + * + * DESCRIPTION: Write data to an I/O port or register. This is a front-end + * to acpi_os_write_port that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) +{ + acpi_status status; + + status = acpi_hw_validate_io_request(address, width); + if (ACPI_FAILURE(status)) { + return status; + } + + status = acpi_os_write_port(address, value, width); + return status; +} diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index 26e66427f4f..9829979f2bd 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -146,7 +146,7 @@ acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) case ACPI_ADR_SPACE_SYSTEM_IO: status = - acpi_os_read_port((acpi_io_address) address, value, width); + acpi_hw_read_port((acpi_io_address) address, value, width); break; default: @@ -220,7 +220,7 @@ acpi_status acpi_write(u32 value, struct acpi_generic_address *reg) case ACPI_ADR_SPACE_SYSTEM_IO: - status = acpi_os_write_port((acpi_io_address) address, value, + status = acpi_hw_write_port((acpi_io_address) address, value, width); break; diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c index 3b9152579d0..006b16c2601 100644 --- a/drivers/acpi/acpica/uteval.c +++ b/drivers/acpi/acpica/uteval.c @@ -59,26 +59,35 @@ acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, /* * Strings supported by the _OSI predefined (internal) method. + * + * March 2009: Removed "Linux" as this host no longer wants to respond true + * for this string. Basically, the only safe OS strings are windows-related + * and in many or most cases represent the only test path within the + * BIOS-provided ASL code. + * + * The second element of each entry is used to track the newest version of + * Windows that the BIOS has requested. */ -static char *acpi_interfaces_supported[] = { +static struct acpi_interface_info acpi_interfaces_supported[] = { /* Operating System Vendor Strings */ - "Windows 2000", /* Windows 2000 */ - "Windows 2001", /* Windows XP */ - "Windows 2001 SP1", /* Windows XP SP1 */ - "Windows 2001 SP2", /* Windows XP SP2 */ - "Windows 2001.1", /* Windows Server 2003 */ - "Windows 2001.1 SP1", /* Windows Server 2003 SP1 - Added 03/2006 */ - "Windows 2006", /* Windows Vista - Added 03/2006 */ + {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */ + {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */ + {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ + {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ + {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ + {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ + {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ /* Feature Group Strings */ - "Extended Address Space Descriptor" - /* - * All "optional" feature group strings (features that are implemented - * by the host) should be implemented in the host version of - * acpi_os_validate_interface and should not be added here. - */ + {"Extended Address Space Descriptor", 0} + + /* + * All "optional" feature group strings (features that are implemented + * by the host) should be implemented in the host version of + * acpi_os_validate_interface and should not be added here. + */ }; /******************************************************************************* @@ -125,9 +134,17 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { if (!ACPI_STRCMP(string_desc->string.pointer, - acpi_interfaces_supported[i])) { - - /* The interface is supported */ + acpi_interfaces_supported[i].name)) { + /* + * The interface is supported. + * Update the osi_data if necessary. We keep track of the latest + * version of Windows that has been requested by the BIOS. + */ + if (acpi_interfaces_supported[i].value > + acpi_gbl_osi_data) { + acpi_gbl_osi_data = + acpi_interfaces_supported[i].value; + } return_value = ACPI_UINT32_MAX; goto exit; @@ -176,8 +193,8 @@ acpi_status acpi_osi_invalidate(char *interface) int i; for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { - if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i])) { - *acpi_interfaces_supported[i] = '\0'; + if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) { + *acpi_interfaces_supported[i].name = '\0'; return AE_OK; } } diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index 256ce777856..59e46f257c0 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c @@ -789,6 +789,7 @@ acpi_status acpi_ut_init_globals(void) acpi_gbl_trace_dbg_layer = 0; acpi_gbl_debugger_configuration = DEBUGGER_THREADING; acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; + acpi_gbl_osi_data = 0; /* Hardware oriented */ -- cgit v1.2.3 From f9ca058430333c9a24c5ca926aa445125f88df18 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 09:47:16 +0800 Subject: ACPICA: Remove obsolete acpi_os_validate_address interface This interface is no longer necessary. Requests should be validated on a per-field basis, not on the entire operation region. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/acobject.h | 1 - drivers/acpi/acpica/dsopcode.c | 24 ------------------------ drivers/acpi/acpica/exfldio.c | 6 ------ 3 files changed, 31 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h index eb6f038b03d..544dcf83492 100644 --- a/drivers/acpi/acpica/acobject.h +++ b/drivers/acpi/acpica/acobject.h @@ -97,7 +97,6 @@ #define AOPOBJ_OBJECT_INITIALIZED 0x08 #define AOPOBJ_SETUP_COMPLETE 0x10 #define AOPOBJ_SINGLE_DATUM 0x20 -#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */ /****************************************************************************** * diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c index 602ddaa10c2..b4c87b5053e 100644 --- a/drivers/acpi/acpica/dsopcode.c +++ b/drivers/acpi/acpica/dsopcode.c @@ -397,30 +397,6 @@ acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc) status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), extra_desc->extra.aml_length, extra_desc->extra.aml_start); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* Validate the region address/length via the host OS */ - - status = acpi_os_validate_address(obj_desc->region.space_id, - obj_desc->region.address, - (acpi_size) obj_desc->region.length, - acpi_ut_get_node_name(node)); - - if (ACPI_FAILURE(status)) { - /* - * Invalid address/length. We will emit an error message and mark - * the region as invalid, so that it will cause an additional error if - * it is ever used. Then return AE_OK. - */ - ACPI_EXCEPTION((AE_INFO, status, - "During address validation of OpRegion [%4.4s]", - node->name.ascii)); - obj_desc->common.flags |= AOPOBJ_INVALID; - status = AE_OK; - } - return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index 1053e7cd92a..99cee61e655 100644 --- a/drivers/acpi/acpica/exfldio.c +++ b/drivers/acpi/acpica/exfldio.c @@ -113,12 +113,6 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, } } - /* Exit if Address/Length have been disallowed by the host OS */ - - if (rgn_desc->common.flags & AOPOBJ_INVALID) { - return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); - } - /* * Exit now for SMBus address space, it has a non-linear address space * and the request cannot be directly validated -- cgit v1.2.3 From c3dd25f4c1ca84baa170c0a3a15a884f4f06297e Mon Sep 17 00:00:00 2001 From: Lin Ming Date: Thu, 19 Mar 2009 09:51:01 +0800 Subject: ACPICA: Clear PM register write-only bits on reading Affects PM1 Control register only. When reading the register, zero the write-only bits as per the ACPI spec. ACPICA BZ 443. Lin Ming. http://www.acpica.org/bugzilla/show_bug.cgi?id=443 Signed-off-by: Lin Ming Signed-off-by: Bob Moore Signed-off-by: Len Brown --- drivers/acpi/acpica/aclocal.h | 4 ++++ drivers/acpi/acpica/hwregs.c | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 42ef0cbf70f..772ee5c4ccc 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -781,6 +781,10 @@ struct acpi_bit_register_info { */ #define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ +/* Write-only bits must be zeroed by software */ + +#define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */ + /* For control registers, both ignored and reserved bits must be preserved */ #define ACPI_PM1_CONTROL_IGNORED_BITS 0x0201 /* Bits 9, 0(SCI_EN) */ diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index f8ee0a7fd44..7b2fb602b5c 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -207,6 +207,13 @@ acpi_hw_register_read(u32 register_id, u32 * return_value) xpm1a_control_block, &acpi_gbl_FADT. xpm1b_control_block); + + /* + * Zero the write-only bits. From the ACPI specification, "Hardware + * Write-Only Bits": "Upon reads to registers with write-only bits, + * software masks out all write-only bits." + */ + value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS; break; case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ -- cgit v1.2.3 From 91a56e631fc837852304ee7bc2876d6e444b7fdb Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 09:52:34 +0800 Subject: ACPICA: Remove unused code, no functional change Removed unused code for dump of args and locals. General cleanup and splitting of long lines. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/exdump.c | 44 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c index 193d23312e1..89d141fdae0 100644 --- a/drivers/acpi/acpica/exdump.c +++ b/drivers/acpi/acpica/exdump.c @@ -350,6 +350,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, break; case ACPI_EXD_TYPE: + acpi_ex_out_string("Type", acpi_ut_get_object_type_name (obj_desc)); @@ -422,6 +423,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, break; default: + acpi_os_printf("**** Invalid table opcode [%X] ****\n", info->opcode); return; @@ -527,44 +529,16 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) type)); break; - case ACPI_REFCLASS_ARG: - - acpi_os_printf("%X", obj_desc->reference.value); - - if (obj_desc->common.type == ACPI_TYPE_INTEGER) { - - /* Value is an Integer */ - - acpi_os_printf(" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64(obj_desc-> - integer. - value)); - } + case ACPI_REFCLASS_NAME: - acpi_os_printf("\n"); + acpi_os_printf("- [%4.4s]\n", + obj_desc->reference.node->name.ascii); break; + case ACPI_REFCLASS_ARG: case ACPI_REFCLASS_LOCAL: - acpi_os_printf("%X", obj_desc->reference.value); - - if (obj_desc->common.type == ACPI_TYPE_INTEGER) { - - /* Value is an Integer */ - - acpi_os_printf(" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64(obj_desc-> - integer. - value)); - } - - acpi_os_printf("\n"); - break; - - case ACPI_REFCLASS_NAME: - - acpi_os_printf("- [%4.4s]\n", - obj_desc->reference.node->name.ascii); + acpi_os_printf("%X\n", obj_desc->reference.value); break; default: /* Unknown reference class */ @@ -661,8 +635,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) case ACPI_TYPE_LOCAL_REGION_FIELD: acpi_os_printf - ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", - obj_desc->field.bit_length, + ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at " + "byte=%X bit=%X of below:\n", obj_desc->field.bit_length, obj_desc->field.access_byte_width, obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, -- cgit v1.2.3 From ee6a0fbd0ccb7736a3be56630e3ad65ceddfb5bd Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 09:53:35 +0800 Subject: ACPICA: Condense some protected ports One entry in the protected port table eliminated. Added extra comments to describe each table entry. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwvalid.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c index e0b562fbe7c..105b818eba4 100644 --- a/drivers/acpi/acpica/hwvalid.c +++ b/drivers/acpi/acpica/hwvalid.c @@ -63,24 +63,42 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width); * * This provides ACPICA with the desired port protections and * Microsoft compatibility. + * + * Description of port entries: + * DMA: DMA controller + * PIC0: Programmable Interrupt Controller (8259_a) + * PIT1: System Timer 1 + * PIT2: System Timer 2 failsafe + * RTC: Real-time clock + * CMOS: Extended CMOS + * DMA1: DMA 1 page registers + * DMA1L: DMA 1 Ch 0 low page + * DMA2: DMA 2 page registers + * DMA2L: DMA 2 low page refresh + * ARBC: Arbitration control + * SETUP: Reserved system board setup + * POS: POS channel select + * PIC1: Cascaded PIC + * IDMA: ISA DMA + * ELCR: PIC edge/level registers + * PCI: PCI configuration space */ static const struct acpi_port_info acpi_protected_ports[] = { - {"DMA1", 0x0000, 0x000F, ACPI_OSI_WIN_XP}, + {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP}, {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL}, {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP}, {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP}, - {"DMA1", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, - {"DMA2", 0x0089, 0x0089, ACPI_OSI_WIN_XP}, - {"DMA2", 0x008A, 0x008B, ACPI_OSI_WIN_XP}, - {"DMA2", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, - {"Arb", 0x0090, 0x0091, ACPI_OSI_WIN_XP}, - {"Setup", 0x0093, 0x0094, ACPI_OSI_WIN_XP}, + {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, + {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP}, + {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, + {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP}, + {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP}, {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP}, {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL}, - {"DMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, + {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL}, {"PCI", 0x0CF8, 0x0D00, ACPI_OSI_WIN_XP} }; -- cgit v1.2.3 From f28ad2c3daf0691081d91488df4d9d101e1a2b5d Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 09:54:31 +0800 Subject: ACPICA: Fix PCI configuration space port address range Microsoft website uses 0xCF8-0xD00. Should be 0xCF8-0xCFF (Two 32-bit registers.) Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/hwvalid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c index 105b818eba4..bd3c937b0ac 100644 --- a/drivers/acpi/acpica/hwvalid.c +++ b/drivers/acpi/acpica/hwvalid.c @@ -100,7 +100,7 @@ static const struct acpi_port_info acpi_protected_ports[] = { {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL}, {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL}, - {"PCI", 0x0CF8, 0x0D00, ACPI_OSI_WIN_XP} + {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP} }; #define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (acpi_protected_ports) -- cgit v1.2.3 From 31fbc073a35a017e34840deb9e865a701e986002 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 10:12:13 +0800 Subject: ACPICA: FADT: Favor 32-bit register addresses for compatibility Use the 32-bit register addresses whenever they are non-zero. This means that the 32-bit addresses are favored over the 64-bit (GAS) addresses. The 64-bit addresses are only used if the 32-bit addresses are zero. This change provides compatibility with all versions of Windows. The worst case that this solves is when both the 32-bit and 64-bit addresses are non-zero, but only the 32-bit addresses are actually valid. This appears to happen in some BIOSes because in this case, Windows uses the 32-bit addresses. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/tbfadt.c | 86 ++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 35 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index ff89cfee0e7..f87bfb259ef 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -320,29 +320,35 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) * RETURN: None * * DESCRIPTION: Converts all versions of the FADT to a common internal format. - * Expand all 32-bit addresses to 64-bit. + * Expand 32-bit addresses to 64-bit as necessary. * * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), * and must contain a copy of the actual FADT. * - * ACPICA will use the "X" fields of the FADT for all addresses. + * Notes on 64-bit register addresses: * - * "X" fields are optional extensions to the original V1.0 fields. Even if - * they are present in the structure, they can be optionally not used by - * setting them to zero. Therefore, we must selectively expand V1.0 fields - * if the corresponding X field is zero. + * After this FADT conversion, later ACPICA code will only use the 64-bit "X" + * fields of the FADT for all ACPI register addresses. * - * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding - * "X" fields. + * The 64-bit "X" fields are optional extensions to the original 32-bit FADT + * V1.0 fields. Even if they are present in the FADT, they are optional and + * are unused if the BIOS sets them to zero. Therefore, we must copy/expand + * 32-bit V1.0 fields if the corresponding X field is zero. * - * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by - * expanding the corresponding ACPI 1.0 field. + * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the + * corresponding "X" fields in the internal FADT. + * + * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded + * to the corresponding 64-bit X fields. For compatibility with other ACPI + * implementations, we ignore the 64-bit field if the 32-bit field is valid, + * regardless of whether the host OS is 32-bit or 64-bit. * ******************************************************************************/ static void acpi_tb_convert_fadt(void) { - struct acpi_generic_address *target64; + struct acpi_generic_address *address64; + u32 address32; u32 i; /* Update the local FADT table header length */ @@ -391,29 +397,51 @@ static void acpi_tb_convert_fadt(void) * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" * generic address structures as necessary. Later code will always use * the 64-bit address structures. + * + * March 2009: + * We now always use the 32-bit address if it is valid (non-null). This + * is not in accordance with the ACPI specification which states that + * the 64-bit address supersedes the 32-bit version, but we do this for + * compatibility with other ACPI implementations. Most notably, in the + * case where both the 32 and 64 versions are non-null, we use the 32-bit + * version. This is the only address that is guaranteed to have been + * tested by the BIOS manufacturer. */ for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { - target64 = - ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, - fadt_info_table[i].address64); + address32 = *ACPI_ADD_PTR(u32, + &acpi_gbl_FADT, + fadt_info_table[i].address32); - /* Expand only if the 64-bit X target is null */ + address64 = ACPI_ADD_PTR(struct acpi_generic_address, + &acpi_gbl_FADT, + fadt_info_table[i].address64); - if (!target64->address) { + /* + * If both 32- and 64-bit addresses are valid (non-zero), + * they must match. + */ + if (address64->address && address32 && + (address64->address != (u64) address32)) { + ACPI_ERROR((AE_INFO, + "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32", + fadt_info_table[i].name, address32, + ACPI_FORMAT_UINT64(address64->address))); + } - /* The space_id is always I/O for the 32-bit legacy address fields */ + /* Always use 32-bit address if it is valid (non-null) */ - acpi_tb_init_generic_address(target64, + if (address32) { + /* + * Copy the 32-bit address to the 64-bit GAS structure. The + * Space ID is always I/O for 32-bit legacy address fields + */ + acpi_tb_init_generic_address(address64, ACPI_ADR_SPACE_SYSTEM_IO, *ACPI_ADD_PTR(u8, &acpi_gbl_FADT, fadt_info_table [i].length), - (u64) * ACPI_ADD_PTR(u32, - &acpi_gbl_FADT, - fadt_info_table - [i]. - address32)); + address32); } } } @@ -530,18 +558,6 @@ static void acpi_tb_validate_fadt(void) length)); } } - - /* - * If both 32- and 64-bit addresses are valid (non-zero), - * they must match - */ - if (address64->address && *address32 && - (address64->address != (u64) * address32)) { - ACPI_ERROR((AE_INFO, - "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 64X", - name, *address32, - ACPI_FORMAT_UINT64(address64->address))); - } } } -- cgit v1.2.3 From f65563063375b05898a94ab71b52612cbe3a789b Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 10:13:40 +0800 Subject: ACPICA: FADT: Favor 32-bit FACS and DSDT addresses If both the 32-bit and 64-bit addresses are non-null, use the 32-bit address. Provides Windows compatibility. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/tbfadt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index f87bfb259ef..71e655d14cb 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c @@ -483,18 +483,22 @@ static void acpi_tb_validate_fadt(void) (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) { ACPI_WARNING((AE_INFO, "32/64X FACS address mismatch in FADT - " - "two FACS tables! %8.8X/%8.8X%8.8X", + "%8.8X/%8.8X%8.8X, using 32", acpi_gbl_FADT.facs, ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs))); + + acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs; } if (acpi_gbl_FADT.dsdt && (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) { ACPI_WARNING((AE_INFO, "32/64X DSDT address mismatch in FADT - " - "two DSDT tables! %8.8X/%8.8X%8.8X", + "%8.8X/%8.8X%8.8X, using 32", acpi_gbl_FADT.dsdt, ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt))); + + acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt; } /* Examine all of the 64-bit extended address fields (X fields) */ -- cgit v1.2.3 From 03ef132b7258bbea4858be4b1bd6cb6c3fdd3253 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 19 Mar 2009 10:14:45 +0800 Subject: ACPICA: Fix index value in package warning message For predefined method validation. Index value in warning message could be off by one. Signed-off-by: Bob Moore Signed-off-by: Lin Ming Signed-off-by: Len Brown --- drivers/acpi/acpica/nspredef.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 0d0b4ee1358..d9e8cbc6e67 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c @@ -79,7 +79,9 @@ acpi_ns_check_package(char *pathname, static acpi_status acpi_ns_check_package_elements(char *pathname, union acpi_operand_object **elements, - u8 type1, u32 count1, u8 type2, u32 count2); + u8 type1, + u32 count1, + u8 type2, u32 count2, u32 start_index); static acpi_status acpi_ns_check_object_type(char *pathname, @@ -473,7 +475,7 @@ acpi_ns_check_package(char *pathname, package->ret_info. object_type2, package->ret_info. - count2); + count2, 0); if (ACPI_FAILURE(status)) { return (status); } @@ -624,7 +626,7 @@ acpi_ns_check_package(char *pathname, object_type2, package-> ret_info. - count2); + count2, 0); if (ACPI_FAILURE(status)) { return (status); } @@ -673,7 +675,8 @@ acpi_ns_check_package(char *pathname, object_type1, sub_package-> package. - count, 0, 0); + count, 0, 0, + 0); if (ACPI_FAILURE(status)) { return (status); } @@ -711,7 +714,8 @@ acpi_ns_check_package(char *pathname, ret_info. object_type1, (expected_count - - 1), 0, 0); + - 1), 0, 0, + 1); if (ACPI_FAILURE(status)) { return (status); } @@ -759,6 +763,7 @@ acpi_ns_check_package(char *pathname, * Count1 - Count for first group * Type2 - Object type for second group * Count2 - Count for second group + * start_index - Start of the first group of elements * * RETURN: Status * @@ -770,7 +775,9 @@ acpi_ns_check_package(char *pathname, static acpi_status acpi_ns_check_package_elements(char *pathname, union acpi_operand_object **elements, - u8 type1, u32 count1, u8 type2, u32 count2) + u8 type1, + u32 count1, + u8 type2, u32 count2, u32 start_index) { union acpi_operand_object **this_element = elements; acpi_status status; @@ -783,7 +790,7 @@ acpi_ns_check_package_elements(char *pathname, */ for (i = 0; i < count1; i++) { status = acpi_ns_check_object_type(pathname, this_element, - type1, i); + type1, i + start_index); if (ACPI_FAILURE(status)) { return (status); } @@ -792,7 +799,8 @@ acpi_ns_check_package_elements(char *pathname, for (i = 0; i < count2; i++) { status = acpi_ns_check_object_type(pathname, this_element, - type2, (i + count1)); + type2, + (i + count1 + start_index)); if (ACPI_FAILURE(status)) { return (status); } -- cgit v1.2.3