diff mbox series

acpi/method: check levels on full power and battery power

Message ID 20190130203802.10290-1-alex.hung@canonical.com
State Accepted
Headers show
Series acpi/method: check levels on full power and battery power | expand

Commit Message

Alex Hung Jan. 30, 2019, 8:38 p.m. UTC
This checks whether 1st (full) and 2nd (battery) levels are also in the
brightness levels.

Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/acpi/method/method.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

Ivan Hu Jan. 31, 2019, 8:11 a.m. UTC | #1
On 1/31/19 4:38 AM, Alex Hung wrote:
> This checks whether 1st (full) and 2nd (battery) levels are also in the
> brightness levels.
>
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/method/method.c | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 654112d9..91156d1a 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -5460,6 +5460,7 @@ static void method_test_BCL_return(
>  	uint32_t i;
>  	bool failed = false;
>  	bool ascending_levels = false;
> +	bool matching_levels;
>  	char *str = NULL;
>  
>  	FWTS_UNUSED(private);
> @@ -5511,6 +5512,42 @@ static void method_test_BCL_return(
>  		failed = true;
>  	}
>  
> +	matching_levels = false;
> +	for (i = 2; i < obj->Package.Count; i++) {
> +		if (obj->Package.Elements[0].Integer.Value ==
> +		    obj->Package.Elements[i].Integer.Value) {
> +			matching_levels = true;
> +			break;
> +		}
> +	}
> +
> +	if (!matching_levels) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_BCLFullNotInList",
> +			"brightness level on full power (%" PRIu64
> +			") is not in brightness levels.",
> +			obj->Package.Elements[0].Integer.Value);
> +	}
> +
> +	matching_levels = false;
> +	for (i = 2; i < obj->Package.Count; i++) {
> +		if (obj->Package.Elements[1].Integer.Value ==
> +		    obj->Package.Elements[i].Integer.Value) {
> +			matching_levels = true;
> +			break;
> +		}
> +	}
> +
> +	if (!matching_levels) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_BCLBatteryNotInList",
> +			"brightness level on battery (%" PRIu64
> +			") is not in brightness levels.",
> +			obj->Package.Elements[1].Integer.Value);
> +	}
> +
>  	fwts_log_info(fw, "Brightness levels for %s:" ,name);
>  	fwts_log_info_verbatim(fw, "  Level on full power   : %" PRIu64,
>  		(uint64_t)obj->Package.Elements[0].Integer.Value);


Acked-by: Ivan Hu <ivan.hu@canonical.com>
Colin Ian King Jan. 31, 2019, 9:15 a.m. UTC | #2
On 30/01/2019 20:38, Alex Hung wrote:
> This checks whether 1st (full) and 2nd (battery) levels are also in the
> brightness levels.
> 
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/method/method.c | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 654112d9..91156d1a 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -5460,6 +5460,7 @@ static void method_test_BCL_return(
>  	uint32_t i;
>  	bool failed = false;
>  	bool ascending_levels = false;
> +	bool matching_levels;
>  	char *str = NULL;
>  
>  	FWTS_UNUSED(private);
> @@ -5511,6 +5512,42 @@ static void method_test_BCL_return(
>  		failed = true;
>  	}
>  
> +	matching_levels = false;
> +	for (i = 2; i < obj->Package.Count; i++) {
> +		if (obj->Package.Elements[0].Integer.Value ==
> +		    obj->Package.Elements[i].Integer.Value) {
> +			matching_levels = true;
> +			break;
> +		}
> +	}
> +
> +	if (!matching_levels) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_BCLFullNotInList",
> +			"brightness level on full power (%" PRIu64
> +			") is not in brightness levels.",
> +			obj->Package.Elements[0].Integer.Value);
> +	}
> +
> +	matching_levels = false;
> +	for (i = 2; i < obj->Package.Count; i++) {
> +		if (obj->Package.Elements[1].Integer.Value ==
> +		    obj->Package.Elements[i].Integer.Value) {
> +			matching_levels = true;
> +			break;
> +		}
> +	}
> +
> +	if (!matching_levels) {
> +		failed = true;
> +		fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +			"Method_BCLBatteryNotInList",
> +			"brightness level on battery (%" PRIu64
> +			") is not in brightness levels.",
> +			obj->Package.Elements[1].Integer.Value);
> +	}
> +
>  	fwts_log_info(fw, "Brightness levels for %s:" ,name);
>  	fwts_log_info_verbatim(fw, "  Level on full power   : %" PRIu64,
>  		(uint64_t)obj->Package.Elements[0].Integer.Value);
> 
Looks good. Thanks Alex.

Acked-by: Colin Ian King <colin.king@canonical.com>
diff mbox series

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 654112d9..91156d1a 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -5460,6 +5460,7 @@  static void method_test_BCL_return(
 	uint32_t i;
 	bool failed = false;
 	bool ascending_levels = false;
+	bool matching_levels;
 	char *str = NULL;
 
 	FWTS_UNUSED(private);
@@ -5511,6 +5512,42 @@  static void method_test_BCL_return(
 		failed = true;
 	}
 
+	matching_levels = false;
+	for (i = 2; i < obj->Package.Count; i++) {
+		if (obj->Package.Elements[0].Integer.Value ==
+		    obj->Package.Elements[i].Integer.Value) {
+			matching_levels = true;
+			break;
+		}
+	}
+
+	if (!matching_levels) {
+		failed = true;
+		fwts_failed(fw, LOG_LEVEL_CRITICAL,
+			"Method_BCLFullNotInList",
+			"brightness level on full power (%" PRIu64
+			") is not in brightness levels.",
+			obj->Package.Elements[0].Integer.Value);
+	}
+
+	matching_levels = false;
+	for (i = 2; i < obj->Package.Count; i++) {
+		if (obj->Package.Elements[1].Integer.Value ==
+		    obj->Package.Elements[i].Integer.Value) {
+			matching_levels = true;
+			break;
+		}
+	}
+
+	if (!matching_levels) {
+		failed = true;
+		fwts_failed(fw, LOG_LEVEL_CRITICAL,
+			"Method_BCLBatteryNotInList",
+			"brightness level on battery (%" PRIu64
+			") is not in brightness levels.",
+			obj->Package.Elements[1].Integer.Value);
+	}
+
 	fwts_log_info(fw, "Brightness levels for %s:" ,name);
 	fwts_log_info_verbatim(fw, "  Level on full power   : %" PRIu64,
 		(uint64_t)obj->Package.Elements[0].Integer.Value);