From 47a1185d5d97483698610d9e7bf03a5411cac5d2 Mon Sep 17 00:00:00 2001 From: zwelch Date: Mon, 8 Jun 2009 10:54:41 +0000 Subject: Cleanup the handle_jtag_khz_command routine: - Separate retval assignments from logical tests. - Simplify logical tests. git-svn-id: svn://svn.berlios.de/openocd/trunk@2110 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/jtag/jtag.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c index f58c90e1..113c9610 100644 --- a/src/jtag/jtag.c +++ b/src/jtag/jtag.c @@ -2167,41 +2167,39 @@ static int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cm static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - int retval=ERROR_OK; - LOG_DEBUG("handle jtag khz"); + if (argc > 1) + return ERROR_COMMAND_SYNTAX_ERROR; + int retval = ERROR_OK; int cur_speed = 0; - if(argc == 1) + if (argc == 1) { + LOG_DEBUG("handle jtag khz"); + jtag_set_speed_khz(strtoul(args[0], NULL, 0)); if (jtag != NULL) { LOG_DEBUG("have interface set up"); int speed_div1; - if ((retval=jtag->khz(jtag_get_speed_khz(), &speed_div1))!=ERROR_OK) + retval = jtag->khz(jtag_get_speed_khz(), &speed_div1); + if (ERROR_OK != retval) { jtag_set_speed_khz(0); return retval; } - cur_speed = jtag_speed = speed_div1; - retval=jtag->speed(cur_speed); - } else - { - hasKHz = true; + retval = jtag->speed(cur_speed); } - } else if (argc==0) - { - } else - { - return ERROR_COMMAND_SYNTAX_ERROR; + else + hasKHz = true; } - cur_speed = jtag_get_speed_khz(); - if (jtag!=NULL) + cur_speed = jtag_get_speed_khz(); + if (jtag != NULL) { - if ((retval=jtag->speed_div(jtag_speed, &cur_speed))!=ERROR_OK) + retval = jtag->speed_div(jtag_speed, &cur_speed); + if (ERROR_OK != retval) return retval; } -- cgit v1.2.3