|
From: <zw...@ma...> - 2009-06-12 03:40:39
|
Author: zwelch
Date: 2009-06-12 03:40:35 +0200 (Fri, 12 Jun 2009)
New Revision: 2213
Modified:
trunk/src/jtag/tcl.c
Log:
Improve JTAG reset, speed, and khz handlers to use parse_uint helper.
Modified: trunk/src/jtag/tcl.c
===================================================================
--- trunk/src/jtag/tcl.c 2009-06-12 01:40:29 UTC (rev 2212)
+++ trunk/src/jtag/tcl.c 2009-06-12 01:40:35 UTC (rev 2213)
@@ -971,7 +971,13 @@
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 @@
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 @@
{
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,9 +1029,13 @@
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;
}
int cur_speed;
|