diff options
author | Alexander Goncharov <chat@joursoir.net> | 2023-01-20 14:21:08 +0400 |
---|---|---|
committer | Anastasia Klimchuk <aklm@chromium.org> | 2023-07-19 02:22:44 +0000 |
commit | 0f0f952740022e48cf2b98de6604566fce6eff6f (patch) | |
tree | e57ed3a692c55e0811d02acac1e9483b9668806a | |
parent | 51335a8eb9ffe095df0400dbc99ee4928a70baf5 (diff) | |
download | flashrom-0f0f952740022e48cf2b98de6604566fce6eff6f.tar.gz flashrom-0f0f952740022e48cf2b98de6604566fce6eff6f.tar.bz2 flashrom-0f0f952740022e48cf2b98de6604566fce6eff6f.zip |
ni845x_spi: handle errors using goto during initialization
This patch prepares the programmer to move global singleton states
into a struct.
TOPIC=register_master_api
Change-Id: Ie9620d59db229729fd8523f99b0917d938bcc4ed
Signed-off-by: Alexander Goncharov <chat@joursoir.net>
Ticket: https://ticket.coreboot.org/issues/391
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72156
Reviewed-by: Miklós Márton <martonmiklosqdev@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
-rw-r--r-- | ni845x_spi.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ni845x_spi.c b/ni845x_spi.c index cb6b22ea7..58a8ef4ec 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -622,22 +622,24 @@ static int ni845x_spi_init(const struct programmer_cfg *cfg) tmp = ni845xSpiConfigurationOpen(&configuration_handle); if (tmp != 0) { ni845x_report_error("ni845xSpiConfigurationOpen", tmp); - ni845x_spi_shutdown(NULL); - return 1; + goto err; } if (usb8452_spi_set_io_voltage(requested_io_voltage_mV, &io_voltage_in_mV, USE_LOWER, device_pid, device_handle) < 0) { - ni845x_spi_shutdown(NULL); - return 1; // no alert here usb8452_spi_set_io_voltage already printed that + // no alert here usb8452_spi_set_io_voltage already printed that + goto err; } if (ni845x_spi_set_speed(configuration_handle, spi_speed_KHz)) { msg_perr("Unable to set SPI speed\n"); - ni845x_spi_shutdown(NULL); - return 1; + goto err; } return register_spi_master(&spi_programmer_ni845x, NULL); + +err: + ni845x_spi_shutdown(NULL); + return 1; } const struct programmer_entry programmer_ni845x_spi = { |