summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2018-06-14 06:57:05 +0300
committerPatrick Georgi <pgeorgi@google.com>2018-07-02 07:29:22 +0000
commit2fc1a37c04e0eb7f6db8d9d569205151041b16e6 (patch)
treecf17ee392ebf6f57cbd4e34e7bd5410452961790
parent108fb8a37e06603d4bebbd784f2c1955ebbb70f8 (diff)
downloadcoreboot-2fc1a37c04e0eb7f6db8d9d569205151041b16e6.tar.xz
soc/amd/common: Change create_struct return value
Old return value was not used, and function body has die() in case of errors in allocation. Change-Id: I89b0e9c927d395ac6d27201e0b3a8658e9585187 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/27261 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Garrett Kirkendall <garrett.kirkendall@amd.corp-partner.google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rw-r--r--src/soc/amd/common/block/pi/agesawrapper.c58
1 files changed, 17 insertions, 41 deletions
diff --git a/src/soc/amd/common/block/pi/agesawrapper.c b/src/soc/amd/common/block/pi/agesawrapper.c
index 6fe8e578df..c2a799a0cc 100644
--- a/src/soc/amd/common/block/pi/agesawrapper.c
+++ b/src/soc/amd/common/block/pi/agesawrapper.c
@@ -74,23 +74,23 @@ static AGESA_STATUS agesawrapper_readeventlog(UINT8 HeapStatus)
return Status;
}
-static AGESA_STATUS create_struct(AMD_INTERFACE_PARAMS *interface_struct)
+static void *create_struct(AMD_INTERFACE_PARAMS *interface_struct)
{
/* Should clone entire StdHeader here. */
interface_struct->StdHeader.CalloutPtr = &GetBiosCallout;
AGESA_STATUS status = AmdCreateStruct(interface_struct);
- if (status == AGESA_SUCCESS)
- return status;
- printk(BIOS_ERR, "Error: AmdCreateStruct() for 0x%x returned 0x%x. "
- "Proper system initialization may not be possible.\n",
- interface_struct->AgesaFunctionName, status);
+ if (status != AGESA_SUCCESS) {
+ printk(BIOS_ERR, "Error: AmdCreateStruct() for 0x%x returned 0x%x. "
+ "Proper system initialization may not be possible.\n",
+ interface_struct->AgesaFunctionName, status);
+ }
if (!interface_struct->NewStructPtr) /* Avoid NULL pointer usage */
die("No AGESA structure created");
- return status;
+ return interface_struct->NewStructPtr;
}
AGESA_STATUS agesawrapper_amdinitreset(void)
@@ -103,11 +103,9 @@ AGESA_STATUS agesawrapper_amdinitreset(void)
.NewStructSize = sizeof(AMD_RESET_PARAMS),
.NewStructPtr = &_ResetParams,
};
- AMD_RESET_PARAMS *ResetParams;
- create_struct(&AmdParamStruct);
+ AMD_RESET_PARAMS *ResetParams = create_struct(&AmdParamStruct);
- ResetParams = (AMD_RESET_PARAMS *)AmdParamStruct.NewStructPtr;
SetFchResetParams(&ResetParams->FchInterface);
timestamp_add_now(TS_AGESA_INIT_RESET_START);
@@ -123,15 +121,13 @@ AGESA_STATUS agesawrapper_amdinitreset(void)
AGESA_STATUS agesawrapper_amdinitearly(void)
{
AGESA_STATUS status;
- AMD_EARLY_PARAMS *EarlyParams;
AMD_INTERFACE_PARAMS AmdParamStruct = {
.AgesaFunctionName = AMD_INIT_EARLY,
.AllocationMethod = PreMemHeap,
};
- create_struct(&AmdParamStruct);
+ AMD_EARLY_PARAMS *EarlyParams = create_struct(&AmdParamStruct);
- EarlyParams = (AMD_EARLY_PARAMS *)AmdParamStruct.NewStructPtr;
OemCustomizeInitEarly(EarlyParams);
EarlyParams->GnbConfig.PsppPolicy = PsppDisabled;
@@ -187,11 +183,9 @@ AGESA_STATUS agesawrapper_amdinitpost(void)
.AgesaFunctionName = AMD_INIT_POST,
.AllocationMethod = PreMemHeap,
};
- AMD_POST_PARAMS *PostParams;
- create_struct(&AmdParamStruct);
+ AMD_POST_PARAMS *PostParams = create_struct(&AmdParamStruct);
- PostParams = (AMD_POST_PARAMS *)AmdParamStruct.NewStructPtr;
PostParams->MemConfig.UmaMode = CONFIG_GFXUMA ? UMA_AUTO : UMA_NONE;
PostParams->MemConfig.UmaSize = 0;
PostParams->MemConfig.BottomIo = (UINT16)
@@ -244,11 +238,9 @@ AGESA_STATUS agesawrapper_amdinitenv(void)
.AgesaFunctionName = AMD_INIT_ENV,
.AllocationMethod = PostMemDram,
};
- AMD_ENV_PARAMS *EnvParams;
- status = create_struct(&AmdParamStruct);
+ AMD_ENV_PARAMS *EnvParams = create_struct(&AmdParamStruct);
- EnvParams = (AMD_ENV_PARAMS *)AmdParamStruct.NewStructPtr;
SetFchEnvParams(&EnvParams->FchInterface);
SetNbEnvParams(&EnvParams->GnbEnvConfiguration);
@@ -296,14 +288,12 @@ AGESA_STATUS agesawrapper_amdinitmid(void)
.AgesaFunctionName = AMD_INIT_MID,
.AllocationMethod = PostMemDram,
};
- AMD_MID_PARAMS *MidParams;
/* Enable MMIO on AMD CPU Address Map Controller */
amd_initcpuio();
- create_struct(&AmdParamStruct);
+ AMD_MID_PARAMS *MidParams = create_struct(&AmdParamStruct);
- MidParams = (AMD_MID_PARAMS *)AmdParamStruct.NewStructPtr;
SetFchMidParams(&MidParams->FchInterface);
SetNbMidParams(&MidParams->GnbMidConfiguration);
@@ -325,14 +315,12 @@ AGESA_STATUS agesawrapper_amdinitlate(void)
.AgesaFunctionName = AMD_INIT_LATE,
.AllocationMethod = PostMemDram,
};
- AMD_LATE_PARAMS *LateParams;
/*
* NOTE: if not call amdcreatestruct, the initializer
* (AmdInitLateInitializer) would not be called.
*/
- create_struct(&AmdParamStruct);
- LateParams = (AMD_LATE_PARAMS *)AmdParamStruct.NewStructPtr;
+ AMD_LATE_PARAMS *LateParams = create_struct(&AmdParamStruct);
timestamp_add_now(TS_AGESA_INIT_LATE_START);
Status = AmdInitLate(LateParams);
@@ -394,11 +382,8 @@ AGESA_STATUS agesawrapper_amdinitrtb(void)
.AgesaFunctionName = AMD_INIT_RTB,
.AllocationMethod = PostMemDram,
};
- AMD_RTB_PARAMS *RtbParams;
-
- create_struct(&AmdParamStruct);
- RtbParams = (AMD_RTB_PARAMS *)AmdParamStruct.NewStructPtr;
+ AMD_RTB_PARAMS *RtbParams = create_struct(&AmdParamStruct);
timestamp_add_now(TS_AGESA_INIT_RTB_START);
Status = AmdInitRtb(RtbParams);
@@ -427,15 +412,12 @@ AGESA_STATUS agesawrapper_amdinitresume(void)
.AgesaFunctionName = AMD_INIT_RESUME,
.AllocationMethod = PreMemHeap,
};
- AMD_RESUME_PARAMS *InitResumeParams;
size_t nv_size;
if (!acpi_s3_resume_allowed())
return AGESA_UNSUPPORTED;
- create_struct(&AmdParamStruct);
-
- InitResumeParams = (AMD_RESUME_PARAMS *)AmdParamStruct.NewStructPtr;
+ AMD_RESUME_PARAMS *InitResumeParams = create_struct(&AmdParamStruct);
get_s3nv_info(&InitResumeParams->S3DataBlock.NvStorage, &nv_size);
InitResumeParams->S3DataBlock.NvStorageSize = nv_size;
@@ -461,7 +443,6 @@ AGESA_STATUS agesawrapper_amds3laterestore(void)
.NewStructSize = sizeof(AMD_S3LATE_PARAMS),
.NewStructPtr = &_S3LateParams,
};
- AMD_S3LATE_PARAMS *S3LateParams;
size_t vol_size;
if (!acpi_s3_resume_allowed())
@@ -469,9 +450,7 @@ AGESA_STATUS agesawrapper_amds3laterestore(void)
amd_initcpuio();
- create_struct(&AmdParamStruct);
-
- S3LateParams = (AMD_S3LATE_PARAMS *)AmdParamStruct.NewStructPtr;
+ AMD_S3LATE_PARAMS *S3LateParams = create_struct(&AmdParamStruct);
get_s3vol_info(&S3LateParams->S3DataBlock.VolatileStorage, &vol_size);
S3LateParams->S3DataBlock.VolatileStorageSize = vol_size;
@@ -499,15 +478,12 @@ AGESA_STATUS agesawrapper_amds3finalrestore(void)
.NewStructSize = sizeof(AMD_S3FINAL_PARAMS),
.NewStructPtr = &_S3FinalParams,
};
- AMD_S3FINAL_PARAMS *S3FinalParams;
size_t vol_size;
if (!acpi_s3_resume_allowed())
return AGESA_UNSUPPORTED;
- create_struct(&AmdParamStruct);
-
- S3FinalParams = (AMD_S3FINAL_PARAMS *)AmdParamStruct.NewStructPtr;
+ AMD_S3FINAL_PARAMS *S3FinalParams = create_struct(&AmdParamStruct);
get_s3vol_info(&S3FinalParams->S3DataBlock.VolatileStorage, &vol_size);
S3FinalParams->S3DataBlock.VolatileStorageSize = vol_size;