From 50cbb933a312c4fd57b8f3bdf6fc938e4179f2f0 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 23 Jun 2023 18:49:26 +0200 Subject: [PATCH] soc/amd/common/block/acpi/ivrs: use memset on ivhd_[11,40] Assign the current address casted to acpi_ivrs_ivhd[11,40]_t pointer to *ivhd_[11,40] at the beginning of acpi_fill_ivrs[11,40] and then use memset on *ivhd_[11,40] to zero-initialize the structs. Signed-off-by: Felix Held Change-Id: I70b12fee99d6c71318189ac35e615589a4c8c629 Reviewed-on: https://review.coreboot.org/c/coreboot/+/76077 Reviewed-by: Fred Reitberger Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/acpi/ivrs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/soc/amd/common/block/acpi/ivrs.c b/src/soc/amd/common/block/acpi/ivrs.c index d2080e9f36..d5a409f2eb 100644 --- a/src/soc/amd/common/block/acpi/ivrs.c +++ b/src/soc/amd/common/block/acpi/ivrs.c @@ -200,11 +200,10 @@ static unsigned long acpi_ivhd_misc(unsigned long current, struct device *dev) static unsigned long acpi_fill_ivrs40(unsigned long current, acpi_ivrs_ivhd_t *ivhd, struct device *nb_dev, struct device *iommu_dev) { - acpi_ivrs_ivhd40_t *ivhd_40; + acpi_ivrs_ivhd40_t *ivhd_40 = (acpi_ivrs_ivhd40_t *)current; unsigned long current_backup; - memset((void *)current, 0, sizeof(acpi_ivrs_ivhd40_t)); - ivhd_40 = (acpi_ivrs_ivhd40_t *)current; + memset(ivhd_40, 0, sizeof(acpi_ivrs_ivhd40_t)); /* Enable EFR */ ivhd_40->type = IVHD_BLOCK_TYPE_FULL__ACPI_HID; @@ -253,7 +252,7 @@ static unsigned long acpi_fill_ivrs40(unsigned long current, acpi_ivrs_ivhd_t *i static unsigned long acpi_fill_ivrs11(unsigned long current, acpi_ivrs_ivhd_t *ivhd, struct device *nb_dev, struct device *iommu_dev) { - acpi_ivrs_ivhd11_t *ivhd_11; + acpi_ivrs_ivhd11_t *ivhd_11 = (acpi_ivrs_ivhd11_t *)current; ivhd11_iommu_attr_t *ivhd11_attr_ptr; unsigned long current_backup; @@ -261,8 +260,7 @@ static unsigned long acpi_fill_ivrs11(unsigned long current, acpi_ivrs_ivhd_t *i * In order to utilize all features, firmware should expose type 11h * IVHD which supersedes the type 10h. */ - memset((void *)current, 0, sizeof(acpi_ivrs_ivhd11_t)); - ivhd_11 = (acpi_ivrs_ivhd11_t *)current; + memset(ivhd_11, 0, sizeof(acpi_ivrs_ivhd11_t)); /* Enable EFR */ ivhd_11->type = IVHD_BLOCK_TYPE_FULL__FIXED;