From 7571044f9d5cad945310254b20d2eab4f732d605 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Mon, 28 Oct 2024 17:43:56 +0100 Subject: soc/amd/common/psp_smi_flash: factor out get_flash_device Since the RPMC-related functions will only need the spi_flash struct, but not the region_device struct of the store region corresponding to the 'target_nv_id', factor out 'get_flash_device' from 'find_psp_spi_flash_device_region'. Signed-off-by: Felix Held Change-Id: Ia99d3454df2c1c4182c193da7de1bbb4eef18313 Reviewed-on: https://review.coreboot.org/c/coreboot/+/84905 Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) Reviewed-by: Ana Carolina Cabral --- src/soc/amd/common/block/psp/psp_smi_flash.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/soc/amd/common') diff --git a/src/soc/amd/common/block/psp/psp_smi_flash.c b/src/soc/amd/common/block/psp/psp_smi_flash.c index d78db48ddc..ca595536c1 100644 --- a/src/soc/amd/common/block/psp/psp_smi_flash.c +++ b/src/soc/amd/common/block/psp/psp_smi_flash.c @@ -66,9 +66,7 @@ static int lookup_store(uint64_t target_nv_id, struct region_device *rstore) return rdev_chain(rstore, rdev, 0, region_device_sz(rdev)); } -static enum mbox_p2c_status find_psp_spi_flash_device_region(uint64_t target_nv_id, - struct region_device *store, - const struct spi_flash **flash) +static enum mbox_p2c_status get_flash_device(const struct spi_flash **flash) { *flash = boot_device_spi_flash(); if (*flash == NULL) { @@ -76,6 +74,16 @@ static enum mbox_p2c_status find_psp_spi_flash_device_region(uint64_t target_nv_ return MBOX_PSP_COMMAND_PROCESS_ERROR; } + return MBOX_PSP_SUCCESS; +} + +static enum mbox_p2c_status find_psp_spi_flash_device_region(uint64_t target_nv_id, + struct region_device *store, + const struct spi_flash **flash) +{ + if (get_flash_device(flash) != MBOX_PSP_SUCCESS) + return MBOX_PSP_COMMAND_PROCESS_ERROR; + if (lookup_store(target_nv_id, store) < 0) { printk(BIOS_ERR, "PSP: Unable to find PSP SPI region\n"); return MBOX_PSP_COMMAND_PROCESS_ERROR; -- cgit v1.2.3