aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-12 01:40:23 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-12 01:40:23 +0000
commitd5339d2eb49930a60bafc5908045303ee8ad3e00 (patch)
tree64c77235fce7ef8bd669fdc8c4fa4fbef33ffb83
parentf218f36df5ad401837a5a74d755174b1dc9023fe (diff)
downloadriscv-openocd-d5339d2eb49930a60bafc5908045303ee8ad3e00.zip
riscv-openocd-d5339d2eb49930a60bafc5908045303ee8ad3e00.tar.gz
riscv-openocd-d5339d2eb49930a60bafc5908045303ee8ad3e00.tar.bz2
Simplify and improve gw16012_handle_parport_command:
- Show the port number to the user when asking for it or setting it. - Print an error if the parport_port has already been set. - Use parse_u16 helper to ensure the parport_port string parses correctly. git-svn-id: svn://svn.berlios.de/openocd/trunk@2211 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r--src/jtag/gw16012.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/jtag/gw16012.c b/src/jtag/gw16012.c
index 0ea6634..b5fd288 100644
--- a/src/jtag/gw16012.c
+++ b/src/jtag/gw16012.c
@@ -571,12 +571,23 @@ static int gw16012_quit(void)
static int gw16012_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- if (argc == 0)
- return ERROR_OK;
+ if (argc == 1)
+ {
+ /* only if the port wasn't overwritten by cmdline */
+ if (gw16012_port == 0)
+ {
+ int retval = parse_u16(args[0], &gw16012_port);
+ if (ERROR_OK != retval)
+ return retval;
+ }
+ else
+ {
+ LOG_ERROR("The parport port was already configured!");
+ return ERROR_FAIL;
+ }
+ }
- /* only if the port wasn't overwritten by cmdline */
- if (gw16012_port == 0)
- gw16012_port = strtoul(args[0], NULL, 0);
+ command_print(cmd_ctx, "parport port = %u", gw16012_port);
return ERROR_OK;
}