x86/acpi: simplify updating header checksum

Use acpi_update_checksum() for updating ACPI table header checksum.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
This commit is contained in:
Heinrich Schuchardt 2025-03-22 00:21:18 +01:00 committed by Tom Rini
parent bbc78592b1
commit e0055ac9bb
3 changed files with 6 additions and 9 deletions

View file

@ -298,7 +298,7 @@ static int apl_acpi_hb_write_tables(const struct udevice *dev,
/* (Re)calculate length and checksum */ /* (Re)calculate length and checksum */
header->length = ctx->current - (void *)dmar; header->length = ctx->current - (void *)dmar;
header->checksum = table_compute_checksum((void *)dmar, header->length); acpi_update_checksum(header);
acpi_align(ctx); acpi_align(ctx);
acpi_add_table(ctx, dmar); acpi_add_table(ctx, dmar);

View file

@ -414,7 +414,7 @@ int nhlt_serialise_oem_overrides(struct acpi_ctx *ctx, struct nhlt *nhlt,
cur.start = (void *)header; cur.start = (void *)header;
nhlt_serialise_endpoints(nhlt, &cur); nhlt_serialise_endpoints(nhlt, &cur);
header->checksum = table_compute_checksum(header, sz); acpi_update_checksum(header);
nhlt_free_resources(nhlt); nhlt_free_resources(nhlt);
assert(cur.buf - cur.start == sz); assert(cur.buf - cur.start == sz);

View file

@ -173,7 +173,7 @@ int acpi_write_tcpa(struct acpi_ctx *ctx, const struct acpi_writer *entry)
/* (Re)calculate length and checksum */ /* (Re)calculate length and checksum */
current = (u32)tcpa + sizeof(struct acpi_tcpa); current = (u32)tcpa + sizeof(struct acpi_tcpa);
header->length = current - (u32)tcpa; header->length = current - (u32)tcpa;
header->checksum = table_compute_checksum(tcpa, header->length); acpi_update_checksum(header);
acpi_inc(ctx, tcpa->header.length); acpi_inc(ctx, tcpa->header.length);
acpi_add_table(ctx, tcpa); acpi_add_table(ctx, tcpa);
@ -242,7 +242,7 @@ static int acpi_write_tpm2(struct acpi_ctx *ctx,
tpm2->lasa = nomap_to_sysmem(lasa); tpm2->lasa = nomap_to_sysmem(lasa);
/* Calculate checksum. */ /* Calculate checksum. */
header->checksum = table_compute_checksum(tpm2, header->length); acpi_update_checksum(header);
acpi_inc(ctx, tpm2->header.length); acpi_inc(ctx, tpm2->header.length);
acpi_add_table(ctx, tpm2); acpi_add_table(ctx, tpm2);
@ -279,9 +279,7 @@ int acpi_write_gnvs(struct acpi_ctx *ctx, const struct acpi_writer *entry)
* patched the GNVS address. Set the checksum to zero since it * patched the GNVS address. Set the checksum to zero since it
* is part of the region being checksummed. * is part of the region being checksummed.
*/ */
ctx->dsdt->checksum = 0; acpi_update_checksum(ctx->dsdt);
ctx->dsdt->checksum = table_compute_checksum((void *)ctx->dsdt,
ctx->dsdt->length);
} }
/* Fill in platform-specific global NVS variables */ /* Fill in platform-specific global NVS variables */
@ -330,8 +328,7 @@ static int acpi_create_hpet(struct acpi_hpet *hpet)
hpet->number = 0; hpet->number = 0;
hpet->min_tick = 0; /* HPET_MIN_TICKS */ hpet->min_tick = 0; /* HPET_MIN_TICKS */
header->checksum = table_compute_checksum(hpet, acpi_update_checksum(header);
sizeof(struct acpi_hpet));
return 0; return 0;
} }