ACK: [PATCH 07/16] acpi: battery/method: add _BPC, _BPS and _BPT tests (mantis 1997)
Colin Ian King
colin.king at canonical.com
Tue Jan 26 20:47:45 UTC 2021
On 26/01/2021 20:30, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
> src/acpi/devices/battery/battery.c | 39 ++++++++++++++
> src/acpi/method/method.c | 40 ++++++++++++++
> src/lib/include/fwts_acpi_object_eval.h | 2 +
> src/lib/src/fwts_acpi_object_eval.c | 71 +++++++++++++++++++++++++
> 4 files changed, 152 insertions(+)
>
> diff --git a/src/acpi/devices/battery/battery.c b/src/acpi/devices/battery/battery.c
> index d71c7332..84fcc7d0 100644
> --- a/src/acpi/devices/battery/battery.c
> +++ b/src/acpi/devices/battery/battery.c
> @@ -128,6 +128,39 @@ static int method_test_BMS(fwts_framework *fw)
> "_BMS", arg, 1, fwts_method_test_passed_failed_return, "_BMS");
> }
>
> +static int method_test_BPC(fwts_framework *fw)
> +{
> + return fwts_evaluate_method(fw, METHOD_OPTIONAL, &device,
> + "_BPC", NULL, 0, fwts_method_test_BPC_return, NULL);
> +}
> +
> +static int method_test_BPS(fwts_framework *fw)
> +{
> + return fwts_evaluate_method(fw, METHOD_OPTIONAL, &device,
> + "_BPS", NULL, 0, fwts_method_test_BPS_return, NULL);
> +}
> +
> +static int method_test_BPT(fwts_framework *fw)
> +{
> + ACPI_OBJECT arg[3];
> + uint64_t max = 5;
> + int i;
> +
> + arg[0].Type = ACPI_TYPE_INTEGER;
> + arg[0].Integer.Value = 1;
> + arg[2].Type = ACPI_TYPE_INTEGER;
> + arg[2].Integer.Value = 0;
> + for (i = 0; i <= 2; i++) {
> + arg[1].Type = ACPI_TYPE_INTEGER;
> + arg[1].Integer.Value = i;
> + if (fwts_evaluate_method(fw, METHOD_OPTIONAL, &device, "_BPT", arg, 2,
> + fwts_method_test_integer_max_return, &max) == FWTS_NOT_EXIST)
> + break;
> + fwts_log_nl(fw);
> + }
> +
> + return FWTS_OK;
> +}
>
> static int method_test_BST(fwts_framework *fw)
> {
> @@ -323,6 +356,12 @@ static fwts_framework_minor_test acpi_battery_tests[] = {
> { method_test_BIX, "Test _BIX (Battery Information Extended)." },
> { method_test_BMA, "Test _BMA (Battery Measurement Averaging)." },
> { method_test_BMS, "Test _BMS (Battery Measurement Sampling Time)." },
> + { method_test_BPC, "Test _BPC (Battery Power Characteristics)." },
> + { method_test_BPS, "Test _BPS (Battery Power State)." },
> + { method_test_BPT, "Test _BPT (Battery Power Threshold)." },
> + { method_test_BPC, "Test _BPC (Battery Power Characteristics)." },
> + { method_test_BPS, "Test _BPS (Battery Power State)." },
> + { method_test_BPT, "Test _BPT (Battery Power Threshold)." },
> { method_test_BST, "Test _BST (Battery Status)." },
> { method_test_BTH, "Test _BTH (Battery Throttle Limit)." },
> { method_test_BTP, "Test _BTP (Battery Trip Point)." },
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 805b49bf..43f697fa 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -56,6 +56,9 @@
> * _BMC Y
> * _BMD Y
> * _BMS Y
> + * _BPC Y
> + * _BPS Y
> + * _BPT Y
> * _BQC Y
> * _BST Y
> * _BTH Y
> @@ -3219,6 +3222,40 @@ static int method_test_BMS(fwts_framework *fw)
> "_BMS", arg, 1, fwts_method_test_passed_failed_return, "_BMS");
> }
>
> +static int method_test_BPC(fwts_framework *fw)
> +{
> + return method_evaluate_method(fw, METHOD_OPTIONAL,
> + "_BPC", NULL, 0, fwts_method_test_BPC_return, NULL);
> +}
> +
> +static int method_test_BPS(fwts_framework *fw)
> +{
> + return method_evaluate_method(fw, METHOD_OPTIONAL,
> + "_BPS", NULL, 0, fwts_method_test_BPS_return, NULL);
> +}
> +
> +static int method_test_BPT(fwts_framework *fw)
> +{
> + ACPI_OBJECT arg[3];
> + uint64_t max = 5;
> + int i;
> +
> + arg[0].Type = ACPI_TYPE_INTEGER;
> + arg[0].Integer.Value = 1;
> + arg[2].Type = ACPI_TYPE_INTEGER;
> + arg[2].Integer.Value = 0;
> + for (i = 0; i <= 2; i++) {
> + arg[1].Type = ACPI_TYPE_INTEGER;
> + arg[1].Integer.Value = i;
> + if (method_evaluate_method(fw, METHOD_OPTIONAL, "_BPT", arg, 2,
> + fwts_method_test_integer_max_return, &max) == FWTS_NOT_EXIST)
> + break;
> + fwts_log_nl(fw);
> + }
> +
> + return FWTS_OK;
> +}
> +
> static int method_test_BST(fwts_framework *fw)
> {
> return method_evaluate_method(fw, METHOD_MOBILE,
> @@ -4822,6 +4859,9 @@ static fwts_framework_minor_test method_tests[] = {
> { method_test_BMC, "Test _BMC (Battery Maintenance Control)." },
> { method_test_BMD, "Test _BMD (Battery Maintenance Data)." },
> { method_test_BMS, "Test _BMS (Battery Measurement Sampling Time)." },
> + { method_test_BPC, "Test _BPC (Battery Power Characteristics)." },
> + { method_test_BPS, "Test _BPS (Battery Power State)." },
> + { method_test_BPT, "Test _BPT (Battery Power Threshold)." },
> { method_test_BST, "Test _BST (Battery Status)." },
> { method_test_BTP, "Test _BTP (Battery Trip Point)." },
> { method_test_BTH, "Test _BTH (Battery Throttle Limit)." },
> diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h
> index 996de1fe..9328f984 100644
> --- a/src/lib/include/fwts_acpi_object_eval.h
> +++ b/src/lib/include/fwts_acpi_object_eval.h
> @@ -164,6 +164,8 @@ int fwts_method_test_STR(fwts_framework *fw, ACPI_HANDLE *device);
> int fwts_method_test_UID(fwts_framework *fw, ACPI_HANDLE *device);
>
> void fwts_method_test_BMD_return(fwts_framework *fw, char *name,ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> +void fwts_method_test_BPC_return(fwts_framework *fw, char *name,ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> +void fwts_method_test_BPS_return(fwts_framework *fw, char *name,ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> void fwts_method_valid_CID_Type(fwts_framework *fw, char *name, ACPI_OBJECT *obj);
> void fwts_method_test_CID_return(fwts_framework *fw, char *name,ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> void fwts_method_test_HID_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 dda29eaf..d894d149 100644
> --- a/src/lib/src/fwts_acpi_object_eval.c
> +++ b/src/lib/src/fwts_acpi_object_eval.c
> @@ -3066,5 +3066,76 @@ void fwts_method_test_BST_return(
> fwts_method_passed_sane(fw, name, "package");
> }
>
> +void fwts_method_test_BPC_return(
> + fwts_framework *fw,
> + char *name,
> + ACPI_BUFFER *buf,
> + ACPI_OBJECT *obj,
> + void *private)
> +{
> + bool passed = true;
> +
> + static const fwts_package_element elements[] = {
> + { ACPI_TYPE_INTEGER, "Revision," },
> + { ACPI_TYPE_INTEGER, "Power Threshold Support" },
> + { ACPI_TYPE_INTEGER, "Max Instantaneous Peak Power Threshold" },
> + { ACPI_TYPE_INTEGER, "Max Sustainable Peak Power Threshold" }
> + };
> +
> + FWTS_UNUSED(private);
> +
> + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
> + return;
> +
> + if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
> + return;
> +
> + if (fwts_method_test_revision(fw, name, obj->Package.Elements[0].Integer.Value, 1) != FWTS_OK)
> + passed = false;
> +
> + fwts_acpi_reserved_bits_check(fw, "_BPC", "Power Threshold Support Capability",
> + obj->Package.Elements[1].Integer.Value, sizeof(uint32_t), 2, 31, &passed);
> +
> + if (!passed)
> + fwts_advice(fw,
> + "Battery %s package contains errors.", name);
> + else
> + fwts_method_passed_sane(fw, name, "package");
> +}
> +
> +void fwts_method_test_BPS_return(
> + fwts_framework *fw,
> + char *name,
> + ACPI_BUFFER *buf,
> + ACPI_OBJECT *obj,
> + void *private)
> +{
> + bool passed = true;
> +
> + static const fwts_package_element elements[] = {
> + { ACPI_TYPE_INTEGER, "Revision," },
> + { ACPI_TYPE_INTEGER, "Instantaneous Peak Power Level" },
> + { ACPI_TYPE_INTEGER, "Instantaneous Peak Power Period" },
> + { ACPI_TYPE_INTEGER, "Sustainable Peak Power Level" },
> + { ACPI_TYPE_INTEGER, "Sustainable Peak Power Period" },
> + };
> +
> + FWTS_UNUSED(private);
> +
> + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
> + return;
> +
> + if (fwts_method_package_elements_type(fw, name, obj, elements) != FWTS_OK)
> + return;
> +
> + if (fwts_method_test_revision(fw, name, obj->Package.Elements[0].Integer.Value, 1) != FWTS_OK)
> + passed = false;
> +
> + if (!passed)
> + fwts_advice(fw,
> + "Battery %s package contains errors.", name);
> + else
> + fwts_method_passed_sane(fw, name, "package");
> +}
>
> #endif
>
Acked-by: Colin Ian King <colin.king at canonical.com>
More information about the fwts-devel
mailing list