[PATCH v3 12/29] dm: core: Add basic ACPI support

Simon Glass
2020-04-08T02:57:24Z

Hi Andy,

On Fri, 3 Apr 2020 at 05:35, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Mon, Mar 30, 2020 at 05:12:48PM -0600, Simon Glass wrote:
> > ACPI (Advanced Configuration and Power Interface) is a standard for
> > specifying information about a platform. It is a little like device
> > tree but the bindings are part of the specification and it supports an
> > interpreted bytecode language.
> >
> > Driver model does not use ACPI for U-Boot's configuration, but it is
> > convenient to have it support generation of ACPI tables for passing to
> > Linux, etc.
> >
> > As a starting point, add an optional set of ACPI operations to each
> > device. Initially only a single operation is available, to obtain the
> > ACPI name for the device. More operations are added later.
> >
> > Enable ACPI for sandbox to ensure build coverage and so that we can add
> > tests.
>
>
> ...
>
> > +int acpi_copy_name(char *out_name, const char *name)
> > +{
>
> > + strncpy(out_name, name, ACPI_NAME_MAX);
>
> memcpy()?

strcpy() seems better since it doesn't rely on the correct string in name.

> > + out_name[ACPI_NAME_LEN] = '\0';
>
> I dunno if compiler is clever enough to catch this and avoid any warnings.

I don't see any warnings.

> Also it seems above should also have _LEN, and not _MAX.

Do you mean for the strncpy()? I could do that but I still want to set
the terminator to nul so that the string is definitely terminated.

Regards,
Simon