]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
adapter/bitbang: Use 'bool' data type for blink()
authorMarc Schink <dev@zapb.de>
Fri, 30 Aug 2024 09:06:13 +0000 (11:06 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 2 Nov 2024 21:05:37 +0000 (21:05 +0000)
Change-Id: I187f8944ad5fd92f28cbd32e447f9ec1a97e16d6
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8515
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
src/jtag/drivers/am335xgpio.c
src/jtag/drivers/bcm2835gpio.c
src/jtag/drivers/bitbang.c
src/jtag/drivers/bitbang.h
src/jtag/drivers/dummy.c
src/jtag/drivers/linuxgpiod.c
src/jtag/drivers/parport.c
src/jtag/drivers/remote_bitbang.c

index cfe41c3be5a525d8fdd166fc9e313cffdf39082d..9bb7ea7d13144ee050efb11563cfb166fd799d02 100644 (file)
@@ -275,10 +275,10 @@ static int am335xgpio_swdio_read(void)
        return get_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO]);
 }
 
-static int am335xgpio_blink(int on)
+static int am335xgpio_blink(bool on)
 {
        if (is_gpio_config_valid(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED]))
-               set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on);
+               set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on ? 1 : 0);
 
        return ERROR_OK;
 }
index b8d91bf3824f2c70be79250aa3a95deb9e2a6dfc..2c2061daec99df9630ce933aaad2a35d06b9002a 100644 (file)
@@ -419,10 +419,10 @@ static void bcm2835gpio_munmap(void)
        }
 }
 
-static int bcm2835gpio_blink(int on)
+static int bcm2835gpio_blink(bool on)
 {
        if (is_gpio_config_valid(ADAPTER_GPIO_IDX_LED))
-               set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on);
+               set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_LED], on ? 1 : 0);
 
        return ERROR_OK;
 }
index 17e01a2330302c17ecfba0dec4fc02590a086ca0..42234a6f72b821efc0eb5fba09b5beb43bc9e25f 100644 (file)
@@ -309,7 +309,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue)
        retval = ERROR_OK;
 
        if (bitbang_interface->blink) {
-               if (bitbang_interface->blink(1) != ERROR_OK)
+               if (bitbang_interface->blink(true) != ERROR_OK)
                        return ERROR_FAIL;
        }
 
@@ -377,7 +377,7 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue)
                cmd = cmd->next;
        }
        if (bitbang_interface->blink) {
-               if (bitbang_interface->blink(0) != ERROR_OK)
+               if (bitbang_interface->blink(false) != ERROR_OK)
                        return ERROR_FAIL;
        }
 
@@ -396,7 +396,7 @@ static void bitbang_swd_exchange(bool rnw, uint8_t buf[], unsigned int offset, u
 {
        if (bitbang_interface->blink) {
                /* FIXME: we should manage errors */
-               bitbang_interface->blink(1);
+               bitbang_interface->blink(true);
        }
 
        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
 
        if (bitbang_interface->blink) {
                /* FIXME: we should manage errors */
-               bitbang_interface->blink(0);
+               bitbang_interface->blink(false);
        }
 }
 
index dc941796e20ffff8b9a7c24944f36be4dce9ff29..82405eb8ab11c40e458766f6f75c1c99481c8eb2 100644 (file)
@@ -45,7 +45,7 @@ struct bitbang_interface {
        int (*write)(int tck, int tms, int tdi);
 
        /** Blink led (optional). */
-       int (*blink)(int on);
+       int (*blink)(bool on);
 
        /** Sample SWDIO and return the value. */
        int (*swdio_read)(void);
index 1b1e57392f10cb898dfea48dfc4e7ff1c855e64b..4fe598fe32a346e073ab05ed828793228b20efe3 100644 (file)
@@ -72,7 +72,7 @@ static int dummy_reset(int trst, int srst)
        return ERROR_OK;
 }
 
-static int dummy_led(int on)
+static int dummy_led(bool on)
 {
        return ERROR_OK;
 }
index 1926ed9ae61c2d06b4cb85055359d1178d89fe3a..fa14e42d6edda5665da41373de884138db0a0bf1 100644 (file)
@@ -178,14 +178,14 @@ static int linuxgpiod_swd_write(int swclk, int swdio)
        return ERROR_OK;
 }
 
-static int linuxgpiod_blink(int on)
+static int linuxgpiod_blink(bool on)
 {
        int retval;
 
        if (!is_gpio_config_valid(ADAPTER_GPIO_IDX_LED))
                return ERROR_OK;
 
-       retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on);
+       retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on ? 1 : 0);
        if (retval < 0)
                LOG_WARNING("Fail set led");
        return retval;
index d26a51048fec10a1a2ed832581349933955493a0..d03d3b89c8d537cfa545a04d44ea82d6d759230f 100644 (file)
@@ -183,8 +183,8 @@ static int parport_reset(int trst, int srst)
        return ERROR_OK;
 }
 
-/* turn LED on parport adapter on (1) or off (0) */
-static int parport_led(int on)
+/* turn LED on parport adapter on (true) or off (true) */
+static int parport_led(bool on)
 {
        if (on)
                dataport_value |= cable->LED_MASK;
@@ -364,7 +364,7 @@ static int parport_init(void)
                return ERROR_FAIL;
        if (parport_write(0, 0, 0) != ERROR_OK)
                return ERROR_FAIL;
-       if (parport_led(1) != ERROR_OK)
+       if (parport_led(true) != ERROR_OK)
                return ERROR_FAIL;
 
        bitbang_interface = &parport_bitbang;
@@ -374,7 +374,7 @@ static int parport_init(void)
 
 static int parport_quit(void)
 {
-       if (parport_led(0) != ERROR_OK)
+       if (parport_led(false) != ERROR_OK)
                return ERROR_FAIL;
 
        if (parport_exit) {
index edd36f2e671eaa8770e4b1af8dd65613d9df9c4d..91a8532b79106b982100924956f9067fce0642e3 100644 (file)
@@ -251,7 +251,7 @@ static int remote_bitbang_sleep(unsigned int microseconds)
        return remote_bitbang_flush();
 }
 
-static int remote_bitbang_blink(int on)
+static int remote_bitbang_blink(bool on)
 {
        char c = on ? 'B' : 'b';
        return remote_bitbang_queue(c, FLUSH_SEND_BUF);