summaryrefslogtreecommitdiffstats
path: root/buspirate_spi.c
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2022-08-18 23:57:31 +0200
committerAnastasia Klimchuk <aklm@chromium.org>2022-09-08 02:00:16 +0000
commit27be9edd46d2d30ad16ebe0e689249365a8e9628 (patch)
tree903b3c4c2f7e8da4a46f62f3fdc69dd8d4312d5a /buspirate_spi.c
parentc0fdc9d108ff59e13ce6b9751f60c22aed153161 (diff)
downloadflashrom-27be9edd46d2d30ad16ebe0e689249365a8e9628.tar.gz
flashrom-27be9edd46d2d30ad16ebe0e689249365a8e9628.tar.bz2
flashrom-27be9edd46d2d30ad16ebe0e689249365a8e9628.zip
buspirate_spi.c: Retype appropriate variables with bool
Use the bool type instead of integer for appropriate variables, since this represents their purpose much better. Signed-off-by: Felix Singer <felixsinger@posteo.net> Change-Id: I245616168796f2c7fe99388688b0f606bd3405bf Reviewed-on: https://review.coreboot.org/c/flashrom/+/66868 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'buspirate_spi.c')
-rw-r--r--buspirate_spi.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/buspirate_spi.c b/buspirate_spi.c
index 8fa60f65c..0704887f3 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <strings.h>
#include <string.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
@@ -327,8 +328,8 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
int spispeed = 0x7;
int serialspeed_index = -1;
int ret = 0;
- int pullup = 0;
- int psu = 0;
+ bool pullup = false;
+ bool psu = false;
unsigned char *bp_commbuf;
int bp_commbufsize;
@@ -372,7 +373,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
tmp = extract_programmer_param_str(cfg, "pullups");
if (tmp) {
if (strcasecmp("on", tmp) == 0)
- pullup = 1;
+ pullup = true;
else if (strcasecmp("off", tmp) == 0)
; // ignore
else
@@ -383,7 +384,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
tmp = extract_programmer_param_str(cfg, "psus");
if (tmp) {
if (strcasecmp("on", tmp) == 0)
- psu = 1;
+ psu = true;
else if (strcasecmp("off", tmp) == 0)
; // ignore
else
@@ -646,11 +647,11 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
/* Initial setup (SPI peripherals config): Enable power, CS high, AUX */
bp_commbuf[0] = 0x40 | 0x0b;
- if (pullup == 1) {
+ if (pullup) {
bp_commbuf[0] |= (1 << 2);
msg_pdbg("Enabling pull-up resistors.\n");
}
- if (psu == 1) {
+ if (psu) {
bp_commbuf[0] |= (1 << 3);
msg_pdbg("Enabling PSUs.\n");
}
@@ -676,7 +677,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
/* Set SPI config: output type, idle, clock edge, sample */
bp_commbuf[0] = 0x80 | 0xa;
- if (pullup == 1) {
+ if (pullup) {
bp_commbuf[0] &= ~(1 << 3);
msg_pdbg("Pull-ups enabled, so using HiZ pin output! (Open-Drain mode)\n");
}