[PATCH][V2] fwts_acpi_object_eval: add a function to check package
Colin Ian King
colin.king at canonical.com
Tue May 26 17:13:02 UTC 2020
On 26/05/2020 18:09, Alex Hung wrote:
>
>
> On Tue, May 26, 2020 at 9:55 AM Colin Ian King <colin.king at canonical.com
> <mailto:colin.king at canonical.com>> wrote:
>
> On 25/05/2020 09:22, Alex Hung wrote:
> > This function checks if all elements are integers in a returned
> package.
> > This is one of common forms returned by ACPI methods.
> >
> > Signed-off-by: Alex Hung <alex.hung at canonical.com
> <mailto:alex.hung at canonical.com>>
> > ---
> > src/lib/include/fwts_acpi_object_eval.h | 1 +
> > src/lib/src/fwts_acpi_object_eval.c | 29
> +++++++++++++++++++++++++
> > 2 files changed, 30 insertions(+)
> >
> > diff --git a/src/lib/include/fwts_acpi_object_eval.h
> b/src/lib/include/fwts_acpi_object_eval.h
> > index 09f3f754..92177857 100644
> > --- a/src/lib/include/fwts_acpi_object_eval.h
> > +++ b/src/lib/include/fwts_acpi_object_eval.h
> > @@ -128,6 +128,7 @@ void
> fwts_method_test_buffer_return(fwts_framework *fw, char *name,
> ACPI_BUFFER
> > void fwts_method_test_all_reference_package_return(fwts_framework
> *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > void fwts_method_test_integer_reserved_bits_return(fwts_framework
> *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > void fwts_method_test_integer_max_return(fwts_framework *fw, char
> *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > +void fwts_method_test_package_integer_return(fwts_framework *fw,
> char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > void fwts_method_test_passed_failed_return(fwts_framework *fw,
> char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > void fwts_method_test_polling_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 1e3575c9..f8d22eb4 100644
> > --- a/src/lib/src/fwts_acpi_object_eval.c
> > +++ b/src/lib/src/fwts_acpi_object_eval.c
> > @@ -881,6 +881,35 @@ void fwts_method_test_integer_max_return(
> > fwts_passed(fw, "%s correctly returned an integer.",
> name);
> > }
> >
> > +/*
> > + * fwts_method_test_package_integer_return
> > + * check if all integers in a returned package
> > + */
> > +void fwts_method_test_package_integer_return(
> > + fwts_framework *fw,
> > + char *name,
> > + ACPI_BUFFER *buf,
> > + ACPI_OBJECT *obj,
> > + void *private)
> > +{
> > + char method[5];
> > + uint32_t *element_size = (uint32_t *) private;
> > +
> > + memcpy(method, &name[strlen(name) - 4], 4);
> > + method[4] = '\0';
>
> I don't understand the memcpy, surely memcpy(method, name, 4) is fine?
>
>
> Only the device name is needed. For example, wWhen name =
> _SB.PCI0.LPCB.ABCD, only the ABCD is wanted.
Ah, OK. Just a sanity check question, but will there be any occasion
where the suffix part of the name (e.g. ABCD) or the whole string itself
is less than 4 chars as I don't want to index off the front of a short
string.
Also, name + strlen(name) - 4 is probably easier to comprehend than
&name[strlen(name() - 4] :-)
Colin
>
>
>
>
> > +
> > + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE)
> != FWTS_OK)
> > + return;
> > +
> > + if (fwts_method_package_count_equal(fw, name, method, obj,
> *element_size) != FWTS_OK)
> > + return;
> > +
> > + if (fwts_method_package_elements_all_type(fw, name, method,
> obj, ACPI_TYPE_INTEGER) != FWTS_OK)
> > + return;
> > +
> > + fwts_method_passed_sane(fw, name, "package");
> > +}
> > +
> > /*
> > * fwts_method_test_passed_failed_return
> > * check if 0 or 1 (false/true) integer is returned
> >
>
>
>
> --
> Cheers,
> Alex Hung
More information about the fwts-devel
mailing list