diff mbox series

[1/2] acpi/method: remove duplicated code for returned integers

Message ID 20200506154537.335068-1-alex.hung@canonical.com
State Accepted
Headers show
Series [1/2] acpi/method: remove duplicated code for returned integers | expand

Commit Message

Alex Hung May 6, 2020, 3:45 p.m. UTC
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/acpi/method/method.c | 62 ++++------------------------------------
 1 file changed, 5 insertions(+), 57 deletions(-)

Comments

Colin Ian King May 6, 2020, 3:50 p.m. UTC | #1
On 06/05/2020 16:45, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/method/method.c | 62 ++++------------------------------------
>  1 file changed, 5 insertions(+), 57 deletions(-)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 68973847..b6e9d86d 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -3171,23 +3171,10 @@ static int method_test_ALP(fwts_framework *fw)
>  /*
>   * Section 9.4 Lid control
>   */
> -static void method_test_LID_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_INTEGER) == FWTS_OK)
> -		fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
> -}
> -
>  static int method_test_LID(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_MOBILE,
> -		"_LID", NULL, 0, method_test_LID_return, NULL);
> +		"_LID", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  
> @@ -3421,21 +3408,6 @@ static int method_test_GRT(fwts_framework *fw)
>  		"_GRT", NULL, 0, method_test_GRT_return, NULL);
>  }
>  
> -static void method_test_SRT_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_INTEGER) != FWTS_OK)
> -		return;
> -
> -	fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
> -}
> -
>  static int method_test_SRT(fwts_framework *fw)
>  {
>  	uint32_t time_size = sizeof(fwts_acpi_time_buffer);
> @@ -3455,7 +3427,7 @@ static int method_test_SRT(fwts_framework *fw)
>  	arg0.Buffer.Pointer = (void *)&real_time;
>  
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_SRT", &arg0, 1, method_test_SRT_return, NULL);
> +		"_SRT", &arg0, 1, fwts_method_test_integer_return, NULL);
>  }
>  
>  static void method_test_GWS_return(
> @@ -5167,27 +5139,16 @@ static int method_test_TSP(fwts_framework *fw)
>  		"_TSP", NULL, 0, fwts_method_test_polling_return, "_TSP");
>  }
>  
> -static void method_test_TCx_return(
> -	fwts_framework *fw,
> -	char *name,
> -	ACPI_BUFFER *buf,
> -	ACPI_OBJECT *obj,
> -	void *private)
> -{
> -	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK)
> -		fwts_method_passed_sane_uint64(fw, (char*)private, obj->Integer.Value);
> -}
> -
>  static int method_test_TC1(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_TC1", NULL, 0, method_test_TCx_return, "_TC1");
> +		"_TC1", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  static int method_test_TC2(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_TC2", NULL, 0, method_test_TCx_return, "_TC1");
> +		"_TC2", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  static int method_test_TFP(fwts_framework *fw)
> @@ -5271,23 +5232,10 @@ static int method_test_SCP(fwts_framework *fw)
>  	return FWTS_OK;
>  }
>  
> -static void method_test_RTV_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_INTEGER) == FWTS_OK)
> -		fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
> -}
> -
>  static int method_test_RTV(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_RTV", NULL, 0, method_test_RTV_return, "_RTV");
> +		"_RTV", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  static int method_test_TPT(fwts_framework *fw)
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Ivan Hu May 8, 2020, 7:55 a.m. UTC | #2
On 5/6/20 11:45 PM, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/method/method.c | 62 ++++------------------------------------
>  1 file changed, 5 insertions(+), 57 deletions(-)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 68973847..b6e9d86d 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -3171,23 +3171,10 @@ static int method_test_ALP(fwts_framework *fw)
>  /*
>   * Section 9.4 Lid control
>   */
> -static void method_test_LID_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_INTEGER) == FWTS_OK)
> -		fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
> -}
> -
>  static int method_test_LID(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_MOBILE,
> -		"_LID", NULL, 0, method_test_LID_return, NULL);
> +		"_LID", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  
> @@ -3421,21 +3408,6 @@ static int method_test_GRT(fwts_framework *fw)
>  		"_GRT", NULL, 0, method_test_GRT_return, NULL);
>  }
>  
> -static void method_test_SRT_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_INTEGER) != FWTS_OK)
> -		return;
> -
> -	fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
> -}
> -
>  static int method_test_SRT(fwts_framework *fw)
>  {
>  	uint32_t time_size = sizeof(fwts_acpi_time_buffer);
> @@ -3455,7 +3427,7 @@ static int method_test_SRT(fwts_framework *fw)
>  	arg0.Buffer.Pointer = (void *)&real_time;
>  
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_SRT", &arg0, 1, method_test_SRT_return, NULL);
> +		"_SRT", &arg0, 1, fwts_method_test_integer_return, NULL);
>  }
>  
>  static void method_test_GWS_return(
> @@ -5167,27 +5139,16 @@ static int method_test_TSP(fwts_framework *fw)
>  		"_TSP", NULL, 0, fwts_method_test_polling_return, "_TSP");
>  }
>  
> -static void method_test_TCx_return(
> -	fwts_framework *fw,
> -	char *name,
> -	ACPI_BUFFER *buf,
> -	ACPI_OBJECT *obj,
> -	void *private)
> -{
> -	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK)
> -		fwts_method_passed_sane_uint64(fw, (char*)private, obj->Integer.Value);
> -}
> -
>  static int method_test_TC1(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_TC1", NULL, 0, method_test_TCx_return, "_TC1");
> +		"_TC1", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  static int method_test_TC2(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_TC2", NULL, 0, method_test_TCx_return, "_TC1");
> +		"_TC2", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  static int method_test_TFP(fwts_framework *fw)
> @@ -5271,23 +5232,10 @@ static int method_test_SCP(fwts_framework *fw)
>  	return FWTS_OK;
>  }
>  
> -static void method_test_RTV_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_INTEGER) == FWTS_OK)
> -		fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
> -}
> -
>  static int method_test_RTV(fwts_framework *fw)
>  {
>  	return method_evaluate_method(fw, METHOD_OPTIONAL,
> -		"_RTV", NULL, 0, method_test_RTV_return, "_RTV");
> +		"_RTV", NULL, 0, fwts_method_test_integer_return, NULL);
>  }
>  
>  static int method_test_TPT(fwts_framework *fw)
> 

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

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 68973847..b6e9d86d 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -3171,23 +3171,10 @@  static int method_test_ALP(fwts_framework *fw)
 /*
  * Section 9.4 Lid control
  */
