Anastasia Klimchuk has uploaded this change for review.
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.
BUG=b:185191942
TEST=builds
Change-Id: I31fd70f607dc965d5cac1cd0116faa447dbc177a
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M buspirate_spi.c
1 file changed, 5 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/18/55818/1
diff --git a/buspirate_spi.c b/buspirate_spi.c
index bfd0e05..b56d422 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -629,10 +629,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)))
@@ -655,10 +653,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;
@@ -668,10 +664,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;
@@ -685,10 +679,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;
@@ -698,10 +690,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;
To view, visit change 55818. To unsubscribe, or for help writing mail filters, visit settings.