From patchwork Tue Oct 25 05:21:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9394007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4DE2960231 for ; Tue, 25 Oct 2016 05:23:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 429AC28D94 for ; Tue, 25 Oct 2016 05:23:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3760228EB0; Tue, 25 Oct 2016 05:23:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82C6328D94 for ; Tue, 25 Oct 2016 05:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754787AbcJYFWm (ORCPT ); Tue, 25 Oct 2016 01:22:42 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:34366 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755260AbcJYFWA (ORCPT ); Tue, 25 Oct 2016 01:22:00 -0400 Received: by mail-oi0-f66.google.com with SMTP id p136so5261627oic.1; Mon, 24 Oct 2016 22:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TlVnn/SbDbQQXv4E1bElhIh3JbpRdcb+bZ6Fdczms8c=; b=fqg6nU36ENqn2ajgGFHGBmwawYjg0kBQHpNu0kRWG3gkkk4icZcanhURpQvOtPQeTM t3xhEw+EjRNII87OmbyeCpFLc5J7C5A6BjUG4iKjEqkxkI1j6yUIS2lIhcefyKcrz2fB w9JY/FlxZYcNEeN3xWqTRkzmcDwqXUMpY1FfCXXDpwKZV+jGTjMdFcHNcmC8tF8zxgjQ PrSyh0z+4tjOlV/ApVLY1PL6UKu8iITkXy4Bu5/OAqeDpH8NkY2g7yyijcKDDIRgisEC b+4rIyuwjlZRnXOTXM3Hfkn9dTK/66v1WBXLtlo19VD4UaJ4/XtYlpXgPo6MUm/WKflP pbcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TlVnn/SbDbQQXv4E1bElhIh3JbpRdcb+bZ6Fdczms8c=; b=MxLxd2l6mLw0AQekVJEDZ6q5rwFyvIen1ZQchfrvRoLg7XNuAyk/CVgP2PV38w8ioh k0xxs4+EgUNvAnB+SZvveRZkBlEi3ncX0tYmkx0jk2DDesdaxsfDKSl9eNRkpVnbkwcm h+uHDrQWxioORiP6/tCNMFG6fe5e7NMSNFaIJJIYvBu2omUlIjkMEoTR1tcgIOwbe091 BMbkm3odGyiedJFao3NEV52lS9kAmzJGDGEef4lVcVydDcQpvU0Mfez/SCFmuVlBgez9 vOihCtbHuoMG2tgTsWQoKmyIHM61e3DUJcFvFQaawLLiPExCiam8g8+EVt+GYRb9sNHr SIdg== X-Gm-Message-State: AA6/9RmWUIspg0l6xMpyfk/XAPsApYcHvNUaI6Yzp5bIa+KkkoZRjaeoq8ZrITDkgEDW6Q== X-Received: by 10.202.240.194 with SMTP id o185mr22547626oih.111.1477372906851; Mon, 24 Oct 2016 22:21:46 -0700 (PDT) Received: from localhost.localdomain (h3.246.129.40.static.ip.windstream.net. [40.129.246.3]) by smtp.gmail.com with ESMTPSA id o6sm6305282oia.29.2016.10.24.22.21.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 22:21:46 -0700 (PDT) From: Lv Zheng X-Google-Original-From: Lv Zheng To: "Rafael J . Wysocki" , "Rafael J . Wysocki" , Len Brown Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Lv Zheng Subject: [PATCH 6/6] ACPICA: Tables: Add acpi_tb_unload_table() Date: Tue, 25 Oct 2016 13:21:43 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces acpi_tb_unload_table() to eliminate redundant code from acpi_ex_unload_table() and acpi_unload_parent_table(). No functional change. Lv Zheng. Signed-off-by: Lv Zheng --- drivers/acpi/acpica/actables.h | 2 ++ drivers/acpi/acpica/exconfig.c | 35 +----------------------------- drivers/acpi/acpica/tbdata.c | 48 ++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/acpica/tbxfload.c | 31 +-------------------------- 4 files changed, 52 insertions(+), 64 deletions(-) diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h index 1850005..7dd527f 100644 --- a/drivers/acpi/acpica/actables.h +++ b/drivers/acpi/acpica/actables.h @@ -130,6 +130,8 @@ acpi_status acpi_tb_install_and_load_table(acpi_physical_address address, u8 flags, u8 override, u32 *table_index); +acpi_status acpi_tb_unload_table(u32 table_index); + void acpi_tb_terminate(void); acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index); diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c index 8b8d620..c32c782 100644 --- a/drivers/acpi/acpica/exconfig.c +++ b/drivers/acpi/acpica/exconfig.c @@ -499,7 +499,6 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) acpi_status status = AE_OK; union acpi_operand_object *table_desc = ddb_handle; u32 table_index; - struct acpi_table_header *table; ACPI_FUNCTION_TRACE(ex_unload_table); @@ -536,39 +535,7 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) * strict order requirement against it. */ acpi_ex_exit_interpreter(); - - /* Ensure the table is still loaded */ - - if (!acpi_tb_is_table_loaded(table_index)) { - status = AE_NOT_EXIST; - goto lock_and_exit; - } - - /* Invoke table handler if present */ - - if (acpi_gbl_table_handler) { - status = acpi_get_table_by_index(table_index, &table); - if (ACPI_SUCCESS(status)) { - (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD, - table, - acpi_gbl_table_handler_context); - } - } - - /* Delete the portion of the namespace owned by this table */ - - status = acpi_tb_delete_namespace_by_owner(table_index); - if (ACPI_FAILURE(status)) { - goto lock_and_exit; - } - - (void)acpi_tb_release_owner_id(table_index); - acpi_tb_set_table_loaded_flag(table_index, FALSE); - -lock_and_exit: - - /* Re-acquire the interpreter lock */ - + status = acpi_tb_unload_table(table_index); acpi_ex_enter_interpreter(); /* diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c index 4cbfa30..82b0b57 100644 --- a/drivers/acpi/acpica/tbdata.c +++ b/drivers/acpi/acpica/tbdata.c @@ -871,3 +871,51 @@ unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(status); } + +/******************************************************************************* + * + * FUNCTION: acpi_tb_unload_table + * + * PARAMETERS: table_index - Table index + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ******************************************************************************/ + +acpi_status acpi_tb_unload_table(u32 table_index) +{ + acpi_status status = AE_OK; + struct acpi_table_header *table; + + ACPI_FUNCTION_TRACE(tb_unload_table); + + /* Ensure the table is still loaded */ + + if (!acpi_tb_is_table_loaded(table_index)) { + return_ACPI_STATUS(AE_NOT_EXIST); + } + + /* Invoke table handler if present */ + + if (acpi_gbl_table_handler) { + status = acpi_get_table_by_index(table_index, &table); + if (ACPI_SUCCESS(status)) { + (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD, + table, + acpi_gbl_table_handler_context); + } + } + + /* 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); + return_ACPI_STATUS(status); +} diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c index 35d3f9b..940254c 100644 --- a/drivers/acpi/acpica/tbxfload.c +++ b/drivers/acpi/acpica/tbxfload.c @@ -404,37 +404,8 @@ acpi_status acpi_unload_parent_table(acpi_handle object) break; } - /* Ensure the table is actually loaded */ - (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); - if (!acpi_tb_is_table_loaded(i)) { - status = AE_NOT_EXIST; - (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); - break; - } - - /* Invoke table handler if present */ - - if (acpi_gbl_table_handler) { - (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD, - acpi_gbl_root_table_list. - tables[i].pointer, - acpi_gbl_table_handler_context); - } - - /* - * Delete all namespace objects owned by this table. Note that - * these objects can appear anywhere in the namespace by virtue - * of the AML "Scope" operator. Thus, we need to track ownership - * by an ID, not simply a position within the hierarchy. - */ - status = acpi_tb_delete_namespace_by_owner(i); - if (ACPI_FAILURE(status)) { - break; - } - - status = acpi_tb_release_owner_id(i); - acpi_tb_set_table_loaded_flag(i, FALSE); + status = acpi_tb_unload_table(i); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); break; }