[PATCH 1/4] acpi: replace objname by get_object_name() in various functions
Alex Hung
alex.hung at canonical.com
Wed Jan 20 23:23:01 UTC 2021
Including the following functions:
fwts_method_package_count_min
fwts_method_package_count_equal
fwts_method_subpackage_count_equal
fwts_method_package_elements_all_type
fwts_method_package_elements_type
Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
src/acpi/devices/ac_adapter/ac.c | 8 +-
src/acpi/devices/battery/battery.c | 18 ++--
src/acpi/devices/lid/lid.c | 2 +-
src/acpi/method/method.c | 120 ++++++++++++------------
src/lib/include/fwts_acpi_object_eval.h | 16 ++--
src/lib/src/fwts_acpi_object_eval.c | 45 ++++-----
6 files changed, 105 insertions(+), 104 deletions(-)
diff --git a/src/acpi/devices/ac_adapter/ac.c b/src/acpi/devices/ac_adapter/ac.c
index 244a221b..0de13b2d 100644
--- a/src/acpi/devices/ac_adapter/ac.c
+++ b/src/acpi/devices/ac_adapter/ac.c
@@ -116,7 +116,7 @@ static void method_test_PCL_return(fwts_framework *fw,
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PCL", obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
return;
fwts_passed(fw, "%s returned a sane package of %" PRIu32 " references.", name, obj->Package.Count);
@@ -149,10 +149,10 @@ static void method_test_PIF_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_PIF", obj, 6) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 6) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_PIF", obj, elements) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
return;
fwts_acpi_object_dump(fw, obj);
@@ -178,7 +178,7 @@ static void method_test_PRL_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PRL", obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
return;
fwts_method_passed_sane(fw, name, "package");
diff --git a/src/acpi/devices/battery/battery.c b/src/acpi/devices/battery/battery.c
index ec250de8..049479fb 100644
--- a/src/acpi/devices/battery/battery.c
+++ b/src/acpi/devices/battery/battery.c
@@ -107,10 +107,10 @@ static void method_test_BIF_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_BIF", obj, 13) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 13) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_BIF", obj, elements) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
return;
/* Sanity check each field */
@@ -285,17 +285,17 @@ static void method_test_BIX_return(
switch (revision) {
case 0:
- if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 20) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 20) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
return;
break;
case 1:
- if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 21) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 21) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements_v1) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements_v1) != FWTS_OK)
return;
break;
default:
@@ -477,10 +477,10 @@ static void method_test_BST_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_BST", obj, 4) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 4) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_BST", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
/* Sanity check each field */
@@ -570,7 +570,7 @@ static void method_test_PCL_return(fwts_framework *fw,
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PCL", obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
return;
fwts_passed(fw, "%s returned a sane package of %" PRIu32 " references.", name, obj->Package.Count);
diff --git a/src/acpi/devices/lid/lid.c b/src/acpi/devices/lid/lid.c
index dadee79e..136f2a61 100644
--- a/src/acpi/devices/lid/lid.c
+++ b/src/acpi/devices/lid/lid.c
@@ -111,7 +111,7 @@ static void method_test_PRW_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_min(fw, name, "_PRW", obj, 2) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 2) != FWTS_OK)
return;
if (obj->Package.Elements[0].Type != ACPI_TYPE_INTEGER &&
diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 6addf7c9..544cbda7 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -686,14 +686,14 @@ static void method_test_DLM_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_DLM", obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
/* Could be one or more packages */
for (i = 0; i < obj->Package.Count; i++) {
ACPI_OBJECT *pkg = &obj->Package.Elements[i];
- if (fwts_method_subpackage_count_equal(fw, name, "_DLM", pkg, i, 2) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 2) != FWTS_OK) {
failed = true;
continue;
}
@@ -894,7 +894,7 @@ static void method_test_PRT_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PRT", obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
for (i = 0; i < obj->Package.Count; i++) {
@@ -903,7 +903,7 @@ static void method_test_PRT_return(
pkg = &obj->Package.Elements[i];
/* check size of sub-packages */
- if (fwts_method_subpackage_count_equal(fw, name, "_PRT", pkg, i, 4) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 4) != FWTS_OK) {
failed = true;
continue;
}
@@ -985,7 +985,7 @@ static void method_test_FIX_return(
return;
/* All elements in the package must be integers */
- if (fwts_method_package_elements_all_type(fw, name, "_FIX", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
/* And they need to be valid IDs */
@@ -1364,7 +1364,7 @@ static void method_test_PRW_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_min(fw, name, "_PRW", obj, 2) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 2) != FWTS_OK)
return;
if (obj->Package.Elements[0].Type != ACPI_TYPE_INTEGER &&
@@ -1378,7 +1378,7 @@ static void method_test_PRW_return(
if (obj->Package.Elements[0].Type == ACPI_TYPE_PACKAGE) {
ACPI_OBJECT *pkg;
pkg = &obj->Package.Elements[0];
- if (fwts_method_subpackage_count_equal(fw, name, "_PRW", pkg, 0, 2) != FWTS_OK)
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, 0, 2) != FWTS_OK)
failed = true;
if (pkg->Package.Elements[0].Type != ACPI_TYPE_LOCAL_REFERENCE) {
@@ -1505,14 +1505,12 @@ static void method_test_power_resources_return(
ACPI_OBJECT *obj,
void *private)
{
- char *objname = (char *)private;
-
FWTS_UNUSED(private);
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, objname,
+ if (fwts_method_package_elements_all_type(fw, name,
obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
return;
@@ -1588,10 +1586,10 @@ static void method_test_PRR_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_PRR", obj, 1) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 1) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PRR", obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
return;
fwts_method_passed_sane(fw, name, "package");
@@ -1813,26 +1811,26 @@ static void method_test_CPC_return(
if (revision == 1) { // acpi 5.0
/* Something is really wrong if we don't have any elements in _CPC */
- if (fwts_method_package_count_equal(fw, name, "_CPC", obj, 17) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 17) != FWTS_OK)
return;
/* For now, just check types */
- if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv1) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elementsv1) != FWTS_OK)
return;
} else if (revision == 2) { // acpi 5.1 ~ acpi 6.1a
/* Something is really wrong if we don't have any elements in _CPC */
- if (fwts_method_package_count_equal(fw, name, "_CPC", obj, 21) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 21) != FWTS_OK)
return;
/* For now, just check types */
- if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv2) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elementsv2) != FWTS_OK)
return;
} else if (revision == 3) { // acpi 6.2 and later
- if (fwts_method_package_count_equal(fw, name, "_CPC", obj, 23) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 23) != FWTS_OK)
return;
/* For now, just check types */
- if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv3) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elementsv3) != FWTS_OK)
return;
} else {
fwts_failed(fw, LOG_LEVEL_HIGH,
@@ -1868,7 +1866,7 @@ static void method_test_CSD_return(
return;
/* Something is really wrong if we don't have any elements in _CSD */
- if (fwts_method_package_count_min(fw, name, "_CSD", obj, 1) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 1) != FWTS_OK)
return;
/* Could be one or more packages */
@@ -1877,7 +1875,7 @@ static void method_test_CSD_return(
uint32_t j;
bool elements_ok = true;
- if (fwts_method_package_elements_all_type(fw, name, "_CSD",
+ if (fwts_method_package_elements_all_type(fw, name,
obj, ACPI_TYPE_PACKAGE) != FWTS_OK) {
failed = true;
continue; /* Skip processing sub-package */
@@ -1887,7 +1885,7 @@ static void method_test_CSD_return(
/*
* Currently we expect a package of 6 integers.
*/
- if (fwts_method_subpackage_count_equal(fw, name, "_CSD", pkg, i, 6) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 6) != FWTS_OK) {
failed = true;
continue;
}
@@ -1991,7 +1989,7 @@ static void method_test_CST_return(
return;
/* _CST has at least two elements */
- if (fwts_method_package_count_min(fw, name, "_CST", obj, 2) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 2) != FWTS_OK)
return;
/* Element 1 must be an integer */
@@ -2036,7 +2034,7 @@ static void method_test_CST_return(
pkg = &obj->Package.Elements[i];
- if (fwts_method_subpackage_count_equal(fw, name, "_CST", pkg, i, 4) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 4) != FWTS_OK) {
cst_elements_ok[i] = false;
failed = true;
continue;
@@ -2133,10 +2131,10 @@ static void method_test_PCT_return(
return;
/* Something is really wrong if we don't have any elements in _PCT */
- if (fwts_method_package_count_min(fw, name, "_PCT", obj, 2) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 2) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PCT",
+ if (fwts_method_package_elements_all_type(fw, name,
obj, ACPI_TYPE_BUFFER) != FWTS_OK)
return;
@@ -2170,7 +2168,7 @@ static void method_test_PSS_return(
return;
/* Something is really wrong if we don't have any elements in _PSS */
- if (fwts_method_package_count_min(fw, name, "_PSS", obj, 1) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 1) != FWTS_OK)
return;
element_ok = calloc(obj->Package.Count, sizeof(bool));
@@ -2345,10 +2343,10 @@ static void method_test_PSD_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_PSD", obj, 1) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 1) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PSD", obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
/* Could be one or more packages */
@@ -2358,7 +2356,7 @@ static void method_test_PSD_return(
bool elements_ok = true;
pkg = &obj->Package.Elements[i];
- if (fwts_method_subpackage_count_equal(fw, name, "_PSD", pkg, i, 5) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 5) != FWTS_OK) {
failed = true;
continue;
}
@@ -2407,10 +2405,10 @@ static void method_test_PTC_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_PTC", obj, ACPI_TYPE_BUFFER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_BUFFER) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_PTC", obj, 2) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 2) != FWTS_OK)
return;
for (i = 0; i < obj->Package.Count; i++) {
@@ -2474,7 +2472,7 @@ static void method_test_TSD_return(
return;
if (fwts_get_acpi_version(fw) >= FWTS_ACPI_VERSION_62) {
- if (fwts_method_package_count_equal(fw, name, "_TSD", obj, 1) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 1) != FWTS_OK)
return;
}
@@ -2497,7 +2495,7 @@ static void method_test_TSD_return(
/*
* Currently we expect a package of 5 integers.
*/
- if (fwts_method_subpackage_count_equal(fw, name, "TSD", pkg, i, 5) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 5) != FWTS_OK) {
failed = true;
continue;
}
@@ -2587,7 +2585,7 @@ static void method_test_TSS_return(
return;
/* Something is really wrong if we don't have any elements in _TSS */
- if (fwts_method_package_count_min(fw, name, "_TSS", obj, 1) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 1) != FWTS_OK)
return;
tss_elements_ok = calloc(obj->Package.Count, sizeof(bool));
@@ -2617,7 +2615,7 @@ static void method_test_TSS_return(
/*
* We expect a package of 5 integers.
*/
- if (fwts_method_subpackage_count_equal(fw, name, "_TSS", pkg, i, 5) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 5) != FWTS_OK) {
tss_elements_ok[i] = false;
failed = true;
continue; /* Skip processing sub-package */
@@ -2710,7 +2708,7 @@ static void method_test_LPI_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_min(fw, name, "_LPI", obj, 3) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 3) != FWTS_OK)
return;
/* first 3 elements are integers, and rests are packages */
@@ -2889,10 +2887,10 @@ static void method_test_PUR_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_PUR", obj, 2) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 2) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_PUR", obj, elements) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
return;
/* RevisionID */
@@ -2979,7 +2977,7 @@ static void method_test_ALR_return(
ACPI_OBJECT *pkg;
pkg = &obj->Package.Elements[i];
- if (fwts_method_subpackage_count_equal(fw, name, "_ALR", pkg, i, 2) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 2) != FWTS_OK) {
failed = true;
} else {
/* elements should be listed in monotonically increasing order */
@@ -3114,10 +3112,10 @@ static void method_test_UPC_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_UPC", obj, 4) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 4) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_UPC", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
connector_type = obj->Package.Elements[1].Integer.Value;
@@ -3477,10 +3475,10 @@ static void method_test_BIF_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_BIF", obj, 13) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 13) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_BIF", obj, elements) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
return;
/* Sanity check each field */
@@ -3646,17 +3644,17 @@ static void method_test_BIX_return(
switch (revision) {
case 0:
- if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 20) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 20) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
return;
break;
case 1:
- if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 21) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 21) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements_v1) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements_v1) != FWTS_OK)
return;
break;
default:
@@ -3829,10 +3827,10 @@ static void method_test_BST_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_BST", obj, 4) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 4) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_BST", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
/* Sanity check each field */
@@ -3992,10 +3990,10 @@ static void method_test_PIF_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_PIF", obj, 6) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 6) != FWTS_OK)
return;
- if (fwts_method_package_elements_type(fw, name, "_PIF", obj, elements) != FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
return;
fwts_acpi_object_dump(fw, obj);
@@ -4041,7 +4039,7 @@ static void method_test_PMC_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_PMC", obj, 14) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 14) != FWTS_OK)
return;
/* check element types */
@@ -4224,7 +4222,7 @@ static void method_test_FPS_return(
}
pkg = &obj->Package.Elements[i];
- if (fwts_method_subpackage_count_equal(fw, name, "_FPS", pkg, i, 5) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 5) != FWTS_OK) {
failed = true;
continue;
}
@@ -4421,7 +4419,7 @@ static void method_test_ART_return(
}
pkg = &obj->Package.Elements[i];
- if (fwts_method_subpackage_count_equal(fw, name, "_ART", pkg, i, 13) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 13) != FWTS_OK) {
failed = true;
continue;
}
@@ -4475,7 +4473,7 @@ static void method_test_TRT_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_TRT", obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
/* Could be one or more packages */
@@ -4485,7 +4483,7 @@ static void method_test_TRT_return(
bool elements_ok = true;
pkg = &obj->Package.Elements[i];
- if (fwts_method_subpackage_count_equal(fw, name, "_TRT", pkg, i, 8) != FWTS_OK) {
+ if (fwts_method_subpackage_count_equal(fw, name, pkg, i, 8) != FWTS_OK) {
failed = true;
continue;
}
@@ -4687,7 +4685,7 @@ static void method_test_GPE_return(
name, (uint64_t)obj->Integer.Value);
break;
case ACPI_TYPE_PACKAGE:
- if (fwts_method_package_elements_type(fw, name, "_GPE", obj, elem) == FWTS_OK)
+ if (fwts_method_package_elements_type(fw, name, obj, elem) == FWTS_OK)
fwts_method_passed_sane(fw, name, "package");
break;
@@ -4783,10 +4781,10 @@ static void method_test_WAK_return(
switch (obj->Type) {
case ACPI_TYPE_PACKAGE:
- if (fwts_method_package_count_equal(fw, name, "_WAK", obj, 2) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 2) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_WAK", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
fwts_method_passed_sane(fw, name, "package");
@@ -4986,10 +4984,10 @@ static void method_test_BCL_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_min(fw, name, "_BCL", obj, 3) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 3) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_BCL", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
if (obj->Package.Elements[0].Integer.Value <
diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h
index fcfe8646..34660286 100644
--- a/src/lib/include/fwts_acpi_object_eval.h
+++ b/src/lib/include/fwts_acpi_object_eval.h
@@ -109,22 +109,22 @@ typedef struct {
#define fwts_method_check_type(fw, name, buf, type) \
fwts_method_check_type__(fw, name, buf, type, #type)
-#define fwts_method_package_elements_type(fw, name, objname, obj, info) \
- fwts_method_package_elements_type__(fw, name, objname, obj, info, FWTS_ARRAY_SIZE(info))
+#define fwts_method_package_elements_type(fw, name, obj, info) \
+ fwts_method_package_elements_type__(fw, name, obj, info, FWTS_ARRAY_SIZE(info))
int fwts_method_check_type__(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT_TYPE type, char *type_name);
-int fwts_method_check_element_type(fwts_framework *fw, char *name, ACPI_OBJECT *obj, uint32_t subpkg, uint32_t element, ACPI_OBJECT_TYPE type);
+int fwts_method_check_element_type(fwts_framework *fw, const char *name, ACPI_OBJECT *obj, uint32_t subpkg, uint32_t element, ACPI_OBJECT_TYPE type);
const char *fwts_method_type_name(const ACPI_OBJECT_TYPE type);
void fwts_method_passed_sane(fwts_framework *fw, const char *name, const char *type);
void fwts_method_passed_sane_uint64(fwts_framework *fw, const char *name, const uint64_t value);
void fwts_method_failed_null_object(fwts_framework *fw, const char *name, const char *type);
bool fwts_method_type_matches(ACPI_OBJECT_TYPE t1, ACPI_OBJECT_TYPE t2);
int fwts_method_buffer_size(fwts_framework *fw, const char *name, ACPI_OBJECT *obj, size_t buf_size);
-int fwts_method_package_count_min(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const uint32_t min);
-int fwts_method_package_count_equal(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const uint32_t count);
-int fwts_method_subpackage_count_equal(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const uint32_t sub, const uint32_t count);
-int fwts_method_package_elements_all_type(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const ACPI_OBJECT_TYPE type);
-int fwts_method_package_elements_type__(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const fwts_package_element *info, const uint32_t count);
+int fwts_method_package_count_min(fwts_framework *fw, const char *name, const ACPI_OBJECT *obj, const uint32_t min);
+int fwts_method_package_count_equal(fwts_framework *fw, const char *name, const ACPI_OBJECT *obj, const uint32_t count);
+int fwts_method_subpackage_count_equal(fwts_framework *fw, const char *name, const ACPI_OBJECT *obj, const uint32_t sub, const uint32_t count);
+int fwts_method_package_elements_all_type(fwts_framework *fw, const char *name, const ACPI_OBJECT *obj, const ACPI_OBJECT_TYPE type);
+int fwts_method_package_elements_type__(fwts_framework *fw, const char *name, const ACPI_OBJECT *obj, const fwts_package_element *info, const uint32_t count);
int fwts_method_test_revision(fwts_framework *fw, const char *name, const uint32_t cur_revision, const uint32_t spec_revision);
void fwts_method_test_integer_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
diff --git a/src/lib/src/fwts_acpi_object_eval.c b/src/lib/src/fwts_acpi_object_eval.c
index 40d73511..a9ee84b3 100644
--- a/src/lib/src/fwts_acpi_object_eval.c
+++ b/src/lib/src/fwts_acpi_object_eval.c
@@ -500,9 +500,9 @@ int fwts_method_check_type__(
* get objname from full path nanme
* ex. _BCL from _SB.PCI0.GFX0.LCD0._BCL
*/
-static void get_object_name(char *name, char* obj_name) {
+static void get_object_name(const char *name, char* obj_name) {
/* obj_name must have length of 5 */
- if (name != NULL && strlen(name) > 4) {
+ if (name != NULL && strlen(name) >= 4) {
memcpy(obj_name, name + strlen(name) - 4, 4);
obj_name[4] = '\0';
}
@@ -546,7 +546,7 @@ static const char *acpi_object_names[] = {
*/
int fwts_method_check_element_type(
fwts_framework *fw,
- char *name,
+ const char *name,
ACPI_OBJECT *obj,
uint32_t subpkg,
uint32_t element,
@@ -682,13 +682,14 @@ int fwts_method_buffer_size(
int fwts_method_package_count_min(
fwts_framework *fw,
const char *name,
- const char *objname,
const ACPI_OBJECT *obj,
const uint32_t min)
{
if (obj->Package.Count < min) {
+ char objname[5] = "_XYZ";
char tmp[128];
+ get_object_name(name, objname);
snprintf(tmp, sizeof(tmp), "Method%sElementCount", objname);
fwts_failed(fw, LOG_LEVEL_CRITICAL, tmp,
"%s should return package of at least %" PRIu32
@@ -707,13 +708,14 @@ int fwts_method_package_count_min(
int fwts_method_package_count_equal(
fwts_framework *fw,
const char *name,
- const char *objname,
const ACPI_OBJECT *obj,
const uint32_t count)
{
if (obj->Package.Count != count) {
+ char objname[5] = "_XYZ";
char tmp[128];
+ get_object_name(name, objname);
snprintf(tmp, sizeof(tmp), "Method%sElementCount", objname);
fwts_failed(fw, LOG_LEVEL_CRITICAL, tmp,
"%s should return package of %" PRIu32
@@ -732,14 +734,15 @@ int fwts_method_package_count_equal(
int fwts_method_subpackage_count_equal(
fwts_framework *fw,
const char *name,
- const char *objname,
const ACPI_OBJECT *obj,
const uint32_t sub,
const uint32_t count)
{
if (obj->Package.Count != count) {
+ char objname[5] = "_XYZ";
char tmp[128];
+ get_object_name(name, objname);
snprintf(tmp, sizeof(tmp), "Method%sSubPackageElementCount", objname);
fwts_failed(fw, LOG_LEVEL_CRITICAL, tmp,
"%s sub-package %" PRIu32 " was expected to have "
@@ -754,7 +757,6 @@ int fwts_method_subpackage_count_equal(
int fwts_method_package_elements_all_type(
fwts_framework *fw,
const char *name,
- const char *objname,
const ACPI_OBJECT *obj,
const ACPI_OBJECT_TYPE type)
{
@@ -764,6 +766,9 @@ int fwts_method_package_elements_all_type(
for (i = 0; i < obj->Package.Count; i++) {
if (!fwts_method_type_matches(obj->Package.Elements[i].Type, type)) {
+ char objname[5] = "_XYZ";
+
+ get_object_name(name, objname);
snprintf(tmp, sizeof(tmp), "Method%sElementType", objname);
fwts_failed(fw, LOG_LEVEL_CRITICAL, tmp,
"%s package element %" PRIu32 " was not the expected "
@@ -786,7 +791,6 @@ int fwts_method_package_elements_all_type(
int fwts_method_package_elements_type__(
fwts_framework *fw,
const char *name,
- const char *objname,
const ACPI_OBJECT *obj,
const fwts_package_element *info,
const uint32_t count)
@@ -800,6 +804,9 @@ int fwts_method_package_elements_type__(
for (i = 0; i < obj->Package.Count; i++) {
if (!fwts_method_type_matches(obj->Package.Elements[i].Type, info[i].type)) {
+ char objname[5] = "_XYZ";
+
+ get_object_name(name, objname);
snprintf(tmp, sizeof(tmp), "Method%sElementType", objname);
fwts_failed(fw, LOG_LEVEL_CRITICAL, tmp,
"%s package element %" PRIu32 " (%s) was not the expected "
@@ -964,12 +971,12 @@ void fwts_method_test_all_reference_package_return(
ACPI_OBJECT *obj,
void *private)
{
- char *objname = (char *)private;
+ FWTS_UNUSED(private);
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, objname, obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_LOCAL_REFERENCE) != FWTS_OK)
return;
fwts_passed(fw, "%s returned a sane package of %" PRIu32 " references.", name, obj->Package.Count);
@@ -1044,22 +1051,18 @@ void fwts_method_test_package_integer_return(
ACPI_OBJECT *obj,
void *private)
{
- char method[5];
uint32_t *element_size = (uint32_t *) private;
if (strlen(name) < 4)
return;
- memcpy(method, name + strlen(name) - 4, 4);
- method[4] = '\0';
-
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, method, obj, *element_size) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, *element_size) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, method, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
fwts_method_passed_sane(fw, name, "package");
@@ -2120,7 +2123,7 @@ void fwts_method_test_CID_return(
fwts_method_valid_CID_Type(fw, name, obj);
break;
case ACPI_TYPE_PACKAGE:
- if (fwts_method_package_count_min(fw, name, "_CID", obj, 1) != FWTS_OK)
+ if (fwts_method_package_count_min(fw, name, obj, 1) != FWTS_OK)
return;
for (i = 0; i < obj->Package.Count; i++){
@@ -2240,7 +2243,7 @@ void fwts_method_test_MLS_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_MLS", obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
/* Could be one or more packages */
@@ -2299,7 +2302,7 @@ void fwts_method_test_PLD_return(
return;
/* All elements in the package must be buffers */
- if (fwts_method_package_elements_all_type(fw, name, "_PLD", obj, ACPI_TYPE_BUFFER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_BUFFER) != FWTS_OK)
return;
fwts_method_passed_sane(fw, name, "package");
@@ -2425,10 +2428,10 @@ void fwts_method_test_BMD_return(
if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
return;
- if (fwts_method_package_count_equal(fw, name, "_BMD", obj, 5) != FWTS_OK)
+ if (fwts_method_package_count_equal(fw, name, obj, 5) != FWTS_OK)
return;
- if (fwts_method_package_elements_all_type(fw, name, "_BMD", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
+ if (fwts_method_package_elements_all_type(fw, name, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
return;
fwts_acpi_reserved_bits_check(fw, "_BMD", "Status Flags",
--
2.25.1
More information about the fwts-devel
mailing list