Commit 2bc198c1 authored by Lv Zheng's avatar Lv Zheng Committed by Len Brown

ACPICA: Table Manager: Merge duplicate code (root table)

Merge/remove duplicate code in the root table resize functions
One function is external, the other is internal.  Lv Zheng,

ACPICA BZ 846:
https://acpica.org/bugzilla/show_bug.cgi?id=846Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent ca4a0314
...@@ -350,6 +350,7 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header ...@@ -350,6 +350,7 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
acpi_status acpi_tb_resize_root_table_list(void) acpi_status acpi_tb_resize_root_table_list(void)
{ {
struct acpi_table_desc *tables; struct acpi_table_desc *tables;
u32 table_count;
ACPI_FUNCTION_TRACE(tb_resize_root_table_list); ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
...@@ -363,8 +364,13 @@ acpi_status acpi_tb_resize_root_table_list(void) ...@@ -363,8 +364,13 @@ acpi_status acpi_tb_resize_root_table_list(void)
/* Increase the Table Array size */ /* Increase the Table Array size */
tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
max_table_count + table_count = acpi_gbl_root_table_list.max_table_count;
} else {
table_count = acpi_gbl_root_table_list.current_table_count;
}
tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
ACPI_ROOT_TABLE_SIZE_INCREMENT) * ACPI_ROOT_TABLE_SIZE_INCREMENT) *
sizeof(struct acpi_table_desc)); sizeof(struct acpi_table_desc));
if (!tables) { if (!tables) {
...@@ -377,8 +383,8 @@ acpi_status acpi_tb_resize_root_table_list(void) ...@@ -377,8 +383,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
if (acpi_gbl_root_table_list.tables) { if (acpi_gbl_root_table_list.tables) {
ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
(acpi_size) acpi_gbl_root_table_list. (acpi_size) table_count *
max_table_count * sizeof(struct acpi_table_desc)); sizeof(struct acpi_table_desc));
if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
ACPI_FREE(acpi_gbl_root_table_list.tables); ACPI_FREE(acpi_gbl_root_table_list.tables);
...@@ -386,9 +392,9 @@ acpi_status acpi_tb_resize_root_table_list(void) ...@@ -386,9 +392,9 @@ acpi_status acpi_tb_resize_root_table_list(void)
} }
acpi_gbl_root_table_list.tables = tables; acpi_gbl_root_table_list.tables = tables;
acpi_gbl_root_table_list.max_table_count += acpi_gbl_root_table_list.max_table_count =
ACPI_ROOT_TABLE_SIZE_INCREMENT; table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
acpi_gbl_root_table_list.flags |= (u8)ACPI_ROOT_ORIGIN_ALLOCATED; acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
} }
......
...@@ -159,14 +159,12 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array, ...@@ -159,14 +159,12 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
* DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
* root list from the previously provided scratch area. Should * root list from the previously provided scratch area. Should
* be called once dynamic memory allocation is available in the * be called once dynamic memory allocation is available in the
* kernel * kernel.
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_reallocate_root_table(void) acpi_status acpi_reallocate_root_table(void)
{ {
struct acpi_table_desc *tables; acpi_status status;
acpi_size new_size;
acpi_size current_size;
ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
...@@ -178,39 +176,10 @@ acpi_status acpi_reallocate_root_table(void) ...@@ -178,39 +176,10 @@ acpi_status acpi_reallocate_root_table(void)
return_ACPI_STATUS(AE_SUPPORT); return_ACPI_STATUS(AE_SUPPORT);
} }
/* acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
* Get the current size of the root table and add the default
* increment to create the new table size.
*/
current_size = (acpi_size)
acpi_gbl_root_table_list.current_table_count *
sizeof(struct acpi_table_desc);
new_size = current_size +
(ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof(struct acpi_table_desc));
/* Create new array and copy the old array */
tables = ACPI_ALLOCATE_ZEROED(new_size);
if (!tables) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size); status = acpi_tb_resize_root_table_list();
return_ACPI_STATUS(status);
/*
* Update the root table descriptor. The new size will be the current
* number of tables plus the increment, independent of the reserved
* size of the original table list.
*/
acpi_gbl_root_table_list.tables = tables;
acpi_gbl_root_table_list.max_table_count =
acpi_gbl_root_table_list.current_table_count +
ACPI_ROOT_TABLE_SIZE_INCREMENT;
acpi_gbl_root_table_list.flags =
ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
return_ACPI_STATUS(AE_OK);
} }
/******************************************************************************* /*******************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment