From: openocd-gerrit <ope...@us...> - 2025-03-15 10:21:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 427528069806b20c05c78f935529bd62308351a9 (commit) via 6beb6280af985e79094501af5cb66d1a33019544 (commit) from e4a51b3235167ea2fccf399d55dc3fe87364dbb8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 427528069806b20c05c78f935529bd62308351a9 Author: Antonio Borneo <bor...@gm...> Date: Sun Dec 1 00:01:00 2024 +0100 adapter: simplify command 'adapter list' The code of command 'adapter list' is called by command 'adapter driver' to list the available drivers in case of error. This dual possible entry points require a conditional check on the number of command line arguments, reducing the code readability. Split the command in a simpler code for the command 'adapter list' that only checks the command line, and move in a common helper the code that list the drivers. While there, fix the output and the comments to report 'adapter driver' instead of 'debug adapters'; we are not parsing the HW to know which adapter is present. Change-Id: I17538e86dc4a31a9589d404e49dcc65a29393390 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8672 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index db3d3b0fe..2fcbd609e 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -392,12 +392,8 @@ COMMAND_HANDLER(handle_adapter_name) return ERROR_OK; } -COMMAND_HANDLER(handle_adapter_list_command) +COMMAND_HANDLER(dump_adapter_driver_list) { - if (strcmp(CMD_NAME, "list") == 0 && CMD_ARGC > 0) - return ERROR_COMMAND_SYNTAX_ERROR; - - command_print(CMD, "The following debug adapters are available:"); for (unsigned int i = 0; adapter_drivers[i]; i++) { const char *name = adapter_drivers[i]->name; command_print(CMD, "%u: %s", i + 1, name); @@ -406,6 +402,14 @@ COMMAND_HANDLER(handle_adapter_list_command) return ERROR_OK; } +COMMAND_HANDLER(handle_adapter_list_command) +{ + if (CMD_ARGC) + return ERROR_COMMAND_SYNTAX_ERROR; + + return CALL_COMMAND_HANDLER(dump_adapter_driver_list); +} + COMMAND_HANDLER(handle_adapter_driver_command) { int retval; @@ -440,7 +444,8 @@ COMMAND_HANDLER(handle_adapter_driver_command) */ LOG_ERROR("The specified debug interface was not found (%s)", CMD_ARGV[0]); - CALL_COMMAND_HANDLER(handle_adapter_list_command); + command_print(CMD, "The following adapter drivers are available:"); + CALL_COMMAND_HANDLER(dump_adapter_driver_list); return ERROR_JTAG_INVALID_INTERFACE; } commit 6beb6280af985e79094501af5cb66d1a33019544 Author: Antonio Borneo <bor...@gm...> Date: Sun Dec 22 17:13:59 2024 +0100 adapter: drop command 'adapter transports' The commit 93f2afa45f4c ("initial "transport" framework") that added the transport framework in 2010 was overly optimistic on the possibility to dynamically add, at runtime, a new adapter and to specify with the command 'adapter transports' the list of the transports supported by the new adapter. Such feature has never become part of OpenOCD, and the command above has never become useful nor ever been used. Drop the command 'adapter transports' and its documentation. Drop the helper 'transport_list_parse', now unused. Change-Id: Ie3d71c74d068fba802839b116bb9bc9af77cc83d Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8671 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 140d0f8c7..9ff524b74 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2415,12 +2415,6 @@ target. List the debug adapter drivers that have been built into the running copy of OpenOCD. @end deffn -@deffn {Config Command} {adapter transports} transport_name+ -Specifies the transports supported by this debug adapter. -The adapter driver builds-in similar knowledge; use this only -when external configuration (such as jumpering) changes what -the hardware can support. -@end deffn @anchor{adapter gpio} @deffn {Config Command} {adapter gpio [ @ diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 04942f753..db3d3b0fe 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -392,25 +392,6 @@ COMMAND_HANDLER(handle_adapter_name) return ERROR_OK; } -COMMAND_HANDLER(adapter_transports_command) -{ - char **transports; - int retval; - - retval = CALL_COMMAND_HANDLER(transport_list_parse, &transports); - if (retval != ERROR_OK) - return retval; - - retval = allow_transports(CMD_CTX, (const char **)transports); - - if (retval != ERROR_OK) { - for (unsigned int i = 0; transports[i]; i++) - free(transports[i]); - free(transports); - } - return retval; -} - COMMAND_HANDLER(handle_adapter_list_command) { if (strcmp(CMD_NAME, "list") == 0 && CMD_ARGC > 0) @@ -1137,13 +1118,6 @@ static const struct command_registration adapter_command_handlers[] = { .usage = "", .chain = adapter_srst_command_handlers, }, - { - .name = "transports", - .handler = adapter_transports_command, - .mode = COMMAND_CONFIG, - .help = "Declare transports the adapter supports.", - .usage = "transport ...", - }, { .name = "usb", .mode = COMMAND_ANY, diff --git a/src/transport/transport.c b/src/transport/transport.c index c7293e7fd..0af136036 100644 --- a/src/transport/transport.c +++ b/src/transport/transport.c @@ -166,54 +166,6 @@ struct transport *get_current_transport(void) * Infrastructure for Tcl interface to transports. */ -/** - * Makes and stores a copy of a set of transports passed as - * parameters to a command. - * - * @param vector where the resulting copy is stored, as an argv-style - * NULL-terminated vector. - */ -COMMAND_HELPER(transport_list_parse, char ***vector) -{ - char **argv; - unsigned int n = CMD_ARGC; - unsigned int j = 0; - - *vector = NULL; - - if (n < 1) - return ERROR_COMMAND_SYNTAX_ERROR; - - /* our return vector must be NULL terminated */ - argv = calloc(n + 1, sizeof(char *)); - if (!argv) - return ERROR_FAIL; - - for (unsigned int i = 0; i < n; i++) { - struct transport *t; - - for (t = transport_list; t; t = t->next) { - if (strcmp(t->name, CMD_ARGV[i]) != 0) - continue; - argv[j++] = strdup(CMD_ARGV[i]); - break; - } - if (!t) { - LOG_ERROR("no such transport '%s'", CMD_ARGV[i]); - goto fail; - } - } - - *vector = argv; - return ERROR_OK; - -fail: - for (unsigned int i = 0; i < n; i++) - free(argv[i]); - free(argv); - return ERROR_FAIL; -} - COMMAND_HANDLER(handle_transport_init) { LOG_DEBUG("%s", __func__); diff --git a/src/transport/transport.h b/src/transport/transport.h index 00d8b07e1..2e3dcc61a 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -77,8 +77,6 @@ struct transport *get_current_transport(void); int transport_register_commands(struct command_context *ctx); -COMMAND_HELPER(transport_list_parse, char ***vector); - int allow_transports(struct command_context *ctx, const char * const *vector); bool transport_is_jtag(void); ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 6 ------ src/jtag/adapter.c | 41 ++++++++++------------------------------ src/transport/transport.c | 48 ----------------------------------------------- src/transport/transport.h | 2 -- 4 files changed, 10 insertions(+), 87 deletions(-) hooks/post-receive -- Main OpenOCD repository |