libusb: don't use typedef's
[openocd.git] / src / jtag / drivers / vsllink.c
index 501322bba66583acf19b72df663485b06f1120d0..f08fa9165ed40191c0882abe6cc1d1a363e7bc3b 100644 (file)
@@ -59,7 +59,7 @@ static void vsllink_runtest(int num_cycles);
 static void vsllink_stableclocks(int num_cycles, int tms);
 static void vsllink_scan(bool ir_scan, enum scan_type type,
                uint8_t *buffer, int scan_size, struct scan_command *command);
-static void vsllink_reset(int trst, int srst);
+static int vsllink_reset(int trst, int srst);
 
 /* VSLLink tap buffer functions */
 static void vsllink_tap_append_step(int tms, int tdi);
@@ -164,22 +164,8 @@ static int vsllink_execute_queue(void)
                                                cmd->cmd.scan);
                                break;
 
-                       case JTAG_RESET:
-                               LOG_DEBUG_IO("reset trst: %i srst %i",
-                                               cmd->cmd.reset->trst,
-                                               cmd->cmd.reset->srst);
-
-                               vsllink_tap_execute();
-
-                               if (cmd->cmd.reset->trst == 1)
-                                       tap_set_state(TAP_RESET);
-
-                               vsllink_reset(cmd->cmd.reset->trst,
-                                               cmd->cmd.reset->srst);
-                               break;
-
                        case JTAG_SLEEP:
-                               LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
+                               LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
                                vsllink_tap_execute();
                                jtag_sleep(cmd->cmd.sleep->us);
                                break;
@@ -259,18 +245,14 @@ static int vsllink_speed_div(int jtag_speed, int *khz)
 
 static void vsllink_free_buffer(void)
 {
-       if (tdi_buffer != NULL) {
-               free(tdi_buffer);
-               tdi_buffer = NULL;
-       }
-       if (tdo_buffer != NULL) {
-               free(tdo_buffer);
-               tdo_buffer = NULL;
-       }
-       if (tms_buffer != NULL) {
-               free(tms_buffer);
-               tms_buffer = NULL;
-       }
+       free(tdi_buffer);
+       tdi_buffer = NULL;
+
+       free(tdo_buffer);
+       tdo_buffer = NULL;
+
+       free(tms_buffer);
+       tms_buffer = NULL;
 }
 
 static int vsllink_quit(void)
@@ -306,7 +288,7 @@ static int vsllink_interface_init(void)
        libusb_init(&vsllink_handle->libusb_ctx);
 
        if (ERROR_OK != vsllink_usb_open(vsllink_handle)) {
-               LOG_ERROR("Can't find USB JTAG Interface!" \
+               LOG_ERROR("Can't find USB JTAG Interface!"
                        "Please check connection and permissions.");
                return ERROR_JTAG_INIT_FAILED;
        }
@@ -478,7 +460,7 @@ static void vsllink_scan(bool ir_scan, enum scan_type type, uint8_t *buffer,
                vsllink_state_move();
 }
 
-static void vsllink_reset(int trst, int srst)
+static int vsllink_reset(int trst, int srst)
 {
        LOG_DEBUG("trst: %i, srst: %i", trst, srst);
 
@@ -494,7 +476,7 @@ static void vsllink_reset(int trst, int srst)
                        versaloon_interface.adaptors.gpio.out(0, GPIO_TRST, 0);
        }
 
-       versaloon_interface.adaptors.peripheral_commit();
+       return versaloon_interface.adaptors.peripheral_commit();
 }
 
 COMMAND_HANDLER(vsllink_handle_usb_vid_command)
@@ -690,8 +672,7 @@ static int vsllink_jtag_execute(void)
                                        return ERROR_JTAG_QUEUE_FAILED;
                                }
 
-                               if (pending_scan_result->buffer != NULL)
-                                       free(pending_scan_result->buffer);
+                               free(pending_scan_result->buffer);
                        }
                }
        } else {
@@ -831,7 +812,7 @@ static int vsllink_check_usb_strings(
 static int vsllink_usb_open(struct vsllink *vsllink)
 {
        ssize_t num_devices, i;
-       libusb_device **usb_devices;
+       struct libusb_device **usb_devices;
        struct libusb_device_descriptor usb_desc;
        struct libusb_device_handle *usb_device_handle;
        int retval;
@@ -842,7 +823,7 @@ static int vsllink_usb_open(struct vsllink *vsllink)
                return ERROR_FAIL;
 
        for (i = 0; i < num_devices; i++) {
-               libusb_device *device = usb_devices[i];
+               struct libusb_device *device = usb_devices[i];
 
                retval = libusb_get_device_descriptor(device, &usb_desc);
                if (retval != 0)
@@ -956,24 +937,29 @@ static const char * const vsllink_transports[] = {"jtag", "swd", NULL};
 
 static const struct swd_driver vsllink_swd_driver = {
        .init = vsllink_swd_init,
-       .frequency = vsllink_swd_frequency,
        .switch_seq = vsllink_swd_switch_seq,
        .read_reg = vsllink_swd_read_reg,
        .write_reg = vsllink_swd_write_reg,
        .run = vsllink_swd_run_queue,
 };
 
-struct jtag_interface vsllink_interface = {
-       .name = "vsllink",
+static struct jtag_interface vsllink_interface = {
        .supported = DEBUG_CAP_TMS_SEQ,
-       .commands = vsllink_command_handlers,
+       .execute_queue = vsllink_execute_queue,
+};
+
+struct adapter_driver vsllink_adapter_driver = {
+       .name = "vsllink",
        .transports = vsllink_transports,
-       .swd = &vsllink_swd_driver,
+       .commands = vsllink_command_handlers,
 
        .init = vsllink_init,
        .quit = vsllink_quit,
-       .khz = vsllink_khz,
+       .reset = vsllink_reset,
        .speed = vsllink_speed,
+       .khz = vsllink_khz,
        .speed_div = vsllink_speed_div,
-       .execute_queue = vsllink_execute_queue,
+
+       .jtag_ops = &vsllink_interface,
+       .swd_ops = &vsllink_swd_driver,
 };

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)