[PATCH 14/16] acpi: battery: add Battery Charge Limiting (mantis 2090)

Alex Hung alex.hung at canonical.com
Tue Jan 26 20:30:38 UTC 2021


Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
 src/acpi/devices/battery/battery.c  |  2 +-
 src/acpi/method/method.c            |  2 +-
 src/lib/src/fwts_acpi_object_eval.c | 14 ++++----------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/acpi/devices/battery/battery.c b/src/acpi/devices/battery/battery.c
index 84fcc7d0..68d5fc7f 100644
--- a/src/acpi/devices/battery/battery.c
+++ b/src/acpi/devices/battery/battery.c
@@ -273,7 +273,7 @@ static int method_test_BMD(fwts_framework *fw)
 
 static int method_test_BMC(fwts_framework *fw)
 {
-	static const int values[] = { 0, 1, 2, 4 };
+	static const int values[] = { 0, 1, 2, 4, 8};
 	ACPI_STATUS status;
 	uint8_t i;
 
diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 90e03304..8ef5da5e 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -3328,7 +3328,7 @@ static int method_test_BMD(fwts_framework *fw)
 
 static int method_test_BMC(fwts_framework *fw)
 {
-	static const int values[] = { 0, 1, 2, 4 };
+	static const int values[] = { 0, 1, 2, 4, 8};
 	int i;
 
 	for (i = 0; i < FWTS_ARRAY_SIZE(values); i++) {
diff --git a/src/lib/src/fwts_acpi_object_eval.c b/src/lib/src/fwts_acpi_object_eval.c
index d894d149..17e42ca0 100644
--- a/src/lib/src/fwts_acpi_object_eval.c
+++ b/src/lib/src/fwts_acpi_object_eval.c
@@ -2437,10 +2437,10 @@ void fwts_method_test_BMD_return(
 		return;
 
 	fwts_acpi_reserved_bits_check(fw, "_BMD", "Status Flags",
-		obj->Package.Elements[0].Integer.Value, sizeof(uint32_t), 5, 31, &failed);
+		obj->Package.Elements[0].Integer.Value, sizeof(uint32_t), 7, 31, &failed);
 
 	fwts_acpi_reserved_bits_check(fw, "_BMD", "Capability Flags",
-		obj->Package.Elements[1].Integer.Value, sizeof(uint32_t), 5, 31, &failed);
+		obj->Package.Elements[1].Integer.Value, sizeof(uint32_t), 6, 31, &failed);
 
 	if (!failed)
 		fwts_method_passed_sane(fw, name, "package");
@@ -3034,14 +3034,8 @@ void fwts_method_test_BST_return(
 
 	/* Sanity check each field */
 	/* Battery State */
-	if ((obj->Package.Elements[0].Integer.Value) > 7) {
-		fwts_failed(fw, LOG_LEVEL_CRITICAL,
-			"Method_BSTBadState",
-			"%s: Expected Battery State (Element 0) to "
-			"be 0..7, got 0x%8.8" PRIx64 ".",
-			name, (uint64_t)obj->Package.Elements[0].Integer.Value);
-		failed = true;
-	}
+	fwts_acpi_reserved_bits_check(fw, "_BST", "Battery State",
+			obj->Package.Elements[0].Integer.Value, sizeof(uint32_t), 3, 31, &failed);
 	/* Ensure bits 0 (discharging) and 1 (charging) are not both set, see 10.2.2.6 */
 	if (((obj->Package.Elements[0].Integer.Value) & 3) == 3) {
 		fwts_failed(fw, LOG_LEVEL_CRITICAL,
-- 
2.25.1




More information about the fwts-devel mailing list