summaryrefslogtreecommitdiffstats
path: root/buspirate_spi.c
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2021-06-24 16:25:43 +1000
committerAngel Pons <th3fanbus@gmail.com>2021-06-30 08:11:18 +0000
commit92b30ba80001e13356ef7e5d87738fb226dddc40 (patch)
tree1d7b9e6e359453b7b703f3750bcbbee96aada325 /buspirate_spi.c
parent16419f424ea87329783e14723057939a205a51c0 (diff)
downloadflashrom-92b30ba80001e13356ef7e5d87738fb226dddc40.tar.gz
flashrom-92b30ba80001e13356ef7e5d87738fb226dddc40.tar.bz2
flashrom-92b30ba80001e13356ef7e5d87738fb226dddc40.zip
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. BUG=b:185191942 TEST=builds Change-Id: I31fd70f607dc965d5cac1cd0116faa447dbc177a Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55818 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'buspirate_spi.c')
-rw-r--r--buspirate_spi.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/buspirate_spi.c b/buspirate_spi.c
index bfd0e0523..b56d422bd 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -629,10 +629,8 @@ static int buspirate_spi_init(void)
/* 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 @@ static int buspirate_spi_init(void)
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 @@ static int buspirate_spi_init(void)
/* 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 @@ static int buspirate_spi_init(void)
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 @@ static int buspirate_spi_init(void)
/* 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;