Patchwork acpi: method: print out BCL brightness levels rather than dump the object

login
register
mail settings
Submitter Colin King
Date Feb. 19, 2013, 10:55 a.m.
Message ID <1361271334-522-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/221662/
State Accepted
Headers show

Comments

Colin King - Feb. 19, 2013, 10:55 a.m.
From: Colin Ian King <colin.king@canonical.com>

Instead of doing an object dump of the _BCL return package we should
print out the brightness levels in a easier to understand formatted
form.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/method/method.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
Alex Hung - Feb. 20, 2013, 1:50 a.m.
On 02/19/2013 06:55 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Instead of doing an object dump of the _BCL return package we should
> print out the brightness levels in a easier to understand formatted
> form.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/method/method.c | 21 +++++++++++++++++++--
>   1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 09aef38..906ebc0 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -4560,6 +4560,7 @@ static void method_test_BCL_return(
>   	uint32_t i;
>   	bool failed = false;
>   	bool ascending_levels = false;
> +	char *str = NULL;
>
>   	FWTS_UNUSED(private);
>
> @@ -4572,8 +4573,6 @@ static void method_test_BCL_return(
>   	if (method_package_elements_all_type(fw, name, "_BCL", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
>   		return;
>
> -	fwts_acpi_object_dump(fw, obj);
> -
>   	if (obj->Package.Elements[0].Integer.Value <
>   	    obj->Package.Elements[1].Integer.Value) {
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> @@ -4614,6 +4613,24 @@ static void method_test_BCL_return(
>   		failed = true;
>   	}
>
> +	fwts_log_info(fw, "Brightness levels for %s:" ,name);
> +	fwts_log_info_verbatum(fw, "  Level on full power   : %" PRIu64, obj->Package.Elements[0].Integer.Value);
> +	fwts_log_info_verbatum(fw, "  Level on battery power: %" PRIu64, obj->Package.Elements[1].Integer.Value);
> +	for (i = 2; i < obj->Package.Count; i++) {
> +		char tmp[12];
> +
> +		snprintf(tmp, sizeof(tmp), "%s%" PRIu64,
> +			i == 2 ? "" : ", ",
> +			obj->Package.Elements[i].Integer.Value);
> +		str = fwts_realloc_strcat(str, tmp);
> +		if (!str)
> +			break;
> +	}
> +	if (str) {
> +		fwts_log_info_verbatum(fw, "  Brightness Levels     : %s", str);
> +		free(str);
> +	}
> +
>   	if (failed)
>   		fwts_advice(fw,
>   			"%s seems to be "
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Feb. 20, 2013, 5:47 a.m.
On Tue, Feb 19, 2013 at 6:55 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Instead of doing an object dump of the _BCL return package we should
> print out the brightness levels in a easier to understand formatted
> form.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/method/method.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 09aef38..906ebc0 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -4560,6 +4560,7 @@ static void method_test_BCL_return(
>         uint32_t i;
>         bool failed = false;
>         bool ascending_levels = false;
> +       char *str = NULL;
>
>         FWTS_UNUSED(private);
>
> @@ -4572,8 +4573,6 @@ static void method_test_BCL_return(
>         if (method_package_elements_all_type(fw, name, "_BCL", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
>                 return;
>
> -       fwts_acpi_object_dump(fw, obj);
> -
>         if (obj->Package.Elements[0].Integer.Value <
>             obj->Package.Elements[1].Integer.Value) {
>                 fwts_failed(fw, LOG_LEVEL_MEDIUM,
> @@ -4614,6 +4613,24 @@ static void method_test_BCL_return(
>                 failed = true;
>         }
>
> +       fwts_log_info(fw, "Brightness levels for %s:" ,name);
> +       fwts_log_info_verbatum(fw, "  Level on full power   : %" PRIu64, obj->Package.Elements[0].Integer.Value);
> +       fwts_log_info_verbatum(fw, "  Level on battery power: %" PRIu64, obj->Package.Elements[1].Integer.Value);
> +       for (i = 2; i < obj->Package.Count; i++) {
> +               char tmp[12];
> +
> +               snprintf(tmp, sizeof(tmp), "%s%" PRIu64,
> +                       i == 2 ? "" : ", ",
> +                       obj->Package.Elements[i].Integer.Value);
> +               str = fwts_realloc_strcat(str, tmp);
> +               if (!str)
> +                       break;
> +       }
> +       if (str) {
> +               fwts_log_info_verbatum(fw, "  Brightness Levels     : %s", str);
> +               free(str);
> +       }
> +
>         if (failed)
>                 fwts_advice(fw,
>                         "%s seems to be "
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 09aef38..906ebc0 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -4560,6 +4560,7 @@  static void method_test_BCL_return(
 	uint32_t i;
 	bool failed = false;
 	bool ascending_levels = false;
+	char *str = NULL;
 
 	FWTS_UNUSED(private);
 
@@ -4572,8 +4573,6 @@  static void method_test_BCL_return(
 	if (method_package_elements_all_type(fw, name, "_BCL", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
 		return;
 
-	fwts_acpi_object_dump(fw, obj);
-
 	if (obj->Package.Elements[0].Integer.Value <
 	    obj->Package.Elements[1].Integer.Value) {
 		fwts_failed(fw, LOG_LEVEL_MEDIUM,
@@ -4614,6 +4613,24 @@  static void method_test_BCL_return(
 		failed = true;
 	}
 
+	fwts_log_info(fw, "Brightness levels for %s:" ,name);
+	fwts_log_info_verbatum(fw, "  Level on full power   : %" PRIu64, obj->Package.Elements[0].Integer.Value);
+	fwts_log_info_verbatum(fw, "  Level on battery power: %" PRIu64, obj->Package.Elements[1].Integer.Value);
+	for (i = 2; i < obj->Package.Count; i++) {
+		char tmp[12];
+
+		snprintf(tmp, sizeof(tmp), "%s%" PRIu64,
+			i == 2 ? "" : ", ",
+			obj->Package.Elements[i].Integer.Value);
+		str = fwts_realloc_strcat(str, tmp);
+		if (!str)
+			break;
+	}
+	if (str) {
+		fwts_log_info_verbatum(fw, "  Brightness Levels     : %s", str);
+		free(str);
+	}
+
 	if (failed)
 		fwts_advice(fw,
 			"%s seems to be "