diff options
author | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-06-12 01:40:17 +0000 |
---|---|---|
committer | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-06-12 01:40:17 +0000 |
commit | f218f36df5ad401837a5a74d755174b1dc9023fe (patch) | |
tree | ca776d0a97f1077bc88bd830ec46db4b8bab1ab2 /src | |
parent | ae28b96ab9824474a8f5a808480fee3fe7db1f3a (diff) | |
download | riscv-openocd-f218f36df5ad401837a5a74d755174b1dc9023fe.zip riscv-openocd-f218f36df5ad401837a5a74d755174b1dc9023fe.tar.gz riscv-openocd-f218f36df5ad401837a5a74d755174b1dc9023fe.tar.bz2 |
Simplify and improve amt_jtagaccel_handle_parport_port_command:
- Show the port number to the user when asking for it or setting it.
- Print an error if the amt_jtagaccel_port has already been set.
- Use parse_u16 helper to ensure amt_jtagaccel_port string parses correctly.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2210 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r-- | src/jtag/amt_jtagaccel.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/jtag/amt_jtagaccel.c b/src/jtag/amt_jtagaccel.c index 7d0dd53..c7524cc 100644 --- a/src/jtag/amt_jtagaccel.c +++ b/src/jtag/amt_jtagaccel.c @@ -526,14 +526,26 @@ static int amt_jtagaccel_quit(void) return ERROR_OK; } -static int amt_jtagaccel_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int amt_jtagaccel_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 (amt_jtagaccel_port == 0) + { + int retval = parse_u16(args[0], &amt_jtagaccel_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 (amt_jtagaccel_port == 0) - amt_jtagaccel_port = strtoul(args[0], NULL, 0); + command_print(cmd_ctx, "parport port = %u", amt_jtagaccel_port); return ERROR_OK; } |