ACK: [PATCH] acpi: shorten fwts_method_package_elements_type args by a macro
ivanhu
ivan.hu at canonical.com
Mon Jan 18 07:04:12 UTC 2021
On 1/15/21 8:03 AM, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
> src/acpi/devices/ac_adapter/ac.c | 2 +-
> src/acpi/devices/battery/battery.c | 6 +++---
> src/acpi/method/method.c | 18 +++++++++---------
> src/lib/include/fwts_acpi_object_eval.h | 5 ++++-
> src/lib/src/fwts_acpi_object_eval.c | 4 ++--
> 5 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/src/acpi/devices/ac_adapter/ac.c b/src/acpi/devices/ac_adapter/ac.c
> index b29edd00..244a221b 100644
> --- a/src/acpi/devices/ac_adapter/ac.c
> +++ b/src/acpi/devices/ac_adapter/ac.c
> @@ -152,7 +152,7 @@ static void method_test_PIF_return(
> if (fwts_method_package_count_equal(fw, name, "_PIF", obj, 6) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_PIF", obj, elements, 6) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_PIF", obj, elements) != FWTS_OK)
> return;
>
> fwts_acpi_object_dump(fw, obj);
> diff --git a/src/acpi/devices/battery/battery.c b/src/acpi/devices/battery/battery.c
> index cd402176..ec250de8 100644
> --- a/src/acpi/devices/battery/battery.c
> +++ b/src/acpi/devices/battery/battery.c
> @@ -110,7 +110,7 @@ static void method_test_BIF_return(
> if (fwts_method_package_count_equal(fw, name, "_BIF", obj, 13) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_BIF", obj, elements, 13) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_BIF", obj, elements) != FWTS_OK)
> return;
>
> /* Sanity check each field */
> @@ -288,14 +288,14 @@ static void method_test_BIX_return(
> if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 20) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements, 20) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements) != FWTS_OK)
> return;
> break;
> case 1:
> if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 21) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements_v1, 21) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements_v1) != FWTS_OK)
> return;
> break;
> default:
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index a6a06338..6addf7c9 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -1817,7 +1817,7 @@ static void method_test_CPC_return(
> return;
>
> /* For now, just check types */
> - if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv1, 17) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv1) != FWTS_OK)
> return;
> } else if (revision == 2) { // acpi 5.1 ~ acpi 6.1a
> /* Something is really wrong if we don't have any elements in _CPC */
> @@ -1825,14 +1825,14 @@ static void method_test_CPC_return(
> return;
>
> /* For now, just check types */
> - if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv2, 21) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv2) != FWTS_OK)
> return;
> } else if (revision == 3) { // acpi 6.2 and later
> if (fwts_method_package_count_equal(fw, name, "_CPC", obj, 23) != FWTS_OK)
> return;
>
> /* For now, just check types */
> - if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv3, 23) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_CPC", obj, elementsv3) != FWTS_OK)
> return;
> } else {
> fwts_failed(fw, LOG_LEVEL_HIGH,
> @@ -2892,7 +2892,7 @@ static void method_test_PUR_return(
> if (fwts_method_package_count_equal(fw, name, "_PUR", obj, 2) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_PUR", obj, elements, 2) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_PUR", obj, elements) != FWTS_OK)
> return;
>
> /* RevisionID */
> @@ -3480,7 +3480,7 @@ static void method_test_BIF_return(
> if (fwts_method_package_count_equal(fw, name, "_BIF", obj, 13) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_BIF", obj, elements, 13) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_BIF", obj, elements) != FWTS_OK)
> return;
>
> /* Sanity check each field */
> @@ -3649,14 +3649,14 @@ static void method_test_BIX_return(
> if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 20) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements, 20) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements) != FWTS_OK)
> return;
> break;
> case 1:
> if (fwts_method_package_count_equal(fw, name, "_BIX", obj, 21) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements_v1, 21) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_BIX", obj, elements_v1) != FWTS_OK)
> return;
> break;
> default:
> @@ -3995,7 +3995,7 @@ static void method_test_PIF_return(
> if (fwts_method_package_count_equal(fw, name, "_PIF", obj, 6) != FWTS_OK)
> return;
>
> - if (fwts_method_package_elements_type(fw, name, "_PIF", obj, elements, 6) != FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_PIF", obj, elements) != FWTS_OK)
> return;
>
> fwts_acpi_object_dump(fw, obj);
> @@ -4687,7 +4687,7 @@ static void method_test_GPE_return(
> name, (uint64_t)obj->Integer.Value);
> break;
> case ACPI_TYPE_PACKAGE:
> - if (fwts_method_package_elements_type(fw, name, "_GPE", obj, elem, FWTS_ARRAY_SIZE(elem)) == FWTS_OK)
> + if (fwts_method_package_elements_type(fw, name, "_GPE", obj, elem) == FWTS_OK)
> fwts_method_passed_sane(fw, name, "package");
>
> break;
> diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h
> index 472f91a1..fcfe8646 100644
> --- a/src/lib/include/fwts_acpi_object_eval.h
> +++ b/src/lib/include/fwts_acpi_object_eval.h
> @@ -109,6 +109,9 @@ typedef struct {
> #define fwts_method_check_type(fw, name, buf, type) \
> fwts_method_check_type__(fw, name, buf, type, #type)
>
> +#define fwts_method_package_elements_type(fw, name, objname, obj, info) \
> + fwts_method_package_elements_type__(fw, name, objname, obj, info, FWTS_ARRAY_SIZE(info))
> +
> int fwts_method_check_type__(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT_TYPE type, char *type_name);
> int fwts_method_check_element_type(fwts_framework *fw, char *name, ACPI_OBJECT *obj, uint32_t subpkg, uint32_t element, ACPI_OBJECT_TYPE type);
> const char *fwts_method_type_name(const ACPI_OBJECT_TYPE type);
> @@ -121,7 +124,7 @@ int fwts_method_package_count_min(fwts_framework *fw, const char *name, const ch
> int fwts_method_package_count_equal(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const uint32_t count);
> int fwts_method_subpackage_count_equal(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const uint32_t sub, const uint32_t count);
> int fwts_method_package_elements_all_type(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const ACPI_OBJECT_TYPE type);
> -int fwts_method_package_elements_type(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const fwts_package_element *info, const uint32_t count);
> +int fwts_method_package_elements_type__(fwts_framework *fw, const char *name, const char *objname, const ACPI_OBJECT *obj, const fwts_package_element *info, const uint32_t count);
> int fwts_method_test_revision(fwts_framework *fw, const char *name, const uint32_t cur_revision, const uint32_t spec_revision);
>
> void fwts_method_test_integer_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 258cca64..40d73511 100644
> --- a/src/lib/src/fwts_acpi_object_eval.c
> +++ b/src/lib/src/fwts_acpi_object_eval.c
> @@ -779,11 +779,11 @@ int fwts_method_package_elements_all_type(
> }
>
> /*
> - * fwts_method_package_elements_type()
> + * fwts_method_package_elements_type__()
> * sanity check fields in a package that all have
> * the same type
> */
> -int fwts_method_package_elements_type(
> +int fwts_method_package_elements_type__(
> fwts_framework *fw,
> const char *name,
> const char *objname,
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list