1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

pony_spi.c: Retype appropriate variables with bool

Use the bool type instead of an integer for appropriate variables and
attributes, since this represents their purpose much better.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: Iecd98c391a74794647caeeb2715707ccd681463c
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66875
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Felix Singer 2022-08-19 00:48:00 +02:00 committed by Anastasia Klimchuk
parent 4840cfe210
commit 2ce2606bd5

View File

@ -36,6 +36,7 @@
* DCE >-------> DSR * DCE >-------> DSR
*/ */
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <strings.h>
#include <string.h> #include <string.h>
@ -51,11 +52,11 @@ enum pony_type {
struct pony_spi_data { struct pony_spi_data {
/* Pins for master->slave direction */ /* Pins for master->slave direction */
int negate_cs; bool negate_cs;
int negate_sck; bool negate_sck;
int negate_mosi; bool negate_mosi;
/* Pins for slave->master direction */ /* Pins for slave->master direction */
int negate_miso; bool negate_miso;
}; };
static void pony_bitbang_set_cs(int val, void *spi_data) static void pony_bitbang_set_cs(int val, void *spi_data)
@ -120,14 +121,14 @@ static int pony_spi_shutdown(void *data)
return ret; return ret;
} }
static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, int *have_device) static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, bool *have_device)
{ {
char *arg = NULL; char *arg = NULL;
int ret = 0; int ret = 0;
/* defaults */ /* defaults */
*type = TYPE_SI_PROG; *type = TYPE_SI_PROG;
*have_device = 0; *have_device = false;
/* The parameter is in format "dev=/dev/device,type=serbang" */ /* The parameter is in format "dev=/dev/device,type=serbang" */
arg = extract_programmer_param_str(cfg, "dev"); arg = extract_programmer_param_str(cfg, "dev");
@ -136,7 +137,7 @@ static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, in
if (sp_fd == SER_INV_FD) if (sp_fd == SER_INV_FD)
ret = 1; ret = 1;
else else
(*have_device)++; *have_device = true;
} }
free(arg); free(arg);
@ -164,8 +165,8 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
int i, data_out; int i, data_out;
enum pony_type type; enum pony_type type;
const char *name; const char *name;
int have_device; bool have_device;
int have_prog = 0; bool have_prog = false;
if (get_params(cfg, &type, &have_device)) { if (get_params(cfg, &type, &have_device)) {
serialport_shutdown(NULL); serialport_shutdown(NULL);
@ -184,10 +185,10 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
serialport_shutdown(NULL); serialport_shutdown(NULL);
return 1; return 1;
} }
data->negate_cs = 1; data->negate_cs = true;
data->negate_sck = 0; data->negate_sck = false;
data->negate_mosi = 0; data->negate_mosi = false;
data->negate_miso = 0; data->negate_miso = false;
if (register_shutdown(pony_spi_shutdown, data) != 0) { if (register_shutdown(pony_spi_shutdown, data) != 0) {
free(data); free(data);
@ -200,25 +201,25 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
*/ */
switch (type) { switch (type) {
case TYPE_AJAWE: case TYPE_AJAWE:
data->negate_cs = 1; data->negate_cs = true;
data->negate_sck = 1; data->negate_sck = true;
data->negate_mosi = 1; data->negate_mosi = true;
data->negate_miso = 1; data->negate_miso = true;
name = "AJAWe"; name = "AJAWe";
break; break;
case TYPE_SERBANG: case TYPE_SERBANG:
data->negate_cs = 0; data->negate_cs = false;
data->negate_sck = 0; data->negate_sck = false;
data->negate_mosi = 0; data->negate_mosi = false;
data->negate_miso = 1; data->negate_miso = true;
name = "serbang"; name = "serbang";
break; break;
default: default:
case TYPE_SI_PROG: case TYPE_SI_PROG:
data->negate_cs = 1; data->negate_cs = true;
data->negate_sck = 0; data->negate_sck = false;
data->negate_mosi = 0; data->negate_mosi = false;
data->negate_miso = 0; data->negate_miso = false;
name = "SI-Prog"; name = "SI-Prog";
break; break;
} }
@ -233,12 +234,12 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
switch (type) { switch (type) {
case TYPE_AJAWE: case TYPE_AJAWE:
have_prog = 1; have_prog = true;
break; break;
case TYPE_SI_PROG: case TYPE_SI_PROG:
case TYPE_SERBANG: case TYPE_SERBANG:
default: default:
have_prog = 1; have_prog = true;
/* We toggle RTS/SCK a few times and see if DSR changes too. */ /* We toggle RTS/SCK a few times and see if DSR changes too. */
for (i = 1; i <= 10; i++) { for (i = 1; i <= 10; i++) {
data_out = i & 1; data_out = i & 1;
@ -247,7 +248,7 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
/* If DSR does not change, we are not connected to what we think */ /* If DSR does not change, we are not connected to what we think */
if (data_out != sp_get_pin(PIN_DSR)) { if (data_out != sp_get_pin(PIN_DSR)) {
have_prog = 0; have_prog = false;
break; break;
} }
} }