acpi/acpigen: factor out acpigen_write_processor_namestring
commitb57b12f729947c83515b96e45885b69d73027d79
authorFelix Held <felix-coreboot@felixheld.de>
Tue, 24 Jan 2023 18:31:00 +0000 (24 19:31 +0100)
committerFelix Held <felix-coreboot@felixheld.de>
Sat, 28 Jan 2023 18:50:10 +0000 (28 18:50 +0000)
tree7a51066bdaf0142f4c60277f45e7f8da588c7a3a
parent2fc2758e51d844b6759759b2d6931717ab9f7ca2
acpi/acpigen: factor out acpigen_write_processor_namestring

This functionality is used in multiple places, so factor it out into a
function. Compared to acpigen_write_processor_cnot, the buffer size is
decreased from 40 to 16 bytes, but the format string specified by
CONFIG_ACPI_CPU_STRING results in 9 chars and a NULL byte which will fit
into the buffer without any issue. I've seen the CPU devices being put
into another scope within \_SB, but even in that case that would be 14
chars and a NULL byte whist still fits into the 16 byte buffer. For
acpigen_write_processor and acpigen_write_processor_package this doesn't
change any edge case behavior. In the unrealistic case of the format
string resulting in a longer CPU device string, this would have been a
problem before this patch too.

Also drop the curly braces of the for loop in
acpigen_write_processor_package. This makes the code a bit harder to
read and isn't a very good idea, but with the curly braces in place, the
linter breaks the build :(

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I5d8291a2aaae2011cb185d72c7f7864b6e2220ec
Reviewed-on: https://review.coreboot.org/c/coreboot/+/72452
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
src/acpi/acpigen.c
src/include/acpi/acpigen.h