This is an automated email from Gerrit. "Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8673
-- gerrit commit d2796836721a26db4d9c6e22c108445a2b87854e Author: Antonio Borneo <borneo.anto...@gmail.com> Date: Sun Dec 22 11:51:03 2024 +0100 adapter: let 'adapter driver' command return selected adapter Almost every OpenOCD command used to set a value, return the value already set when used with no arguments. Let also the command 'adapter driver' to return the name of the selected adapter driver. Align the documentation to the new syntax. Keep the command as a 'config' command. It could be modified, if needed, to be run at 'exec' time. While there, fix the output and the comments to report 'adapter driver' instead of the old term 'interface'. Change-Id: I4c597cb1ee66befeb785d9820856987fb3bc5523 Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com> diff --git a/doc/openocd.texi b/doc/openocd.texi index 59a0e999dd..b3f8403fb7 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2403,9 +2403,10 @@ The @command{adapter driver} command tells OpenOCD what type of debug adapter yo using. Depending on the type of adapter, you may need to use one or more additional commands to further identify or configure the adapter. -@deffn {Config Command} {adapter driver} name +@deffn {Config Command} {adapter driver} [name] Use the adapter driver @var{name} to connect to the target. +Without @var{name} it displays the already selected driver. @end deffn @deffn {Command} {adapter list} diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index b03e2a864d..d67e73a8a3 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -415,16 +415,25 @@ COMMAND_HANDLER(handle_adapter_driver_command) { int retval; - /* check whether the interface is already configured */ + if (CMD_ARGC > 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + if (!CMD_ARGC) { + if (adapter_driver) { + command_print(CMD, "%s", adapter_driver->name); + return ERROR_OK; + } + + command_print(CMD, "Adapter driver not configured"); + return ERROR_FAIL; + } + + /* check whether the adapter driver is already configured */ if (adapter_driver) { - LOG_WARNING("Interface already configured, ignoring"); + LOG_WARNING("Adapter driver already configured, ignoring"); return ERROR_OK; } - /* interface name is a mandatory argument */ - if (CMD_ARGC != 1 || CMD_ARGV[0][0] == '\0') - return ERROR_COMMAND_SYNTAX_ERROR; - for (unsigned int i = 0; adapter_drivers[i]; i++) { if (strcmp(CMD_ARGV[0], adapter_drivers[i]->name) != 0) continue; @@ -440,10 +449,10 @@ COMMAND_HANDLER(handle_adapter_driver_command) return allow_transports(CMD_CTX, adapter_driver->transports); } - /* no valid interface was found (i.e. the configuration option, - * didn't match one of the compiled-in interfaces + /* no valid adapter driver is found (i.e. the configuration option + * didn't match one of the compiled-in driver) */ - LOG_ERROR("The specified debug interface was not found (%s)", + LOG_ERROR("The specified adapter driver is not found (%s)", CMD_ARGV[0]); CALL_COMMAND_HANDLER(dump_adapter_driver_list); return ERROR_JTAG_INVALID_INTERFACE; @@ -1081,8 +1090,9 @@ static const struct command_registration adapter_command_handlers[] = { .name = "driver", .handler = handle_adapter_driver_command, .mode = COMMAND_CONFIG, - .help = "Select a debug adapter driver", - .usage = "driver_name", + .help = "Select a debug adapter driver." + "Without argument display the current setting", + .usage = "[driver_name]", }, { .name = "speed", --