]> git.sur5r.net Git - openocd/commitdiff
Improve JTAG reset, speed, and khz handlers to use parse_uint helper.
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 12 Jun 2009 01:40:35 +0000 (01:40 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 12 Jun 2009 01:40:35 +0000 (01:40 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@2213 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/tcl.c

index f2a5bf8fddacd8db5859fc42ae9dea5916966360..eadfb431714a5d194cadde8c3ebbba382e9e65d1 100644 (file)
@@ -971,7 +971,13 @@ static int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx,
        if (argc > 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
        if (argc == 1)
-               jtag_set_nsrst_delay(strtoul(args[0], NULL, 0));
+       {
+               unsigned delay;
+               int retval = parse_uint(args[0], &delay);
+               if (ERROR_OK != retval)
+                       return retval;
+               jtag_set_nsrst_delay(delay);
+       }
        command_print(cmd_ctx, "jtag_nsrst_delay: %u", jtag_get_nsrst_delay());
        return ERROR_OK;
 }
@@ -982,7 +988,13 @@ static int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx,
        if (argc > 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
        if (argc == 1)
-               jtag_set_ntrst_delay(strtoul(args[0], NULL, 0));
+       {
+               unsigned delay;
+               int retval = parse_uint(args[0], &delay);
+               if (ERROR_OK != retval)
+                       return retval;
+               jtag_set_ntrst_delay(delay);
+       }
        command_print(cmd_ctx, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
        return ERROR_OK;
 }
@@ -997,8 +1009,10 @@ static int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cm
        {
                LOG_DEBUG("handle jtag speed");
 
-               int cur_speed = 0;
-               cur_speed = strtoul(args[0], NULL, 0);
+               unsigned cur_speed = 0;
+               int retval = parse_uint(args[0], &cur_speed);
+               if (ERROR_OK != retval)
+                       return retval;
                retval = jtag_set_speed(cur_speed);
 
        }
@@ -1015,7 +1029,11 @@ static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd,
        int retval = ERROR_OK;
        if (argc == 1)
        {
-               retval = jtag_config_khz(strtoul(args[0], NULL, 0));
+               unsigned khz = 0;
+               int retval = parse_uint(args[0], &khz);
+               if (ERROR_OK != retval)
+                       return retval;
+               retval = jtag_config_khz(khz);
                if (ERROR_OK != retval)
                        return retval;
        }