From 0b654bb92e273e4facdca1c561556ef5e57c3513 Mon Sep 17 00:00:00 2001 From: Alexander Goncharov Date: Sun, 7 Aug 2022 12:08:49 +0300 Subject: [PATCH] nicintel_eeprom: handle errors using goto for i210's shutdown This patch prepares the programmer to move global singleton states into a struct. TOPIC=register_master_api TEST=builds Change-Id: Idb4f75fa92966a0fffd83dd0e297f5f51f6c0bd3 Signed-off-by: Alexander Goncharov Ticket: https://ticket.coreboot.org/issues/391 Reviewed-on: https://review.coreboot.org/c/flashrom/+/66491 Tested-by: build bot (Jenkins) Reviewed-by: Thomas Heijligen Reviewed-by: Felix Singer Reviewed-by: Anastasia Klimchuk Reviewed-by: Angel Pons Reviewed-by: Nico Huber --- nicintel_eeprom.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index 42e6a7bb5..6827d9a28 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -397,8 +397,10 @@ static int nicintel_ee_erase_82580(struct flashctx *flash, unsigned int addr, un static int nicintel_ee_shutdown_i210(void *arg) { + int ret = 0; + if (!done_i20_write) - return 0; + goto out; uint32_t flup = pci_mmio_readl(nicintel_eebar + EEC); @@ -408,11 +410,13 @@ static int nicintel_ee_shutdown_i210(void *arg) int i; for (i = 0; i < MAX_ATTEMPTS; i++) if (pci_mmio_readl(nicintel_eebar + EEC) & BIT(EE_FLUDONE)) - return 0; + goto out; + ret = -1; msg_perr("Flash update failed\n"); - return -1; +out: + return ret; } static int nicintel_ee_shutdown_82580(void *eecp)