ACK: [PATCH] acpi: refactor method_test_BMD to a common function

ivanhu ivan.hu at canonical.com
Fri May 22 03:08:14 UTC 2020



On 5/16/20 2:03 AM, Alex Hung wrote:
> New function "fwts_method_test_BMD_return" also checks status flags and
> capability flags in the returned package.
> 
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>  src/acpi/devices/battery/battery.c      | 23 +------------------
>  src/acpi/method/method.c                | 25 +--------------------
>  src/lib/include/fwts_acpi_object_eval.h |  1 +
>  src/lib/src/fwts_acpi_object_eval.c     | 30 +++++++++++++++++++++++++
>  4 files changed, 33 insertions(+), 46 deletions(-)
> 
> diff --git a/src/acpi/devices/battery/battery.c b/src/acpi/devices/battery/battery.c
> index 72d8e377..400f485b 100644
> --- a/src/acpi/devices/battery/battery.c
> +++ b/src/acpi/devices/battery/battery.c
> @@ -653,31 +653,10 @@ static int method_test_BCT(fwts_framework *fw)
>  		"_BCT", arg, 1, fwts_method_test_integer_return, NULL);
>  }
>  
> -static void method_test_BMD_return(
> -	fwts_framework *fw,
> -	char *name,
> -	ACPI_BUFFER *buf,
> -	ACPI_OBJECT *obj,
> -	void *private)
> -{
> -	FWTS_UNUSED(private);
> -
> -	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)
> -		return;
> -
> -	if (fwts_method_package_elements_all_type(fw, name, "_BMD", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
> -		return;
> -
> -	fwts_method_passed_sane(fw, name, "package");
> -}
> -
>  static int method_test_BMD(fwts_framework *fw)
>  {
>  	return fwts_evaluate_method(fw, METHOD_OPTIONAL, &device,
> -		"_BMD", NULL, 0, method_test_BMD_return, NULL);
> +		"_BMD", NULL, 0, fwts_method_test_BMD_return, NULL);
>  }
>  
>  static int method_test_BMC(fwts_framework *fw)
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 76ce8a81..7ab72ba7 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -4218,33 +4218,10 @@ static int method_test_BTM(fwts_framework *fw)
>  	return FWTS_OK;
>  }
>  
> -static void method_test_BMD_return(
> -	fwts_framework *fw,
> -	char *name,
> -	ACPI_BUFFER *buf,
> -	ACPI_OBJECT *obj,
> -	void *private)
> -{
> -	FWTS_UNUSED(private);
> -
> -	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)
> -		return;
> -
> -	if (fwts_method_package_elements_all_type(fw, name, "_BMD", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
> -		return;
> -
> -	fwts_acpi_object_dump(fw, obj);
> -
> -	fwts_method_passed_sane(fw, name, "package");
> -}
> -
>  static int method_test_BMD(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_MOBILE,
> -		"_BMD", NULL, 0, method_test_BMD_return, NULL);
> +		"_BMD", NULL, 0, fwts_method_test_BMD_return, NULL);
>  }
>  
>  static int method_test_BMC(fwts_framework *fw)
> diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h
> index 080a0d65..b13b5239 100644
> --- a/src/lib/include/fwts_acpi_object_eval.h
> +++ b/src/lib/include/fwts_acpi_object_eval.h
> @@ -156,6 +156,7 @@ int fwts_method_test_SUN(fwts_framework *fw, ACPI_HANDLE *device);
>  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_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 42b97d26..12165b53 100644
> --- a/src/lib/src/fwts_acpi_object_eval.c
> +++ b/src/lib/src/fwts_acpi_object_eval.c
> @@ -2255,4 +2255,34 @@ int fwts_method_test_UID(fwts_framework *fw, ACPI_HANDLE *device)
>  		"_UID", NULL, 0, fwts_method_test_UID_return, NULL);
>  }
>  
> +void fwts_method_test_BMD_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	bool failed = false;
> +
> +	FWTS_UNUSED(private);
> +
> +	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)
> +		return;
> +
> +	if (fwts_method_package_elements_all_type(fw, name, "_BMD", obj, ACPI_TYPE_INTEGER) != FWTS_OK)
> +		return;
> +
> +	fwts_acpi_reserved_bits_check(fw, "_BMD", "Status Flags",
> +		obj->Package.Elements[0].Integer.Value, sizeof(uint32_t), 5, 31, &failed);
> +
> +	fwts_acpi_reserved_bits_check(fw, "_BMD", "Capability Flags",
> +		obj->Package.Elements[1].Integer.Value, sizeof(uint32_t), 5, 31, &failed);
> +
> +	if (!failed)
> +		fwts_method_passed_sane(fw, name, "package");
> +}
> +
>  #endif
> 
Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list