buspirate_spi: Use non-zero return value from buspirate_sendrecv
Return values for buspirate_sendrecv come from serialport_write
and serialport_read, and those return 1s for any error. No need
to explicity assign ret = 1, because it is already 1 for error.
Follow up on commit 751afa88a7f22487069665c5d206ae490f158231
where this idea was suggested.
Change-Id: I31fd70f607dc965d5cac1cd0116faa447dbc177a
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/55818
Original-Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71397
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/buspirate_spi.c b/buspirate_spi.c
index 39b9c52..e7c2b29 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -518,10 +518,8 @@
/* Enter raw SPI mode */
bp_commbuf[0] = 0x01;
ret = buspirate_sendrecv(bp_commbuf, 1, 0);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if ((ret = buspirate_wait_for_string(bp_commbuf, "SPI")))
goto init_err_cleanup_exit;
if ((ret = buspirate_sendrecv(bp_commbuf, 0, 1)))
@@ -544,10 +542,8 @@
msg_pdbg("Enabling PSUs.\n");
}
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while setting power/CS/AUX(/Pull-up resistors)!\n");
ret = 1;
@@ -557,10 +553,8 @@
/* Set SPI speed */
bp_commbuf[0] = 0x60 | spispeed;
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while setting SPI speed!\n");
ret = 1;
@@ -574,10 +568,8 @@
msg_pdbg("Pull-ups enabled, so using HiZ pin output! (Open-Drain mode)\n");
}
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while setting SPI config!\n");
ret = 1;
@@ -587,10 +579,8 @@
/* De-assert CS# */
bp_commbuf[0] = 0x03;
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while raising CS#!\n");
ret = 1;