diff mbox

acpi: method: refine _AEI control method

Message ID 1438346162-25293-1-git-send-email-alex.hung@canonical.com
State Accepted
Headers show

Commit Message

Alex Hung July 31, 2015, 12:36 p.m. UTC
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/acpi/method/method.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

Comments

Colin Ian King July 31, 2015, 12:54 p.m. UTC | #1
On 31/07/15 13:36, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/method/method.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index d0b98e6..638e937 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -906,10 +906,56 @@ static int method_package_elements_type(
>  /*
>   * Section 5.6 ACPI Event Programming Model
>   */
> +static void method_test_AEI_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	ACPI_STATUS status;
> +	ACPI_RESOURCE *resource;
> +	ACPI_RESOURCE_GPIO* gpio;
> +	bool failed = false;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
> +		return;
> +
> +	status = AcpiBufferToResource(obj->Buffer.Pointer, obj->Buffer.Length, &resource);
> +	if (ACPI_FAILURE(status))
> +		return;
> +
> +	do {
> +		if (resource->Type == ACPI_RESOURCE_TYPE_GPIO) {
> +			gpio = &resource->Data.Gpio;
> +			if (gpio->ConnectionType != ACPI_RESOURCE_GPIO_TYPE_INT) {
> +				failed = true;
> +				fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +					"Method_AEIBadGpioElement",
> +					"%s should contain only GPIO Connection Type 0, got %" PRIu32,
> +					name, gpio->ConnectionType);
> +			}
> +		} else {
> +			failed = true;
> +			fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +				"Method_AEIBadElement",
> +				"%s should contain only Resource Type 17, got%" PRIu32,
> +					name, resource->Type);
> +		}
> +
> +		resource = ACPI_NEXT_RESOURCE(resource);
> +	} while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG);
> +
> +	if (!failed)
> +		method_passed_sane(fw, name, "buffer");
> +}
> +
>  static int method_test_AEI(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_AEI", NULL, 0, method_test_buffer_return, NULL);
> +		"_AEI", NULL, 0, method_test_AEI_return, NULL);
>  }
>  
>  static int method_test_EVT(fwts_framework *fw)
> 
Thanks Alex,

Acked-by: Colin Ian King <colin.king@canonical.com>
Ivan Hu Aug. 3, 2015, 3:57 a.m. UTC | #2
On 2015年07月31日 20:36, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>   src/acpi/method/method.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index d0b98e6..638e937 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -906,10 +906,56 @@ static int method_package_elements_type(
>   /*
>    * Section 5.6 ACPI Event Programming Model
>    */
> +static void method_test_AEI_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	ACPI_STATUS status;
> +	ACPI_RESOURCE *resource;
> +	ACPI_RESOURCE_GPIO* gpio;
> +	bool failed = false;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
> +		return;
> +
> +	status = AcpiBufferToResource(obj->Buffer.Pointer, obj->Buffer.Length, &resource);
> +	if (ACPI_FAILURE(status))
> +		return;
> +
> +	do {
> +		if (resource->Type == ACPI_RESOURCE_TYPE_GPIO) {
> +			gpio = &resource->Data.Gpio;
> +			if (gpio->ConnectionType != ACPI_RESOURCE_GPIO_TYPE_INT) {
> +				failed = true;
> +				fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +					"Method_AEIBadGpioElement",
> +					"%s should contain only GPIO Connection Type 0, got %" PRIu32,
> +					name, gpio->ConnectionType);
> +			}
> +		} else {
> +			failed = true;
> +			fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +				"Method_AEIBadElement",
> +				"%s should contain only Resource Type 17, got%" PRIu32,
> +					name, resource->Type);
> +		}
> +
> +		resource = ACPI_NEXT_RESOURCE(resource);
> +	} while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG);
> +
> +	if (!failed)
> +		method_passed_sane(fw, name, "buffer");
> +}
> +
>   static int method_test_AEI(fwts_framework *fw)
>   {
>   	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_AEI", NULL, 0, method_test_buffer_return, NULL);
> +		"_AEI", NULL, 0, method_test_AEI_return, NULL);
>   }
>   
>   static int method_test_EVT(fwts_framework *fw)

Acked-by: Ivan Hu<ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index d0b98e6..638e937 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -906,10 +906,56 @@  static int method_package_elements_type(
 /*
  * Section 5.6 ACPI Event Programming Model
  */
+static void method_test_AEI_return(
+	fwts_framework *fw,
+	char *name,
+	ACPI_BUFFER *buf,
+	ACPI_OBJECT *obj,
+	void *private)
+{
+	ACPI_STATUS status;
+	ACPI_RESOURCE *resource;
+	ACPI_RESOURCE_GPIO* gpio;
+	bool failed = false;
+
+	FWTS_UNUSED(private);
+
+	if (method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK)
+		return;
+
+	status = AcpiBufferToResource(obj->Buffer.Pointer, obj->Buffer.Length, &resource);
+	if (ACPI_FAILURE(status))
+		return;
+
+	do {
+		if (resource->Type == ACPI_RESOURCE_TYPE_GPIO) {
+			gpio = &resource->Data.Gpio;
+			if (gpio->ConnectionType != ACPI_RESOURCE_GPIO_TYPE_INT) {
+				failed = true;
+				fwts_failed(fw, LOG_LEVEL_MEDIUM,
+					"Method_AEIBadGpioElement",
+					"%s should contain only GPIO Connection Type 0, got %" PRIu32,
+					name, gpio->ConnectionType);
+			}
+		} else {
+			failed = true;
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				"Method_AEIBadElement",
+				"%s should contain only Resource Type 17, got%" PRIu32,
+					name, resource->Type);
+		}
+
+		resource = ACPI_NEXT_RESOURCE(resource);
+	} while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG);
+
+	if (!failed)
+		method_passed_sane(fw, name, "buffer");
+}
+
 static int method_test_AEI(fwts_framework *fw)
 {
 	return method_evaluate_method(fw, METHOD_OPTIONAL,
-		"_AEI", NULL, 0, method_test_buffer_return, NULL);
+		"_AEI", NULL, 0, method_test_AEI_return, NULL);
 }
 
 static int method_test_EVT(fwts_framework *fw)