From d832bda32bd54b65c41db4ae945fb6a993ca055b Mon Sep 17 00:00:00 2001 From: Felix Held Date: Thu, 15 Dec 2022 15:26:28 +0100 Subject: soc/amd/common/block/i2c: don't call die() when MMIO address is NULL There's no need to call die() in the case that the MMIO address of the I2C controller is NULL, so handle this case by returning a failure instead. Signed-off-by: Felix Held Change-Id: I12c143916ad551c56cc4ff75ae23754018817505 Reviewed-on: https://review.coreboot.org/c/coreboot/+/70827 Tested-by: build bot (Jenkins) Reviewed-by: Fred Reitberger Reviewed-by: Martin Roth Reviewed-by: Matt DeVillier Reviewed-by: Eric Lai --- src/soc/amd/common/block/i2c/i2c.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/soc/amd/common/block') diff --git a/src/soc/amd/common/block/i2c/i2c.c b/src/soc/amd/common/block/i2c/i2c.c index 30e02ee07d..617b8b7e10 100644 --- a/src/soc/amd/common/block/i2c/i2c.c +++ b/src/soc/amd/common/block/i2c/i2c.c @@ -49,8 +49,10 @@ static const char *i2c_acpi_name(const struct device *dev) size_t num_ctrlrs; const struct soc_i2c_ctrlr_info *ctrlr = soc_get_i2c_ctrlr_info(&num_ctrlrs); - if (!(uintptr_t)dev->path.mmio.addr) - die("NULL MMIO address at %s\n", __func__); + if (!(uintptr_t)dev->path.mmio.addr) { + printk(BIOS_ERR, "NULL MMIO address at %s\n", __func__); + return NULL; + } for (i = 0; i < num_ctrlrs; i++) { if ((uintptr_t)dev->path.mmio.addr == ctrlr[i].bar) @@ -66,8 +68,10 @@ int dw_i2c_soc_dev_to_bus(const struct device *dev) size_t num_ctrlrs; const struct soc_i2c_ctrlr_info *ctrlr = soc_get_i2c_ctrlr_info(&num_ctrlrs); - if (!(uintptr_t)dev->path.mmio.addr) - die("NULL MMIO address at %s\n", __func__); + if (!(uintptr_t)dev->path.mmio.addr) { + printk(BIOS_ERR, "NULL MMIO address at %s\n", __func__); + return -1; + } for (i = 0; i < num_ctrlrs; i++) { if ((uintptr_t)dev->path.mmio.addr == ctrlr[i].bar) -- cgit v1.2.3