1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

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>
This commit is contained in:
Felix Singer 2022-08-18 23:57:31 +02:00 committed by Anastasia Klimchuk
parent c0fdc9d108
commit 27be9edd46

View File

@ -16,6 +16,7 @@
#include <stdio.h> #include <stdio.h>
#include <strings.h> #include <strings.h>
#include <string.h> #include <string.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
@ -327,8 +328,8 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
int spispeed = 0x7; int spispeed = 0x7;
int serialspeed_index = -1; int serialspeed_index = -1;
int ret = 0; int ret = 0;
int pullup = 0; bool pullup = false;
int psu = 0; bool psu = false;
unsigned char *bp_commbuf; unsigned char *bp_commbuf;
int bp_commbufsize; int bp_commbufsize;
@ -372,7 +373,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
tmp = extract_programmer_param_str(cfg, "pullups"); tmp = extract_programmer_param_str(cfg, "pullups");
if (tmp) { if (tmp) {
if (strcasecmp("on", tmp) == 0) if (strcasecmp("on", tmp) == 0)
pullup = 1; pullup = true;
else if (strcasecmp("off", tmp) == 0) else if (strcasecmp("off", tmp) == 0)
; // ignore ; // ignore
else else
@ -383,7 +384,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg)
tmp = extract_programmer_param_str(cfg, "psus"); tmp = extract_programmer_param_str(cfg, "psus");
if (tmp) { if (tmp) {
if (strcasecmp("on", tmp) == 0) if (strcasecmp("on", tmp) == 0)
psu = 1; psu = true;
else if (strcasecmp("off", tmp) == 0) else if (strcasecmp("off", tmp) == 0)
; // ignore ; // ignore
else 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 */ /* Initial setup (SPI peripherals config): Enable power, CS high, AUX */
bp_commbuf[0] = 0x40 | 0x0b; bp_commbuf[0] = 0x40 | 0x0b;
if (pullup == 1) { if (pullup) {
bp_commbuf[0] |= (1 << 2); bp_commbuf[0] |= (1 << 2);
msg_pdbg("Enabling pull-up resistors.\n"); msg_pdbg("Enabling pull-up resistors.\n");
} }
if (psu == 1) { if (psu) {
bp_commbuf[0] |= (1 << 3); bp_commbuf[0] |= (1 << 3);
msg_pdbg("Enabling PSUs.\n"); 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 */ /* Set SPI config: output type, idle, clock edge, sample */
bp_commbuf[0] = 0x80 | 0xa; bp_commbuf[0] = 0x80 | 0xa;
if (pullup == 1) { if (pullup) {
bp_commbuf[0] &= ~(1 << 3); bp_commbuf[0] &= ~(1 << 3);
msg_pdbg("Pull-ups enabled, so using HiZ pin output! (Open-Drain mode)\n"); msg_pdbg("Pull-ups enabled, so using HiZ pin output! (Open-Drain mode)\n");
} }