Skip to content

Commit 337db32

Browse files
zapb-0borneoa
authored andcommitted
adapter/bitbang: Use 'bool' data type for blink()
Change-Id: I187f8944ad5fd92f28cbd32e447f9ec1a97e16d6 Signed-off-by: Marc Schink <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/8515 Reviewed-by: Antonio Borneo <[email protected]> Tested-by: jenkins
1 parent f4d81cd commit 337db32

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

src/jtag/drivers/am335xgpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ static int am335xgpio_swdio_read(void)
275275
return get_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO]);
276276
}
277277

278-
static int am335xgpio_blink(int on)
278+
static int am335xgpio_blink(bool on)
279279
{
280280
if (is_gpio_config_valid(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED]))
281-
set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on);
281+
set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on ? 1 : 0);
282282

283283
return ERROR_OK;
284284
}

src/jtag/drivers/bcm2835gpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ static void bcm2835gpio_munmap(void)
419419
}
420420
}
421421

422-
static int bcm2835gpio_blink(int on)
422+
static int bcm2835gpio_blink(bool on)
423423
{
424424
if (is_gpio_config_valid(ADAPTER_GPIO_IDX_LED))
425-
set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on);
425+
set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on ? 1 : 0);
426426

427427
return ERROR_OK;
428428
}

src/jtag/drivers/bitbang.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue)
309309
retval = ERROR_OK;
310310

311311
if (bitbang_interface->blink) {
312-
if (bitbang_interface->blink(1) != ERROR_OK)
312+
if (bitbang_interface->blink(true) != ERROR_OK)
313313
return ERROR_FAIL;
314314
}
315315

@@ -377,7 +377,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue)
377377
cmd = cmd->next;
378378
}
379379
if (bitbang_interface->blink) {
380-
if (bitbang_interface->blink(0) != ERROR_OK)
380+
if (bitbang_interface->blink(false) != ERROR_OK)
381381
return ERROR_FAIL;
382382
}
383383

@@ -396,7 +396,7 @@ static void bitbang_swd_exchange(bool rnw, uint8_t buf[], unsigned int offset, u
396396
{
397397
if (bitbang_interface->blink) {
398398
/* FIXME: we should manage errors */
399-
bitbang_interface->blink(1);
399+
bitbang_interface->blink(true);
400400
}
401401

402402
for (unsigned int i = offset; i < bit_cnt + offset; i++) {
@@ -418,7 +418,7 @@ static void bitbang_swd_exchange(bool rnw, uint8_t buf[], unsigned int offset, u
418418

419419
if (bitbang_interface->blink) {
420420
/* FIXME: we should manage errors */
421-
bitbang_interface->blink(0);
421+
bitbang_interface->blink(false);
422422
}
423423
}
424424

src/jtag/drivers/bitbang.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct bitbang_interface {
4545
int (*write)(int tck, int tms, int tdi);
4646

4747
/** Blink led (optional). */
48-
int (*blink)(int on);
48+
int (*blink)(bool on);
4949

5050
/** Sample SWDIO and return the value. */
5151
int (*swdio_read)(void);

src/jtag/drivers/dummy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int dummy_reset(int trst, int srst)
7272
return ERROR_OK;
7373
}
7474

75-
static int dummy_led(int on)
75+
static int dummy_led(bool on)
7676
{
7777
return ERROR_OK;
7878
}

src/jtag/drivers/linuxgpiod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ static int linuxgpiod_swd_write(int swclk, int swdio)
178178
return ERROR_OK;
179179
}
180180

181-
static int linuxgpiod_blink(int on)
181+
static int linuxgpiod_blink(bool on)
182182
{
183183
int retval;
184184

185185
if (!is_gpio_config_valid(ADAPTER_GPIO_IDX_LED))
186186
return ERROR_OK;
187187

188-
retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on);
188+
retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on ? 1 : 0);
189189
if (retval < 0)
190190
LOG_WARNING("Fail set led");
191191
return retval;

src/jtag/drivers/parport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ static int parport_reset(int trst, int srst)
183183
return ERROR_OK;
184184
}
185185

186-
/* turn LED on parport adapter on (1) or off (0) */
187-
static int parport_led(int on)
186+
/* turn LED on parport adapter on (true) or off (true) */
187+
static int parport_led(bool on)
188188
{
189189
if (on)
190190
dataport_value |= cable->LED_MASK;
@@ -364,7 +364,7 @@ static int parport_init(void)
364364
return ERROR_FAIL;
365365
if (parport_write(0, 0, 0) != ERROR_OK)
366366
return ERROR_FAIL;
367-
if (parport_led(1) != ERROR_OK)
367+
if (parport_led(true) != ERROR_OK)
368368
return ERROR_FAIL;
369369

370370
bitbang_interface = &parport_bitbang;
@@ -374,7 +374,7 @@ static int parport_init(void)
374374

375375
static int parport_quit(void)
376376
{
377-
if (parport_led(0) != ERROR_OK)
377+
if (parport_led(false) != ERROR_OK)
378378
return ERROR_FAIL;
379379

380380
if (parport_exit) {

src/jtag/drivers/remote_bitbang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int remote_bitbang_sleep(unsigned int microseconds)
251251
return remote_bitbang_flush();
252252
}
253253

254-
static int remote_bitbang_blink(int on)
254+
static int remote_bitbang_blink(bool on)
255255
{
256256
char c = on ? 'B' : 'b';
257257
return remote_bitbang_queue(c, FLUSH_SEND_BUF);

0 commit comments

Comments
 (0)