Alexander Goncharov has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/72156 )
Change subject: ni845x_spi: handle errors using goto during initialization ......................................................................
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 --- M ni845x_spi.c 1 file changed, 23 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/56/72156/1
diff --git a/ni845x_spi.c b/ni845x_spi.c index 493e8a1..0a5c46d 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -614,22 +614,24 @@ 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) < 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 = {