diff --git a/mec1308.c b/mec1308.c index 682e7a96e..641f5f8fc 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