Add Flash/NAND bank command argument helpers.

This eliminates redundant code for parsing and retreiving the bank
specified from a script command argument.  This patch was written to
replace existing functionality; however, the parsing logic can be
updated later to allow flash commands to accept bank names as well as
their numbers.
This commit is contained in:
Zachary T Welch
2009-10-23 01:13:19 -07:00
parent 4189fdad28
commit 11e545f560
4 changed files with 45 additions and 0 deletions

View File

@@ -255,6 +255,23 @@ flash_bank_t *get_flash_bank_by_num(int num)
return p;
}
int flash_command_get_bank_by_num(
struct command_context_s *cmd_ctx, char *str, flash_bank_t **bank)
{
unsigned bank_num;
COMMAND_PARSE_NUMBER(uint, str, bank_num);
*bank = get_flash_bank_by_num(bank_num);
if (!*bank)
{
command_print(cmd_ctx,
"flash bank '#%u' not found", bank_num);
return ERROR_INVALID_ARGUMENTS;
}
return ERROR_OK;
}
static int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
int retval;