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;