bitbang: remove superfluous switch between jtag and swd
[openocd.git] / src / jtag / drivers / sysfsgpio.c
index c6ffa3205a15ad6a6d7699c629cb9b8a717c942d..f9470a47b3c7b63d3ad3e6e8f4b129dea3d0b0d2 100644 (file)
@@ -61,7 +61,7 @@
  *
  * Assume here that there will be less than 10000 gpios on a system
  */
-static int is_gpio_valid(int gpio)
+static bool is_gpio_valid(int gpio)
 {
        return gpio >= 0 && gpio < 10000;
 }
@@ -98,8 +98,6 @@ static void unexport_sysfs_gpio(int gpio)
        snprintf(gpiostr, sizeof(gpiostr), "%d", gpio);
        if (open_write_close("/sys/class/gpio/unexport", gpiostr) < 0)
                LOG_ERROR("Couldn't unexport gpio %d", gpio);
-
-       return;
 }
 
 /*
@@ -551,21 +549,27 @@ static int sysfsgpio_quit(void);
 
 static const char * const sysfsgpio_transports[] = { "jtag", "swd", NULL };
 
-struct jtag_interface sysfsgpio_interface = {
-       .name = "sysfsgpio",
+static struct jtag_interface sysfsgpio_interface = {
        .supported = DEBUG_CAP_TMS_SEQ,
        .execute_queue = bitbang_execute_queue,
+};
+
+struct adapter_driver sysfsgpio_adapter_driver = {
+       .name = "sysfsgpio",
        .transports = sysfsgpio_transports,
-       .swd = &bitbang_swd,
        .commands = sysfsgpio_command_handlers,
+
        .init = sysfsgpio_init,
        .quit = sysfsgpio_quit,
+       .reset = sysfsgpio_reset,
+
+       .jtag_ops = &sysfsgpio_interface,
+       .swd_ops = &bitbang_swd,
 };
 
 static struct bitbang_interface sysfsgpio_bitbang = {
        .read = sysfsgpio_read,
        .write = sysfsgpio_write,
-       .reset = sysfsgpio_reset,
        .swdio_read = sysfsgpio_swdio_read,
        .swdio_drive = sysfsgpio_swdio_drive,
        .blink = 0
@@ -597,23 +601,23 @@ static void cleanup_all_fds(void)
 static bool sysfsgpio_jtag_mode_possible(void)
 {
        if (!is_gpio_valid(tck_gpio))
-               return 0;
+               return false;
        if (!is_gpio_valid(tms_gpio))
-               return 0;
+               return false;
        if (!is_gpio_valid(tdi_gpio))
-               return 0;
+               return false;
        if (!is_gpio_valid(tdo_gpio))
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 static bool sysfsgpio_swd_mode_possible(void)
 {
        if (!is_gpio_valid(swclk_gpio))
-               return 0;
+               return false;
        if (!is_gpio_valid(swdio_gpio))
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 static int sysfsgpio_init(void)
@@ -690,13 +694,6 @@ static int sysfsgpio_init(void)
                        goto out_error;
        }
 
-       if (sysfsgpio_swd_mode_possible()) {
-               if (swd_mode)
-                       bitbang_swd_switch_seq(JTAG_TO_SWD);
-               else
-                       bitbang_swd_switch_seq(SWD_TO_JTAG);
-       }
-
        return ERROR_OK;
 
 out_error:
@@ -709,4 +706,3 @@ static int sysfsgpio_quit(void)
        cleanup_all_fds();
        return ERROR_OK;
 }
-

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)