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:
parent
4840cfe210
commit
2ce2606bd5
57
pony_spi.c
57
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 @@ enum pony_type {
|
||||
|
||||
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 @@ static int pony_spi_shutdown(void *data)
|
||||
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 @@ static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, in
|
||||
if (sp_fd == SER_INV_FD)
|
||||
ret = 1;
|
||||
else
|
||||
(*have_device)++;
|
||||
*have_device = true;
|
||||
}
|
||||
free(arg);
|
||||
|
||||
@ -164,8 +165,8 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
|
||||
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 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
|
||||
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 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
|
||||
*/
|
||||
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 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
|
||||
|
||||
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 @@ static int pony_spi_init(const struct programmer_cfg *cfg)
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user