[PATCH 2/2] acpi: refactor by fwts_acpi_reserved_type_check

Alex Hung alex.hung at canonical.com
Thu May 13 19:20:36 UTC 2021


Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
 src/acpi/hmat/hmat.c        | 6 +-----
 src/acpi/nfit/nfit.c        | 8 ++------
 src/acpi/pptt/pptt.c        | 6 +-----
 src/lib/include/fwts_acpi.h | 2 ++
 4 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
index c2efdc93..e1105481 100644
--- a/src/acpi/hmat/hmat.c
+++ b/src/acpi/hmat/hmat.c
@@ -181,11 +181,7 @@ static int hmat_test1(fwts_framework *fw)
 			type_length = sizeof(fwts_acpi_table_hmat_cache) +
 			              ((fwts_acpi_table_hmat_cache *) entry)->num_smbios * 2;
 		} else {
-			passed = false;
-			fwts_failed(fw, LOG_LEVEL_HIGH,
-				"HMATBadSubtableType",
-				"HMAT must have subtable with Type 0..2, got "
-				"0x%2.2" PRIx8 " instead", entry->type);
+			fwts_acpi_reserved_type_check(fw, "HMAT", entry->type, 0, FWTS_ACPI_HMAT_TYPE_RESERVED - 1, &passed);
 			break;
 		}
 
diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c
index 7e250aba..6eba2058 100644
--- a/src/acpi/nfit/nfit.c
+++ b/src/acpi/nfit/nfit.c
@@ -506,12 +506,8 @@ static int nfit_test1(fwts_framework *fw)
 				reserved_passed = nfit_struct->reserved2;
 
 		} else {
-			passed = false;
-			fwts_failed(fw, LOG_LEVEL_HIGH,
-				"NFITBadSubType",
-				"NFIT Structure supports type 0..%" PRId8 ", got "
-				"0x%4.4" PRIx16 " instead", FWTS_ACPI_NFIT_TYPE_RESERVED - 1,
-				entry->type);
+			fwts_acpi_reserved_type_check(fw, "NFIT", entry->type, 0, FWTS_ACPI_NFIT_TYPE_RESERVED - 1, &passed);
+			break;
 		}
 
 		fwts_acpi_reserved_zero_check("NFIT", "Reserved", reserved_passed, &passed);
diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
index 2a4513a6..54eef4a2 100644
--- a/src/acpi/pptt/pptt.c
+++ b/src/acpi/pptt/pptt.c
@@ -145,11 +145,7 @@ static int pptt_test1(fwts_framework *fw)
 			pptt_id_test(fw, (fwts_acpi_table_pptt_id *) entry, &passed);
 			type_length = sizeof(fwts_acpi_table_pptt_id);
 		} else {
-			passed = false;
-			fwts_failed(fw, LOG_LEVEL_HIGH,
-				"PPTTBadSubtableType",
-				"PPTT must have subtable with Type 0..2, got "
-				"0x%2.2" PRIx8 " instead", entry->type);
+			fwts_acpi_reserved_type_check(fw, "PPTT", entry->type, 0, FWTS_ACPI_PPTT_RESERVED - 1, &passed);
 			break;
 		}
 
diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
index 24a58d81..0bad5452 100644
--- a/src/lib/include/fwts_acpi.h
+++ b/src/lib/include/fwts_acpi.h
@@ -1393,6 +1393,7 @@ typedef enum {
 	FWTS_ACPI_HMAT_TYPE_PROXIMITY_DOMAIN	= 0,
 	FWTS_ACPI_HMAT_TYPE_LOCALITY		= 1,
 	FWTS_ACPI_HMAT_TYPE_CACHE		= 2,
+	FWTS_ACPI_HMAT_TYPE_RESERVED
 } fwts_acpi_hmat_type;
 
 typedef struct {
@@ -1460,6 +1461,7 @@ typedef enum {
 	FWTS_ACPI_PPTT_PROCESSOR	= 0,
 	FWTS_ACPI_PPTT_CACHE		= 1,
 	FWTS_ACPI_PPTT_ID		= 2,
+	FWTS_ACPI_PPTT_RESERVED
 } fwts_acpi_pptt_type;
 
 typedef struct {
-- 
2.31.1




More information about the fwts-devel mailing list