From 8baf98d2ea48ee633e81ea990af81bbec82c7a02 Mon Sep 17 00:00:00 2001 From: Anastasia Klimchuk Date: Mon, 26 Apr 2021 15:10:34 +1000 Subject: mec1308.c: Untangle successful vs failed init paths Label mec1308_init_exit now serves as failed init path, it does cleanup and returns 1, so it is renamed into init_err_exit. Since all error paths return 1, and successful init is separated from failure, there is no need to have ret variable anymore. TEST=builds and ninja test from 51487 BUG=b:185191942 Change-Id: Ibf35335501e59636c544af124ad7a04a186790b4 Signed-off-by: Anastasia Klimchuk Reviewed-on: https://review.coreboot.org/c/flashrom/+/52596 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- mec1308.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'mec1308.c') diff --git a/mec1308.c b/mec1308.c index 682e7a96..641f5f8f 100644 --- a/mec1308.c +++ b/mec1308.c @@ -426,7 +426,6 @@ int mec1308_init(void) uint16_t sio_port; uint8_t device_id; uint8_t tmp8; - int ret = 0; mec1308_data_t *ctx_data = NULL; msg_pdbg("%s(): entered\n", __func__); @@ -437,15 +436,12 @@ int mec1308_init(void) return 1; } - if (check_params()) { - ret = 1; - goto mec1308_init_exit; - } + if (check_params()) + goto init_err_exit; if (mec1308_get_sio_index(ctx_data, &sio_port) < 0) { msg_pdbg("MEC1308 not found (probe failed).\n"); - ret = 1; - goto mec1308_init_exit; + goto init_err_exit; } device_id = sio_read(sio_port, MEC1308_DEVICE_ID_REG); switch(device_id) { @@ -461,8 +457,7 @@ int mec1308_init(void) break; default: msg_pdbg("MEC1308 not found\n"); - ret = 1; - goto mec1308_init_exit; + goto init_err_exit; } /* @@ -486,28 +481,23 @@ int mec1308_init(void) * command to finish.*/ if (mbx_wait(ctx_data) != 0) { msg_perr("%s: mailbox is not available\n", __func__); - ret = 1; - goto mec1308_init_exit; + goto init_err_exit; } /* Further setup -- disable SMI and ACPI. FIXME: is there an ordering dependency? */ if (mbx_write(ctx_data, MEC1308_MBX_CMD, MEC1308_CMD_ACPI_DISABLE)) { msg_pdbg("%s: unable to disable ACPI\n", __func__); - ret = 1; - goto mec1308_init_exit; + goto init_err_exit; } if (mbx_write(ctx_data, MEC1308_MBX_CMD, MEC1308_CMD_SMI_DISABLE)) { msg_pdbg("%s: unable to disable SMI\n", __func__); - ret = 1; - goto mec1308_init_exit; + goto init_err_exit; } - if (register_shutdown(mec1308_shutdown, ctx_data)) { - ret = 1; - goto mec1308_init_exit; - } + if (register_shutdown(mec1308_shutdown, ctx_data)) + goto init_err_exit; /* * Enter SPI Pass-Thru Mode after commands which do not require access @@ -516,19 +506,18 @@ int mec1308_init(void) */ mec1308_exit_passthru_mode(ctx_data); - if (enter_passthru_mode(ctx_data)) { - ret = 1; - goto mec1308_init_exit; - } + if (enter_passthru_mode(ctx_data)) + goto init_err_exit; internal_buses_supported |= BUS_LPC; /* for LPC <--> SPI bridging */ spi_master_mec1308.data = ctx_data; register_spi_master(&spi_master_mec1308); msg_pdbg("%s(): successfully initialized mec1308\n", __func__); -mec1308_init_exit: - if (ret) - free(ctx_data); - return ret; + return 0; + +init_err_exit: + free(ctx_data); + return 1; } #endif -- cgit v1.2.3