Commit 7bf1a86e authored by Zachary T Welch's avatar Zachary T Welch
Browse files

command_handler: change to 'argc' to CMD_ARGC

This patch converts all instances of 'argc' in COMMAND_HANDLER routines
to use CMD_ARGC.
parent 5b9899d6
......@@ -2365,7 +2365,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
}
switch (argc) {
switch (CMD_ARGC) {
default:
command_print(cmd_ctx,"Too many parameters\n");
return ERROR_COMMAND_SYNTAX_ERROR;
......@@ -2438,7 +2438,7 @@ COMMAND_HANDLER(sam3_handle_slowclk_command)
}
switch (argc) {
switch (CMD_ARGC) {
case 0:
// show
break;
......
......@@ -743,7 +743,7 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
at91sam7_info->ext_freq = 0;
at91sam7_info->flash_autodetection = 0;
if (argc < 13)
if (CMD_ARGC < 13)
{
at91sam7_info->flash_autodetection = 1;
return ERROR_OK;
......@@ -760,7 +760,7 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
COMMAND_PARSE_NUMBER(u16, args[11], page_size);
COMMAND_PARSE_NUMBER(u16, args[12], num_nvmbits);
if (argc == 14) {
if (CMD_ARGC == 14) {
unsigned long freq;
COMMAND_PARSE_NUMBER(ulong, args[13], freq);
ext_freq = freq * 1000;
......@@ -1107,7 +1107,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
struct at91sam7_flash_bank *at91sam7_info;
int retval;
if (argc != 2)
if (CMD_ARGC != 2)
{
command_print(cmd_ctx, "at91sam7 gpnvm <bit> <set | clear>");
return ERROR_OK;
......
......@@ -184,7 +184,7 @@ FLASH_BANK_COMMAND_HANDLER(avrf_flash_bank_command)
{
struct avrf_flash_bank *avrf_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank avr configuration");
return ERROR_FLASH_BANK_INVALID;
......@@ -419,7 +419,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
{
int i;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "avr mass_erase <bank>");
return ERROR_OK;
......
......@@ -606,7 +606,7 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command)
{
struct cfi_flash_bank *cfi_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank cfi configuration");
return ERROR_FLASH_BANK_INVALID;
......@@ -633,7 +633,7 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command)
cfi_info->jedec_probe = 0;
cfi_info->not_cfi = 0;
for (unsigned i = 6; i < argc; i++)
for (unsigned i = 6; i < CMD_ARGC; i++)
{
if (strcmp(args[i], "x16_as_x8") == 0)
{
......
......@@ -645,7 +645,7 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
* - aemif address
* Plus someday, optionally, ALE and CLE masks.
*/
if (argc < 5) {
if (CMD_ARGC < 5) {
LOG_ERROR("parameters: %s target "
"chip_addr hwecc_mode aemif_addr",
args[0]);
......
......@@ -109,7 +109,7 @@ FLASH_BANK_COMMAND_HANDLER(ecosflash_flash_bank_command)
{
struct ecosflash_flash_bank *info;
if (argc < 7)
if (CMD_ARGC < 7)
{
LOG_WARNING("incomplete flash_bank ecosflash configuration");
return ERROR_FLASH_BANK_INVALID;
......
......@@ -41,7 +41,7 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command)
{
struct faux_flash_bank *info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank faux configuration");
return ERROR_FLASH_BANK_INVALID;
......
......@@ -222,7 +222,7 @@ COMMAND_HANDLER(handle_flash_bank_command)
int found = 0;
struct target *target;
if (argc < 6)
if (CMD_ARGC < 6)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -303,7 +303,7 @@ COMMAND_HANDLER(handle_flash_info_command)
int j = 0;
int retval;
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned bank_nr;
......@@ -362,7 +362,7 @@ COMMAND_HANDLER(handle_flash_probe_command)
{
int retval;
if (argc != 1)
if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -397,7 +397,7 @@ COMMAND_HANDLER(handle_flash_probe_command)
COMMAND_HANDLER(handle_flash_erase_check_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -450,7 +450,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
struct target *target = get_current_target(cmd_ctx);
if (argc != 2)
if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(int, args[0], address);
......@@ -487,7 +487,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
COMMAND_HANDLER(handle_flash_protect_check_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
struct flash_bank *p;
......@@ -531,7 +531,7 @@ static int flash_check_sector_parameters(struct command_context *cmd_ctx,
COMMAND_HANDLER(handle_flash_erase_command)
{
if (argc != 2)
if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
......@@ -571,7 +571,7 @@ COMMAND_HANDLER(handle_flash_erase_command)
COMMAND_HANDLER(handle_flash_protect_command)
{
if (argc != 3)
if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
......@@ -622,7 +622,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
int retval;
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -637,13 +637,13 @@ COMMAND_HANDLER(handle_flash_write_image_command)
{
auto_erase = 1;
args++;
argc--;
CMD_ARGC--;
command_print(cmd_ctx, "auto erase enabled");
} else if (strcmp(args[0], "unlock") == 0)
{
auto_unlock = true;
args++;
argc--;
CMD_ARGC--;
command_print(cmd_ctx, "auto unlock enabled");
} else
{
......@@ -651,7 +651,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
}
}
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -665,7 +665,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
struct duration bench;
duration_start(&bench);
if (argc >= 2)
if (CMD_ARGC >= 2)
{
image.base_address_set = 1;
COMMAND_PARSE_NUMBER(int, args[1], image.base_address);
......@@ -678,7 +678,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
image.start_address_set = 0;
retval = image_open(&image, args[0], (argc == 3) ? args[2] : NULL);
retval = image_open(&image, args[0], (CMD_ARGC == 3) ? args[2] : NULL);
if (retval != ERROR_OK)
{
return retval;
......@@ -718,7 +718,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
uint32_t i;
uint32_t wordsize;
if (argc != 3)
if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(u32, args[0], address);
......@@ -813,7 +813,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
uint8_t *buffer;
struct fileio fileio;
if (argc != 3)
if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
struct duration bench;
......
......@@ -118,7 +118,7 @@ struct flash_driver
*
* For example, args[4] = 16 bit flash, args[5] = 32bit bus.
*
* If extra arguments are provided (@a argc > 6), they will
* If extra arguments are provided (@a CMD_ARGC > 6), they will
* start in @a args[6]. These can be used to implement
* driver-specific extensions.
*
......
......@@ -424,7 +424,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command)
{
struct lpc2000_flash_bank *lpc2000_info;
if (argc < 8)
if (CMD_ARGC < 8)
{
LOG_WARNING("incomplete flash_bank lpc2000 configuration");
return ERROR_FLASH_BANK_INVALID;
......@@ -469,7 +469,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command)
lpc2000_info->calc_checksum = 0;
lpc2000_build_sector_list(bank);
if (argc >= 9)
if (CMD_ARGC >= 9)
{
if (strcmp(args[8], "calc_checksum") == 0)
lpc2000_info->calc_checksum = 1;
......@@ -744,7 +744,7 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command)
uint32_t result_table[4];
int status_code;
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......
......@@ -169,7 +169,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc288x_flash_bank_command)
{
struct lpc288x_flash_bank *lpc288x_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank LPC288x configuration");
return ERROR_FLASH_BANK_INVALID;
......
......@@ -537,7 +537,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
uint32_t signature[4];
if( argc < 1 )
if( CMD_ARGC < 1 )
{
LOG_WARNING( "Too few arguments. Call: lpc2900 signature <bank#>" );
return ERROR_FLASH_BANK_INVALID;
......@@ -583,7 +583,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
*/
COMMAND_HANDLER(lpc2900_handle_read_custom_command)
{
if( argc < 2 )
if( CMD_ARGC < 2 )
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -654,7 +654,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
*/
COMMAND_HANDLER(lpc2900_handle_password_command)
{
if (argc < 2)
if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -689,7 +689,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
*/
COMMAND_HANDLER(lpc2900_handle_write_custom_command)
{
if (argc < 2)
if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -724,7 +724,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
image.start_address_set = 0;
const char *filename = args[1];
const char *type = (argc >= 3) ? args[2] : NULL;
const char *type = (CMD_ARGC >= 3) ? args[2] : NULL;
retval = image_open(&image, filename, type);
if (retval != ERROR_OK)
{
......@@ -799,7 +799,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
*/
COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
{
if (argc < 3)
if (CMD_ARGC < 3)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -898,7 +898,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
*/
COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
{
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -1020,7 +1020,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command)
{
struct lpc2900_flash_bank *lpc2900_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank LPC2900 configuration");
return ERROR_FLASH_BANK_INVALID;
......
......@@ -31,7 +31,7 @@ static int lpc3180_controller_ready(struct nand_device *nand, int timeout);
*/
NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command)
{
if (argc < 3)
if (CMD_ARGC < 3)
{
LOG_WARNING("incomplete 'lpc3180' nand flash configuration");
return ERROR_FLASH_BANK_INVALID;
......@@ -836,7 +836,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command)
"no", "mlc", "slc"
};
if ((argc < 1) || (argc > 2))
if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -852,7 +852,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command)
lpc3180_info = nand->controller_priv;
if (argc == 2)
if (CMD_ARGC == 2)
{
if (strcmp(args[1], "mlc") == 0)
{
......
......@@ -710,7 +710,7 @@ COMMAND_HANDLER(mg_write_cmd)
struct fileio fileio;
int ret;
if (argc != 3) {
if (CMD_ARGC != 3) {
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -775,7 +775,7 @@ COMMAND_HANDLER(mg_dump_cmd)
struct fileio fileio;
int ret;
if (argc != 4) {
if (CMD_ARGC != 4) {
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -1223,7 +1223,7 @@ COMMAND_HANDLER(mg_config_cmd)
if ((ret = mg_mflash_rst()) != ERROR_OK)
return ret;
switch (argc) {
switch (CMD_ARGC) {
case 2:
if (!strcmp(args[1], "boot"))
return mg_boot_config();
......@@ -1288,7 +1288,7 @@ COMMAND_HANDLER(mg_bank_cmd)
struct target *target;
int i;
if (argc < 4)
if (CMD_ARGC < 4)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......
......@@ -79,7 +79,7 @@ NAND_DEVICE_COMMAND_HANDLER(imx31_nand_device_command)
LOG_ERROR ("target '%s' not defined", args[1]);
return ERROR_FAIL;
}
if (argc < 3)
if (CMD_ARGC < 3)
{
LOG_ERROR ("use \"nand device imx31 target noecc|hwecc\"");
return ERROR_FAIL;
......
......@@ -210,7 +210,7 @@ COMMAND_HANDLER(handle_nand_device_command)
int i;
int retval;
if (argc < 1)
if (CMD_ARGC < 1)
{
LOG_WARNING("incomplete flash device nand configuration");
return ERROR_FLASH_BANK_INVALID;
......@@ -1082,7 +1082,7 @@ COMMAND_HANDLER(handle_nand_info_command)
if (ERROR_OK != retval)
return retval;
switch (argc) {
switch (CMD_ARGC) {
default:
return ERROR_COMMAND_SYNTAX_ERROR;
case 1:
......@@ -1147,7 +1147,7 @@ COMMAND_HANDLER(handle_nand_info_command)
COMMAND_HANDLER(handle_nand_probe_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -1175,7 +1175,7 @@ COMMAND_HANDLER(handle_nand_probe_command)
COMMAND_HANDLER(handle_nand_erase_command)
{
if (argc != 1 && argc != 3)
if (CMD_ARGC != 1 && CMD_ARGC != 3)
{
return ERROR_COMMAND_SYNTAX_ERROR;
......@@ -1190,7 +1190,7 @@ COMMAND_HANDLER(handle_nand_erase_command)
unsigned long length;
/* erase specified part of the chip; or else everything */
if (argc == 3) {
if (CMD_ARGC == 3) {
unsigned long size = p->erase_size * p->num_blocks;
COMMAND_PARSE_NUMBER(ulong, args[1], offset);
......@@ -1234,7 +1234,7 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
int first = -1;
int last = -1;
if ((argc < 1) || (argc > 3) || (argc == 2))
if ((CMD_ARGC < 1) || (CMD_ARGC > 3) || (CMD_ARGC == 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
......@@ -1245,7 +1245,7 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
if (ERROR_OK != retval)
return retval;
if (argc == 3)
if (CMD_ARGC == 3)
{
unsigned long offset;
unsigned long length;
......@@ -1389,7 +1389,7 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
nand_fileio_init(state);
unsigned minargs = need_size ? 4 : 3;
if (argc < minargs)
if (CMD_ARGC < minargs)
return ERROR_COMMAND_SYNTAX_ERROR;
struct nand_device *nand;
......@@ -1414,9 +1414,9 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
}
}
if (argc > minargs)
if (CMD_ARGC > minargs)
{
for (unsigned i = minargs; i < argc; i++)
for (unsigned i = minargs; i < CMD_ARGC; i++)
{
if (!strcmp(args[i], "oob_raw"))
state->oob_format |= NAND_OOB_RAW;
......@@ -1646,7 +1646,7 @@ COMMAND_HANDLER(handle_nand_dump_command)
COMMAND_HANDLER(handle_nand_raw_access_command)
{
if ((argc < 1) || (argc > 2))
if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -1662,7 +1662,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command)
return ERROR_OK;
}
if (argc == 2)
if (CMD_ARGC == 2)
{
if (strcmp("enable", args[1]) == 0)
p->use_raw = 1;
......
......@@ -49,7 +49,7 @@ FLASH_BANK_COMMAND_HANDLER(ocl_flash_bank_command)
struct arm7_9_common *arm7_9;
struct ocl_priv *ocl;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank ocl configuration");
return ERROR_FLASH_BANK_INVALID;
......
......@@ -131,7 +131,7 @@ NAND_DEVICE_COMMAND_HANDLER(orion_nand_device_command)
uint32_t base;
uint8_t ale, cle;
if (argc != 3) {
if (CMD_ARGC != 3) {
LOG_ERROR("arguments must be: <target_id> <NAND_address>\n");
return ERROR_NAND_DEVICE_INVALID;
}
......
......@@ -66,7 +66,7 @@ FLASH_BANK_COMMAND_HANDLER(pic32mx_flash_bank_command)
{
struct pic32mx_flash_bank *pic32mx_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank pic32mx configuration");
return ERROR_FLASH_BANK_INVALID;
......@@ -677,7 +677,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command)
struct target *target = NULL;
struct pic32mx_flash_bank *pic32mx_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "pic32mx lock <bank>");
return ERROR_OK;
......@@ -723,7 +723,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
struct target *target = NULL;
struct pic32mx_flash_bank *pic32mx_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "pic32mx unlock <bank>");
return ERROR_OK;
......@@ -813,7 +813,7 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command)
#if 0
int i;
if (argc != 0)
if (CMD_ARGC != 0)
{
command_print(cmd_ctx, "pic32mx chip_erase");
return ERROR_OK;
......@@ -848,7 +848,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
uint32_t address, value;
int status, res;
if (argc != 3)
if (CMD_ARGC != 3)
{
command_print(cmd_ctx, "pic32mx pgm_word <addr> <value> <bank>");
return ERROR_OK;
......
......@@ -218,7 +218,7 @@ FLASH_BANK_COMMAND_HANDLER(stellaris_flash_bank_command)
{
struct stellaris_flash_bank *stellaris_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank stellaris configuration");
return ERROR_FLASH_BANK_INVALID;
......@@ -1132,7 +1132,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command)
{
int i;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stellaris mass_erase <bank>");
return ERROR_OK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment