Anastasia Klimchuk has uploaded this change for review.

View Change

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>
---
M ene_lpc.c
1 file changed, 10 insertions(+), 15 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/85/52685/1
diff --git a/ene_lpc.c b/ene_lpc.c
index 560743c..11272d9 100644
--- a/ene_lpc.c
+++ b/ene_lpc.c
@@ -531,7 +531,6 @@
int ene_lpc_init()
{
uint8_t hwver, ediid, i;
- int ret = 0;
ene_lpc_data_t *ctx_data = NULL;

msg_pdbg("%s\n", __func__);
@@ -543,10 +542,8 @@
}
ctx_data->ec_state = EC_STATE_NORMAL;

- if (check_params()) {
- ret = 1;
- goto ene_probe_spi_flash_exit;
- }
+ if (check_params())
+ goto init_err_exit;

for (i = 0; i < ENE_LAST; ++i) {
ctx_data->chip = &ene_chips[i];
@@ -562,8 +559,7 @@

if (i == ENE_LAST) {
msg_pdbg("ENE EC not found (probe failed)\n");
- ret = 1;
- goto ene_probe_spi_flash_exit;
+ goto init_err_exit;
}

/* TODO: probe the EC stop protocol
@@ -576,17 +572,16 @@
internal_buses_supported |= BUS_LPC;
spi_master_ene.data = ctx_data;

- if (register_shutdown(ene_leave_flash_mode, ctx_data)) {
- ret = 1;
- goto ene_probe_spi_flash_exit;
- }
+ if (register_shutdown(ene_leave_flash_mode, ctx_data))
+ goto init_err_exit;
register_spi_master(&spi_master_ene);
msg_pdbg("%s: successfully initialized ene\n", __func__);

-ene_probe_spi_flash_exit:
- if (ret)
- free(ctx_data);
- return ret;
+ return 0;
+
+init_err_exit:
+ free(ctx_data);
+ return 1;
}

#endif /* __i386__ || __x86_64__ */

To view, visit change 52685. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Iac295f1353785cd73d7cb2f19e4a8cbb69beb576
Gerrit-Change-Number: 52685
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-MessageType: newchange