From 92b30ba80001e13356ef7e5d87738fb226dddc40 Mon Sep 17 00:00:00 2001 From: Anastasia Klimchuk Date: Thu, 24 Jun 2021 16:25:43 +1000 Subject: 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/55818 Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- buspirate_spi.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'buspirate_spi.c') diff --git a/buspirate_spi.c b/buspirate_spi.c index bfd0e052..b56d422b 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; -- cgit v1.2.3