flash_command_get_bank_by_num: make COMMAND_HELPER

Use COMMAND_HELPER macro to declare flash_command_get_bank_by_num.
This is required for COMMAND_PARSE_NUMBER macro.
__archive__
Zachary T Welch 2009-11-15 06:48:20 -08:00
parent d7a0dfa4dc
commit e84849f5ed
11 changed files with 41 additions and 41 deletions

View File

@ -426,7 +426,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -198,11 +198,11 @@ struct flash_bank *get_flash_bank_by_num(int num)
return p; return p;
} }
int flash_command_get_bank_by_num( COMMAND_HELPER(flash_command_get_bank_by_num,
struct command_context *cmd_ctx, const char *str, struct flash_bank **bank) unsigned name_index, struct flash_bank **bank)
{ {
unsigned bank_num; unsigned bank_num;
COMMAND_PARSE_NUMBER(uint, str, bank_num); COMMAND_PARSE_NUMBER(uint, args[name_index], bank_num);
*bank = get_flash_bank_by_num(bank_num); *bank = get_flash_bank_by_num(bank_num);
if (!*bank) if (!*bank)
@ -403,7 +403,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command)
} }
struct flash_bank *p; struct flash_bank *p;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &p); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -491,7 +491,7 @@ COMMAND_HANDLER(handle_flash_protect_check_command)
return ERROR_COMMAND_SYNTAX_ERROR; return ERROR_COMMAND_SYNTAX_ERROR;
struct flash_bank *p; struct flash_bank *p;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &p); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -821,7 +821,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
duration_start(&bench); duration_start(&bench);
struct flash_bank *p; struct flash_bank *p;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &p); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -318,13 +318,13 @@ struct flash_bank *get_flash_bank_by_num(int num);
/** /**
* Retreives @a bank from a command argument, reporting errors parsing * Retreives @a bank from a command argument, reporting errors parsing
* the bank identifier or retreiving the specified bank. * the bank identifier or retreiving the specified bank.
* @param cmd_ctx The command context for reporting errors. * @param name_index The index to the string in args containing the
* @param str The string containing the bank identifier. * bank identifier.
* @param bank On output, contians a pointer to the bank or NULL. * @param bank On output, contians a pointer to the bank or NULL.
* @returns ERROR_OK on success, or an error indicating the problem. * @returns ERROR_OK on success, or an error indicating the problem.
*/ */
int flash_command_get_bank_by_num(struct command_context *cmd_ctx, COMMAND_HELPER(flash_command_get_bank_by_num, unsigned name_index,
const char *str, struct flash_bank **bank); struct flash_bank **bank);
/** /**
* Returns the flash bank like get_flash_bank_by_num(), without probing. * Returns the flash bank like get_flash_bank_by_num(), without probing.
* @param num The flash bank number. * @param num The flash bank number.

View File

@ -750,7 +750,7 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -544,7 +544,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -589,7 +589,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -660,7 +660,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -695,7 +695,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -806,7 +806,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
/* Get the bank descriptor */ /* Get the bank descriptor */
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -905,7 +905,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
/* Get the bank descriptor */ /* Get the bank descriptor */
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -684,7 +684,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -730,7 +730,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -820,7 +820,7 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -858,7 +858,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
COMMAND_PARSE_NUMBER(u32, args[1], value); COMMAND_PARSE_NUMBER(u32, args[1], value);
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[2], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 2, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -1139,7 +1139,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -905,7 +905,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -951,7 +951,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -995,7 +995,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -1051,7 +1051,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -1160,7 +1160,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -618,7 +618,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -642,7 +642,7 @@ COMMAND_HANDLER(str9x_handle_flash_config_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;

View File

@ -738,7 +738,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
return ERROR_COMMAND_SYNTAX_ERROR; return ERROR_COMMAND_SYNTAX_ERROR;
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -789,7 +789,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -905,7 +905,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -928,7 +928,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -957,7 +957,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -986,7 +986,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -1015,7 +1015,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -1044,7 +1044,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_lock_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -1067,7 +1067,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -1093,7 +1093,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;
@ -1140,7 +1140,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command)
} }
struct flash_bank *bank; struct flash_bank *bank;
int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
if (ERROR_OK != retval) if (ERROR_OK != retval)
return retval; return retval;