From patchwork Sat Oct 6 20:09:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 1559311 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id F2BBA40D2D for ; Sat, 6 Oct 2012 20:14:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755939Ab2JFUOy (ORCPT ); Sat, 6 Oct 2012 16:14:54 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:60718 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751284Ab2JFUOx (ORCPT ); Sat, 6 Oct 2012 16:14:53 -0400 Received: by mail-qa0-f46.google.com with SMTP id c26so1238567qad.19 for ; Sat, 06 Oct 2012 13:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:reply-to:organization; bh=ee4SzOjeSIaqnh9OM0pnu3z5mPzmG1DvOxm6E/wierc=; b=UMCHRpmSy3TrJj0eP1oThGP33OHw/M3sCHlrO9pvQnFHTOJPaOhz0aL0ByFYjhNdZB maQsgWwhYtc347CG5ing3APxN5i7DbJwVQb9X6ZKGv9S1qThMz9ksOYW64hqQnpfkh8n +XF91eljUky0tmBlAMzHaR4fnVzmLohHbCjOMlbPQgBskhNTyrJ61ukn1GgJ+NwSXjGE TuY15mGX0TivUIlWTaaVvjIL5Uu22FSoyLGDp7iubQxWhaprQGNZSW8aKl2gilJa+Cuf oNdMUWWs2cG4Yv1xy8oMXHib5PVsGyjCzefm70Yztv2Gw5CqOpuMdmmDM5OH/JiRkoCe 5JRg== Received: by 10.224.78.141 with SMTP id l13mr22748323qak.25.1349554492813; Sat, 06 Oct 2012 13:14:52 -0700 (PDT) Received: from x980.localdomain6 (pool-74-104-146-186.bstnma.fios.verizon.net. [74.104.146.186]) by mx.google.com with ESMTPS id x19sm13470740qeq.12.2012.10.06.13.14.33 (version=SSLv3 cipher=OTHER); Sat, 06 Oct 2012 13:14:46 -0700 (PDT) From: Len Brown To: linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lv Zheng , Bob Moore , Len Brown Subject: [PATCH 16/49] ACPICA: Table Manager: Merge duplicate code (root table) Date: Sat, 6 Oct 2012 16:09:37 -0400 Message-Id: <2bc198c1527be998850ade8f91ec7d340b67fdf3.1349554106.git.len.brown@intel.com> X-Mailer: git-send-email 1.8.0.rc0.18.gf84667d In-Reply-To: <1349554210-29978-1-git-send-email-lenb@kernel.org> References: <1349554210-29978-1-git-send-email-lenb@kernel.org> In-Reply-To: References: Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Lv Zheng 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 Signed-off-by: Lv Zheng Signed-off-by: Len Brown --- drivers/acpi/acpica/tbinstal.c | 20 +++++++++++++------- drivers/acpi/acpica/tbxface.c | 41 +++++------------------------------------ 2 files changed, 18 insertions(+), 43 deletions(-) diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index 74f97d7..70f9d78 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 acpi_status acpi_tb_resize_root_table_list(void) { struct acpi_table_desc *tables; + u32 table_count; ACPI_FUNCTION_TRACE(tb_resize_root_table_list); @@ -363,8 +364,13 @@ 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. - max_table_count + + if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { + 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) * sizeof(struct acpi_table_desc)); if (!tables) { @@ -377,8 +383,8 @@ acpi_status acpi_tb_resize_root_table_list(void) if (acpi_gbl_root_table_list.tables) { ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, - (acpi_size) acpi_gbl_root_table_list. - max_table_count * sizeof(struct acpi_table_desc)); + (acpi_size) table_count * + sizeof(struct acpi_table_desc)); if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { ACPI_FREE(acpi_gbl_root_table_list.tables); @@ -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.max_table_count += - ACPI_ROOT_TABLE_SIZE_INCREMENT; - acpi_gbl_root_table_list.flags |= (u8)ACPI_ROOT_ORIGIN_ALLOCATED; + acpi_gbl_root_table_list.max_table_count = + table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; + acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index 29e51bc..2110126 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, * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the * root list from the previously provided scratch area. Should * be called once dynamic memory allocation is available in the - * kernel + * kernel. * ******************************************************************************/ acpi_status acpi_reallocate_root_table(void) { - struct acpi_table_desc *tables; - acpi_size new_size; - acpi_size current_size; + acpi_status status; ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); @@ -178,39 +176,10 @@ acpi_status acpi_reallocate_root_table(void) return_ACPI_STATUS(AE_SUPPORT); } - /* - * 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_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE; - ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size); - - /* - * 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); + status = acpi_tb_resize_root_table_list(); + return_ACPI_STATUS(status); } /*******************************************************************************