-static void method_test_LID_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_INTEGER) == FWTS_OK)
-		fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
-}
-
 static int method_test_LID(fwts_framework *fw)
 {
 	return method_evaluate_method(fw, METHOD_MOBILE,
-		"_LID", NULL, 0, method_test_LID_return, NULL);
+		"_LID", NULL, 0, fwts_method_test_integer_return, NULL);
 }
 
 
@@ -3421,21 +3408,6 @@  static int method_test_GRT(fwts_framework *fw)
 		"_GRT", NULL, 0, method_test_GRT_return, NULL);
 }
 
-static void method_test_SRT_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_INTEGER) != FWTS_OK)
-		return;
-
-	fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
-}
-
 static int method_test_SRT(fwts_framework *fw)
 {
 	uint32_t time_size = sizeof(fwts_acpi_time_buffer);
@@ -3455,7 +3427,7 @@  static int method_test_SRT(fwts_framework *fw)
 	arg0.Buffer.Pointer = (void *)&real_time;
 
 	return method_evaluate_method(fw, METHOD_OPTIONAL,
-		"_SRT", &arg0, 1, method_test_SRT_return, NULL);
+		"_SRT", &arg0, 1, fwts_method_test_integer_return, NULL);
 }
 
 static void method_test_GWS_return(
@@ -5167,27 +5139,16 @@  static int method_test_TSP(fwts_framework *fw)
 		"_TSP", NULL, 0, fwts_method_test_polling_return, "_TSP");
 }
 
-static void method_test_TCx_return(
-	fwts_framework *fw,
-	char *name,
-	ACPI_BUFFER *buf,
-	ACPI_OBJECT *obj,
-	void *private)
-{
-	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK)
-		fwts_method_passed_sane_uint64(fw, (char*)private, obj->Integer.Value);
-}
-
 static int method_test_TC1(fwts_framework *fw)
 {
 	return method_evaluate_method(fw, METHOD_OPTIONAL,
-		"_TC1", NULL, 0, method_test_TCx_return, "_TC1");
+		"_TC1", NULL, 0, fwts_method_test_integer_return, NULL);
 }
 
 static int method_test_TC2(fwts_framework *fw)
 {
 	return method_evaluate_method(fw, METHOD_OPTIONAL,
-		"_TC2", NULL, 0, method_test_TCx_return, "_TC1");
+		"_TC2", NULL, 0, fwts_method_test_integer_return, NULL);
 }
 
 static int method_test_TFP(fwts_framework *fw)
@@ -5271,23 +5232,10 @@  static int method_test_SCP(fwts_framework *fw)
 	return FWTS_OK;
 }
 
-static void method_test_RTV_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_INTEGER) == FWTS_OK)
-		fwts_method_passed_sane_uint64(fw, name, obj->Integer.Value);
-}
-
 static int method_test_RTV(fwts_framework *fw)
 {
 	return method_evaluate_method(fw, METHOD_OPTIONAL,
-		"_RTV", NULL, 0, method_test_RTV_return, "_RTV");
+		"_RTV", NULL, 0, fwts_method_test_integer_return, NULL);
 }
 
 static int method_test_TPT(fwts_framework *fw)