aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2012-09-13 12:29:06 -0400
committerLen Brown <len.brown@intel.com>2012-09-21 00:35:12 -0400
commit2bc198c1527be998850ade8f91ec7d340b67fdf3 (patch)
treef3164a231795968c125aa7a4e6f38850462076d9 /drivers/acpi
parentca4a03143f6c911189f708a3a3c7eae3dfb8678c (diff)
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=846 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpica/tbinstal.c20
-rw-r--r--drivers/acpi/acpica/tbxface.c41
2 files changed, 18 insertions, 43 deletions
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 74f97d74db1c..70f9d787c82c 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -350,6 +350,7 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
350acpi_status acpi_tb_resize_root_table_list(void) 350acpi_status acpi_tb_resize_root_table_list(void)
351{ 351{
352 struct acpi_table_desc *tables; 352 struct acpi_table_desc *tables;
353 u32 table_count;
353 354
354 ACPI_FUNCTION_TRACE(tb_resize_root_table_list); 355 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
355 356
@@ -363,8 +364,13 @@ acpi_status acpi_tb_resize_root_table_list(void)
363 364
364 /* Increase the Table Array size */ 365 /* Increase the Table Array size */
365 366
366 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. 367 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
367 max_table_count + 368 table_count = acpi_gbl_root_table_list.max_table_count;
369 } else {
370 table_count = acpi_gbl_root_table_list.current_table_count;
371 }
372
373 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
368 ACPI_ROOT_TABLE_SIZE_INCREMENT) * 374 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
369 sizeof(struct acpi_table_desc)); 375 sizeof(struct acpi_table_desc));
370 if (!tables) { 376 if (!tables) {
@@ -377,8 +383,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
377 383
378 if (acpi_gbl_root_table_list.tables) { 384 if (acpi_gbl_root_table_list.tables) {
379 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, 385 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
380 (acpi_size) acpi_gbl_root_table_list. 386 (acpi_size) table_count *
381 max_table_count * sizeof(struct acpi_table_desc)); 387 sizeof(struct acpi_table_desc));
382 388
383 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 389 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
384 ACPI_FREE(acpi_gbl_root_table_list.tables); 390 ACPI_FREE(acpi_gbl_root_table_list.tables);
@@ -386,9 +392,9 @@ acpi_status acpi_tb_resize_root_table_list(void)
386 } 392 }
387 393
388 acpi_gbl_root_table_list.tables = tables; 394 acpi_gbl_root_table_list.tables = tables;
389 acpi_gbl_root_table_list.max_table_count += 395 acpi_gbl_root_table_list.max_table_count =
390 ACPI_ROOT_TABLE_SIZE_INCREMENT; 396 table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
391 acpi_gbl_root_table_list.flags |= (u8)ACPI_ROOT_ORIGIN_ALLOCATED; 397 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
392 398
393 return_ACPI_STATUS(AE_OK); 399 return_ACPI_STATUS(AE_OK);
394} 400}
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index 29e51bc01383..21101262e47a 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -159,14 +159,12 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
159 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the 159 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
160 * root list from the previously provided scratch area. Should 160 * root list from the previously provided scratch area. Should
161 * be called once dynamic memory allocation is available in the 161 * be called once dynamic memory allocation is available in the
162 * kernel 162 * kernel.
163 * 163 *
164 ******************************************************************************/ 164 ******************************************************************************/
165acpi_status acpi_reallocate_root_table(void) 165acpi_status acpi_reallocate_root_table(void)
166{ 166{
167 struct acpi_table_desc *tables; 167 acpi_status status;
168 acpi_size new_size;
169 acpi_size current_size;
170 168
171 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); 169 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
172 170
@@ -178,39 +176,10 @@ acpi_status acpi_reallocate_root_table(void)
178 return_ACPI_STATUS(AE_SUPPORT); 176 return_ACPI_STATUS(AE_SUPPORT);
179 } 177 }
180 178
181 /* 179 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
182 * Get the current size of the root table and add the default
183 * increment to create the new table size.
184 */
185 current_size = (acpi_size)
186 acpi_gbl_root_table_list.current_table_count *
187 sizeof(struct acpi_table_desc);
188
189 new_size = current_size +
190 (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof(struct acpi_table_desc));
191
192 /* Create new array and copy the old array */
193
194 tables = ACPI_ALLOCATE_ZEROED(new_size);
195 if (!tables) {
196 return_ACPI_STATUS(AE_NO_MEMORY);
197 }
198 180
199 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size); 181 status = acpi_tb_resize_root_table_list();
200 182 return_ACPI_STATUS(status);
201 /*
202 * Update the root table descriptor. The new size will be the current
203 * number of tables plus the increment, independent of the reserved
204 * size of the original table list.
205 */
206 acpi_gbl_root_table_list.tables = tables;
207 acpi_gbl_root_table_list.max_table_count =
208 acpi_gbl_root_table_list.current_table_count +
209 ACPI_ROOT_TABLE_SIZE_INCREMENT;
210 acpi_gbl_root_table_list.flags =
211 ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
212
213 return_ACPI_STATUS(AE_OK);
214} 183}
215 184
216/******************************************************************************* 185/*******************************************************************************