Anastasia Klimchuk has submitted this change. ( https://review.coreboot.org/c/flashrom/+/66875 )
Change subject: pony_spi.c: Retype appropriate variables with bool ......................................................................
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 --- M pony_spi.c 1 file changed, 46 insertions(+), 28 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
diff --git a/pony_spi.c b/pony_spi.c index 04c3236..ebeac94 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -36,6 +36,7 @@ * DCE >-------> DSR */
+#include <stdbool.h> #include <stdlib.h> #include <strings.h> #include <string.h> @@ -51,11 +52,11 @@
struct pony_spi_data { /* Pins for master->slave direction */ - int negate_cs; - int negate_sck; - int negate_mosi; + bool negate_cs; + bool negate_sck; + bool negate_mosi; /* Pins for slave->master direction */ - int negate_miso; + bool negate_miso; };
static void pony_bitbang_set_cs(int val, void *spi_data) @@ -120,14 +121,14 @@ 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; int ret = 0;
/* defaults */ *type = TYPE_SI_PROG; - *have_device = 0; + *have_device = false;
/* The parameter is in format "dev=/dev/device,type=serbang" */ arg = extract_programmer_param_str(cfg, "dev"); @@ -136,7 +137,7 @@ if (sp_fd == SER_INV_FD) ret = 1; else - (*have_device)++; + *have_device = true; } free(arg);
@@ -164,8 +165,8 @@ int i, data_out; enum pony_type type; const char *name; - int have_device; - int have_prog = 0; + bool have_device; + bool have_prog = false;
if (get_params(cfg, &type, &have_device)) { serialport_shutdown(NULL); @@ -184,10 +185,10 @@ serialport_shutdown(NULL); return 1; } - data->negate_cs = 1; - data->negate_sck = 0; - data->negate_mosi = 0; - data->negate_miso = 0; + data->negate_cs = true; + data->negate_sck = false; + data->negate_mosi = false; + data->negate_miso = false;
if (register_shutdown(pony_spi_shutdown, data) != 0) { free(data); @@ -200,25 +201,25 @@ */ switch (type) { case TYPE_AJAWE: - data->negate_cs = 1; - data->negate_sck = 1; - data->negate_mosi = 1; - data->negate_miso = 1; + data->negate_cs = true; + data->negate_sck = true; + data->negate_mosi = true; + data->negate_miso = true; name = "AJAWe"; break; case TYPE_SERBANG: - data->negate_cs = 0; - data->negate_sck = 0; - data->negate_mosi = 0; - data->negate_miso = 1; + data->negate_cs = false; + data->negate_sck = false; + data->negate_mosi = false; + data->negate_miso = true; name = "serbang"; break; default: case TYPE_SI_PROG: - data->negate_cs = 1; - data->negate_sck = 0; - data->negate_mosi = 0; - data->negate_miso = 0; + data->negate_cs = true; + data->negate_sck = false; + data->negate_mosi = false; + data->negate_miso = false; name = "SI-Prog"; break; } @@ -233,12 +234,12 @@
switch (type) { case TYPE_AJAWE: - have_prog = 1; + have_prog = true; break; case TYPE_SI_PROG: case TYPE_SERBANG: default: - have_prog = 1; + have_prog = true; /* We toggle RTS/SCK a few times and see if DSR changes too. */ for (i = 1; i <= 10; i++) { data_out = i & 1; @@ -247,7 +248,7 @@
/* If DSR does not change, we are not connected to what we think */ if (data_out != sp_get_pin(PIN_DSR)) { - have_prog = 0; + have_prog = false; break; } }