From b931286ab440f4677a9ac983a64b55055d20c438 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 27 Mar 2023 10:43:30 +0200 Subject: [PATCH] target: rewrite command 'arp_halt' as COMMAND_HANDLER While there, add the missing .usage field. Change-Id: I748382cafe08443c458ff1d4e47819610cfbf85c Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/7558 Tested-by: jenkins --- src/target/target.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index e995f134e..f2e8d531a 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5822,19 +5822,18 @@ static int jim_target_reset(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return (e == ERROR_OK) ? JIM_OK : JIM_ERR; } -static int jim_target_halt(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +COMMAND_HANDLER(handle_target_halt) { - if (argc != 1) { - Jim_WrongNumArgs(interp, 1, argv, "[no parameters]"); - return JIM_ERR; + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + struct target *target = get_current_target(CMD_CTX); + if (!target->tap->enabled) { + command_print(CMD, "[TAP is disabled]"); + return ERROR_FAIL; } - struct command_context *cmd_ctx = current_command_context(interp); - assert(cmd_ctx); - struct target *target = get_current_target(cmd_ctx); - if (!target->tap->enabled) - return jim_target_tap_disabled(interp); - int e = target->type->halt(target); - return (e == ERROR_OK) ? JIM_OK : JIM_ERR; + + return target->type->halt(target); } static int jim_target_wait_state(Jim_Interp *interp, int argc, Jim_Obj *const *argv) @@ -6108,8 +6107,9 @@ static const struct command_registration target_instance_command_handlers[] = { { .name = "arp_halt", .mode = COMMAND_EXEC, - .jim_handler = jim_target_halt, + .handler = handle_target_halt, .help = "used internally for reset processing", + .usage = "", }, { .name = "arp_waitstate",