mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-29 07:53:44 +02:00
ene_lpc.c: Untangle successful vs failed init paths
Exit label 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. BUG=b:185191942 TEST=builds Change-Id: Iac295f1353785cd73d7cb2f19e4a8cbb69beb576 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/52685 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
02350a6fcc
commit
4cc7363d25
29
ene_lpc.c
29
ene_lpc.c
@ -529,7 +529,6 @@ static int check_params(void)
|
|||||||
int ene_lpc_init()
|
int ene_lpc_init()
|
||||||
{
|
{
|
||||||
uint8_t hwver, ediid, i;
|
uint8_t hwver, ediid, i;
|
||||||
int ret = 0;
|
|
||||||
ene_lpc_data_t *ctx_data = NULL;
|
ene_lpc_data_t *ctx_data = NULL;
|
||||||
|
|
||||||
msg_pdbg("%s\n", __func__);
|
msg_pdbg("%s\n", __func__);
|
||||||
@ -541,10 +540,8 @@ int ene_lpc_init()
|
|||||||
}
|
}
|
||||||
ctx_data->ec_state = EC_STATE_NORMAL;
|
ctx_data->ec_state = EC_STATE_NORMAL;
|
||||||
|
|
||||||
if (check_params()) {
|
if (check_params())
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto ene_probe_spi_flash_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ENE_LAST; ++i) {
|
for (i = 0; i < ENE_LAST; ++i) {
|
||||||
ctx_data->chip = &ene_chips[i];
|
ctx_data->chip = &ene_chips[i];
|
||||||
@ -560,8 +557,7 @@ int ene_lpc_init()
|
|||||||
|
|
||||||
if (i == ENE_LAST) {
|
if (i == ENE_LAST) {
|
||||||
msg_pdbg("ENE EC not found (probe failed)\n");
|
msg_pdbg("ENE EC not found (probe failed)\n");
|
||||||
ret = 1;
|
goto init_err_exit;
|
||||||
goto ene_probe_spi_flash_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: probe the EC stop protocol
|
/* TODO: probe the EC stop protocol
|
||||||
@ -574,17 +570,20 @@ int ene_lpc_init()
|
|||||||
internal_buses_supported |= BUS_LPC;
|
internal_buses_supported |= BUS_LPC;
|
||||||
spi_master_ene.data = ctx_data;
|
spi_master_ene.data = ctx_data;
|
||||||
|
|
||||||
if (register_shutdown(ene_leave_flash_mode, ctx_data)) {
|
if (register_shutdown(ene_leave_flash_mode, ctx_data))
|
||||||
ret = 1;
|
goto init_err_cleanup_exit;
|
||||||
goto ene_probe_spi_flash_exit;
|
|
||||||
}
|
|
||||||
register_spi_master(&spi_master_ene);
|
register_spi_master(&spi_master_ene);
|
||||||
msg_pdbg("%s: successfully initialized ene\n", __func__);
|
msg_pdbg("%s: successfully initialized ene\n", __func__);
|
||||||
|
|
||||||
ene_probe_spi_flash_exit:
|
return 0;
|
||||||
if (ret)
|
|
||||||
free(ctx_data);
|
init_err_cleanup_exit:
|
||||||
return ret;
|
ene_leave_flash_mode(ctx_data);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
init_err_exit:
|
||||||
|
free(ctx_data);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __i386__ || __x86_64__ */
|
#endif /* __i386__ || __x86_64__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user