This is an automated email from Gerrit.

"Antonio Borneo <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6653

-- gerrit

commit 51c7fd6895a9350ab872ab1c3430dc3b297e29a1
Author: Antonio Borneo <[email protected]>
Date:   Thu Oct 7 22:35:12 2021 +0200

    jtag/presto: switch to command 'adapter serial'
    
    The driver presto defines the command 'presto serial' to specify
    the serial string of the adapter.
    
    Remove and deprecate the driver command, and use 'adapter serial'.
    
    Change-Id: I1a69acce7d4910082d2029d5941ae84f9424314c
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index f990a6ff6..d29a13230 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2371,9 +2371,9 @@ This command is only available if your libusb1 is at 
least version 1.0.16.
 Specifies the @var{serial_string} of the adapter to use.
 If this command is not specified, serial strings are not considered.
 Only the following adapter drivers use the serial string from this command:
-cmsis_dap, ft232r, ftdi, kitprog.
+cmsis_dap, ft232r, ftdi, kitprog, presto.
 The following adapters have their own command to specify the serial string:
-hla, jlink, presto, st-link, vsllink, xds110.
+hla, jlink, st-link, vsllink, xds110.
 @end deffn
 
 @section Interface Drivers
@@ -3017,9 +3017,6 @@ parport cable wiggler
 
 @deffn {Interface Driver} {presto}
 ASIX PRESTO USB JTAG programmer.
-@deffn {Config Command} {presto serial} serial_string
-Configures the USB serial number of the Presto device to use.
-@end deffn
 @end deffn
 
 @deffn {Interface Driver} {rlink}
diff --git a/src/jtag/drivers/presto.c b/src/jtag/drivers/presto.c
index 61de42630..9b284ca7f 100644
--- a/src/jtag/drivers/presto.c
+++ b/src/jtag/drivers/presto.c
@@ -29,6 +29,7 @@
 #include "windows.h"
 #endif
 
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #include <helper/time_support.h>
 #include "bitq.h"
@@ -132,7 +133,7 @@ static int presto_read(uint8_t *buf, uint32_t size)
        return ERROR_OK;
 }
 
-static int presto_open_libftdi(char *req_serial)
+static int presto_open_libftdi(const char *req_serial)
 {
        uint8_t presto_data;
 
@@ -195,7 +196,7 @@ static int presto_open_libftdi(char *req_serial)
        return ERROR_OK;
 }
 
-static int presto_open(char *req_serial)
+static int presto_open(const char *req_serial)
 {
        presto->buff_out_pos = 0;
        presto->buff_in_pos = 0;
@@ -506,43 +507,10 @@ static int presto_jtag_speed(int speed)
        return 0;
 }
 
-static char *presto_serial;
-
-COMMAND_HANDLER(presto_handle_serial_command)
-{
-       if (CMD_ARGC == 1) {
-               free(presto_serial);
-               presto_serial = strdup(CMD_ARGV[0]);
-       } else
-               return ERROR_COMMAND_SYNTAX_ERROR;
-
-       return ERROR_OK;
-}
-
-static const struct command_registration presto_subcommand_handlers[] = {
-       {
-               .name = "serial",
-               .handler = presto_handle_serial_command,
-               .mode = COMMAND_CONFIG,
-               .help = "Configure USB serial number of Presto device.",
-               .usage = "serial_string",
-       },
-       COMMAND_REGISTRATION_DONE
-};
-
-static const struct command_registration presto_command_handlers[] = {
-       {
-               .name = "presto",
-               .mode = COMMAND_ANY,
-               .help = "perform presto management",
-               .chain = presto_subcommand_handlers,
-               .usage = "",
-       },
-       COMMAND_REGISTRATION_DONE
-};
-
 static int presto_jtag_init(void)
 {
+       const char *presto_serial = adapter_get_serial();
+
        if (presto_open(presto_serial) != ERROR_OK) {
                presto_close();
                if (presto_serial)
@@ -562,10 +530,6 @@ static int presto_jtag_quit(void)
        bitq_cleanup();
        presto_close();
        LOG_INFO("PRESTO closed");
-
-       free(presto_serial);
-       presto_serial = NULL;
-
        return ERROR_OK;
 }
 
@@ -576,7 +540,6 @@ static struct jtag_interface presto_interface = {
 struct adapter_driver presto_adapter_driver = {
        .name = "presto",
        .transports = jtag_only,
-       .commands = presto_command_handlers,
 
        .init = presto_jtag_init,
        .quit = presto_jtag_quit,
diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl
index 75b1bfbdf..b8b866fbe 100644
--- a/src/jtag/startup.tcl
+++ b/src/jtag/startup.tcl
@@ -765,4 +765,10 @@ proc kitprog_serial args {
        eval adapter serial $args
 }
 
+lappend _telnet_autocomplete_skip "presto serial"
+proc "presto serial" {args} {
+       echo "DEPRECATED! use 'adapter serial' not 'presto serial'"
+       eval adapter serial $args
+}
+
 # END MIGRATION AIDS

-- 

Reply via email to