mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 15:33:42 +02:00
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 <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/52596 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
914aa7e60e
commit
8baf98d2ea
41
mec1308.c
41
mec1308.c
@ -426,7 +426,6 @@ int mec1308_init(void)
|
|||||||
uint16_t sio_port;
|
uint16_t sio_port;
|
||||||
uint8_t device_id;
|
uint8_t device_id;
|
||||||
uint8_t tmp8;
|
uint8_t tmp8;
|
||||||
int ret = 0;
|
|
||||||
mec1308_data_t *ctx_data = NULL;
|
mec1308_data_t *ctx_data = NULL;
|
||||||
|
|
||||||
msg_pdbg("%s(): entered\n", __func__);
|
msg_pdbg("%s(): entered\n", __func__);
|
||||||
@ -437,15 +436,12 @@ int mec1308_init(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_params()) {
|
if (check_params())
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mec1308_get_sio_index(ctx_data, &sio_port) < 0) {
|
if (mec1308_get_sio_index(ctx_data, &sio_port) < 0) {
|
||||||
msg_pdbg("MEC1308 not found (probe failed).\n");
|
msg_pdbg("MEC1308 not found (probe failed).\n");
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
}
|
||||||
device_id = sio_read(sio_port, MEC1308_DEVICE_ID_REG);
|
device_id = sio_read(sio_port, MEC1308_DEVICE_ID_REG);
|
||||||
switch(device_id) {
|
switch(device_id) {
|
||||||
@ -461,8 +457,7 @@ int mec1308_init(void)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg_pdbg("MEC1308 not found\n");
|
msg_pdbg("MEC1308 not found\n");
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -486,28 +481,23 @@ int mec1308_init(void)
|
|||||||
* command to finish.*/
|
* command to finish.*/
|
||||||
if (mbx_wait(ctx_data) != 0) {
|
if (mbx_wait(ctx_data) != 0) {
|
||||||
msg_perr("%s: mailbox is not available\n", __func__);
|
msg_perr("%s: mailbox is not available\n", __func__);
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Further setup -- disable SMI and ACPI.
|
/* Further setup -- disable SMI and ACPI.
|
||||||
FIXME: is there an ordering dependency? */
|
FIXME: is there an ordering dependency? */
|
||||||
if (mbx_write(ctx_data, MEC1308_MBX_CMD, MEC1308_CMD_ACPI_DISABLE)) {
|
if (mbx_write(ctx_data, MEC1308_MBX_CMD, MEC1308_CMD_ACPI_DISABLE)) {
|
||||||
msg_pdbg("%s: unable to disable ACPI\n", __func__);
|
msg_pdbg("%s: unable to disable ACPI\n", __func__);
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mbx_write(ctx_data, MEC1308_MBX_CMD, MEC1308_CMD_SMI_DISABLE)) {
|
if (mbx_write(ctx_data, MEC1308_MBX_CMD, MEC1308_CMD_SMI_DISABLE)) {
|
||||||
msg_pdbg("%s: unable to disable SMI\n", __func__);
|
msg_pdbg("%s: unable to disable SMI\n", __func__);
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (register_shutdown(mec1308_shutdown, ctx_data)) {
|
if (register_shutdown(mec1308_shutdown, ctx_data))
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enter SPI Pass-Thru Mode after commands which do not require access
|
* 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);
|
mec1308_exit_passthru_mode(ctx_data);
|
||||||
|
|
||||||
if (enter_passthru_mode(ctx_data)) {
|
if (enter_passthru_mode(ctx_data))
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto mec1308_init_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal_buses_supported |= BUS_LPC; /* for LPC <--> SPI bridging */
|
internal_buses_supported |= BUS_LPC; /* for LPC <--> SPI bridging */
|
||||||
spi_master_mec1308.data = ctx_data;
|
spi_master_mec1308.data = ctx_data;
|
||||||
register_spi_master(&spi_master_mec1308);
|
register_spi_master(&spi_master_mec1308);
|
||||||
msg_pdbg("%s(): successfully initialized mec1308\n", __func__);
|
msg_pdbg("%s(): successfully initialized mec1308\n", __func__);
|
||||||
|
|
||||||
mec1308_init_exit:
|
return 0;
|
||||||
if (ret)
|
|
||||||
|
init_err_exit:
|
||||||
free(ctx_data);
|
free(ctx_data);
|
||||||
return ret;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user