From 4551f51fa8ba33a977721c3b250cb70a309e3f23 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 26 Jun 2017 08:30:17 +0800 Subject: [PATCH] Tables: Cleanup table handler invokers Recently, we allows the table mutex to be held in both early and late stage APIs. This patch further cleans up the related code to reduce redundant code related to AcpiGbl_TableHandler. Lv Zheng. Tested-by: Hans de Goede Signed-off-by: Lv Zheng --- source/components/tables/tbdata.c | 49 ++++++++++++++++++++--------- source/components/tables/tbinstal.c | 8 ++--- source/include/actables.h | 5 +++ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/source/components/tables/tbdata.c b/source/components/tables/tbdata.c index 29eaf89123..f6f2fea992 100644 --- a/source/components/tables/tbdata.c +++ b/source/components/tables/tbdata.c @@ -1029,14 +1029,9 @@ AcpiTbLoadTable ( AcpiEvUpdateGpes (OwnerId); } - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); - } + /* Invoke table handler */ + AcpiTbNotifyTable (ACPI_TABLE_EVENT_LOAD, Table); return_ACPI_STATUS (Status); } @@ -1117,16 +1112,12 @@ AcpiTbUnloadTable ( return_ACPI_STATUS (AE_NOT_EXIST); } - /* Invoke table handler if present */ + /* Invoke table handler */ - if (AcpiGbl_TableHandler) + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) { - Status = AcpiGetTableByIndex (TableIndex, &Table); - if (ACPI_SUCCESS (Status)) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, - AcpiGbl_TableHandlerContext); - } + AcpiTbNotifyTable (ACPI_TABLE_EVENT_UNLOAD, Table); } /* Delete the portion of the namespace owned by this table */ @@ -1141,3 +1132,31 @@ AcpiTbUnloadTable ( AcpiTbSetTableLoadedFlag (TableIndex, FALSE); return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiTbNotifyTable + * + * PARAMETERS: Event - Table event + * Table - Validated table pointer + * + * RETURN: None + * + * DESCRIPTION: Notify a table event to the users. + * + ******************************************************************************/ + +void +AcpiTbNotifyTable ( + UINT32 Event, + void *Table) +{ + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (Event, Table, + AcpiGbl_TableHandlerContext); + } +} diff --git a/source/components/tables/tbinstal.c b/source/components/tables/tbinstal.c index f4c8e16032..2e5a507dc0 100644 --- a/source/components/tables/tbinstal.c +++ b/source/components/tables/tbinstal.c @@ -434,14 +434,10 @@ AcpiTbInstallStandardTable ( AcpiTbInstallTableWithOverride (&NewTableDesc, Override, TableIndex); - /* Invoke table handler if present */ + /* Invoke table handler */ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_INSTALL, - NewTableDesc.Pointer, AcpiGbl_TableHandlerContext); - } + AcpiTbNotifyTable (ACPI_TABLE_EVENT_INSTALL, NewTableDesc.Pointer); (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); UnlockAndExit: diff --git a/source/include/actables.h b/source/include/actables.h index 8f5a3948c1..608db51097 100644 --- a/source/include/actables.h +++ b/source/include/actables.h @@ -302,6 +302,11 @@ ACPI_STATUS AcpiTbUnloadTable ( UINT32 TableIndex); +void +AcpiTbNotifyTable ( + UINT32 Event, + void *Table); + void AcpiTbTerminate ( void);