Commit 16b6b5e7 authored by Mathias K's avatar Mathias K Committed by Øyvind Harboe
Browse files

Change return value on error.



On wrong parameters a error is signalized to the calling function.

Change-Id: I484443fdb39938e20382edc9246d5ec546a5c960
Signed-off-by: default avatarMathias K <kesmtp@freenet.de>
Signed-off-by: default avatarØyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/282


Tested-by: jenkins
Reviewed-by: default avatarØyvind Harboe <oyvindharboe@gmail.com>
parent 42cb62cf
......@@ -689,10 +689,7 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
* Plus someday, optionally, ALE and CLE masks.
*/
if (CMD_ARGC < 5) {
LOG_ERROR("parameters: %s target "
"chip_addr hwecc_mode aemif_addr",
CMD_ARGV[0]);
goto fail;
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], chip);
......@@ -783,6 +780,7 @@ fail:
struct nand_flash_controller davinci_nand_controller = {
.name = "davinci",
.usage = "chip_addr hwecc_mode aemif_addr",
.nand_device_command = davinci_nand_device_command,
.init = davinci_init,
.reset = davinci_reset,
......
......@@ -45,8 +45,7 @@ NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command)
{
if (CMD_ARGC < 3)
{
LOG_WARNING("incomplete 'lpc3180' nand flash configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
uint32_t osc_freq;
......
......@@ -75,8 +75,7 @@ static dmac_ll_t dmalist[(2048/256) * 2 + 1];
NAND_DEVICE_COMMAND_HANDLER(lpc32xx_nand_device_command)
{
if (CMD_ARGC < 3) {
LOG_WARNING("incomplete 'lpc32xx' nand flash configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
uint32_t osc_freq;
......
......@@ -76,8 +76,7 @@ NAND_DEVICE_COMMAND_HANDLER(imx31_nand_device_command)
if (CMD_ARGC < 3)
{
LOG_ERROR ("use \"nand device imx31 target noecc|hwecc\"");
return ERROR_FAIL;
return ERROR_COMMAND_SYNTAX_ERROR;
}
/*
* check hwecc requirements
......@@ -851,6 +850,7 @@ static int do_data_output (struct nand_device *nand)
struct nand_flash_controller imx31_nand_flash_controller = {
.name = "imx31",
.usage = "nand device imx31 target noecc|hwecc",
.nand_device_command = &imx31_nand_device_command,
.init = &imx31_init,
.reset = &imx31_reset,
......
......@@ -121,8 +121,7 @@ NAND_DEVICE_COMMAND_HANDLER(orion_nand_device_command)
uint8_t ale, cle;
if (CMD_ARGC != 3) {
LOG_ERROR("arguments must be: <target_id> <NAND_address>");
return ERROR_NAND_DEVICE_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
hw = calloc(1, sizeof(*hw));
......@@ -156,6 +155,7 @@ static int orion_nand_init(struct nand_device *nand)
struct nand_flash_controller orion_nand_controller =
{
.name = "orion",
.usage = "<target_id> <NAND_address>",
.command = orion_nand_command,
.address = orion_nand_address,
.read_data = orion_nand_read,
......
......@@ -3117,7 +3117,6 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
switch (CMD_ARGC) {
default:
command_print(CMD_CTX,"Too many parameters\n");
return ERROR_COMMAND_SYNTAX_ERROR;
break;
case 0:
......
......@@ -1203,8 +1203,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
if (CMD_ARGC != 2)
{
command_print(CMD_CTX, "at91sam7 gpnvm <bit> <set | clear>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
bank = get_flash_bank_by_num_noprobe(0);
......@@ -1295,6 +1294,7 @@ static const struct command_registration at91sam7_command_handlers[] = {
struct flash_driver at91sam7_flash = {
.name = "at91sam7",
.usage = "gpnvm <bit> <set | clear>",
.commands = at91sam7_command_handlers,
.flash_bank_command = at91sam7_flash_bank_command,
.erase = at91sam7_erase,
......
......@@ -191,8 +191,7 @@ FLASH_BANK_COMMAND_HANDLER(avrf_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank avr configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
avrf_info = malloc(sizeof(struct avrf_flash_bank));
......@@ -451,8 +450,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
if (CMD_ARGC < 1)
{
command_print(CMD_CTX, "avr mass_erase <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -482,6 +480,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
static const struct command_registration avrf_exec_command_handlers[] = {
{
.name = "mass_erase",
.usage = "<bank>",
.handler = avrf_handle_mass_erase_command,
.mode = COMMAND_EXEC,
.help = "erase entire device",
......
......@@ -818,8 +818,7 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank cfi configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
/* both widths must:
......
......@@ -111,8 +111,7 @@ FLASH_BANK_COMMAND_HANDLER(ecosflash_flash_bank_command)
if (CMD_ARGC < 7)
{
LOG_WARNING("incomplete flash_bank ecosflash configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
info = malloc(sizeof(struct ecosflash_flash_bank));
......
......@@ -104,8 +104,7 @@ FLASH_BANK_COMMAND_HANDLER(em357_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank em357 configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
em357_info = malloc(sizeof(struct em357_flash_bank));
......@@ -768,8 +767,7 @@ COMMAND_HANDLER(em357_handle_lock_command)
if (CMD_ARGC < 1)
{
command_print(CMD_CTX, "em357 lock <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -813,8 +811,7 @@ COMMAND_HANDLER(em357_handle_unlock_command)
if (CMD_ARGC < 1)
{
command_print(CMD_CTX, "em357 unlock <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -892,8 +889,7 @@ COMMAND_HANDLER(em357_handle_mass_erase_command)
if (CMD_ARGC < 1)
{
command_print(CMD_CTX, "em357 mass_erase <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -923,23 +919,23 @@ COMMAND_HANDLER(em357_handle_mass_erase_command)
static const struct command_registration em357_exec_command_handlers[] = {
{
.name = "lock",
.usage = "<bank>",
.handler = em357_handle_lock_command,
.mode = COMMAND_EXEC,
.usage = "bank_id",
.help = "Lock entire flash device.",
},
{
.name = "unlock",
.usage = "<bank>",
.handler = em357_handle_unlock_command,
.mode = COMMAND_EXEC,
.usage = "bank_id",
.help = "Unlock entire protected flash device.",
},
{
.name = "mass_erase",
.usage = "<bank>",
.handler = em357_handle_mass_erase_command,
.mode = COMMAND_EXEC,
.usage = "bank_id",
.help = "Erase entire flash device.",
},
COMMAND_REGISTRATION_DONE
......
......@@ -44,8 +44,7 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank faux configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
info = malloc(sizeof(struct faux_flash_bank));
......
......@@ -69,8 +69,7 @@ FLASH_BANK_COMMAND_HANDLER(fm3_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank fm3 configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
fm3_info = malloc(sizeof(struct fm3_flash_bank));
......@@ -847,8 +846,7 @@ COMMAND_HANDLER(fm3_handle_chip_erase_command)
if (CMD_ARGC < 1)
{
command_print(CMD_CTX, "fm3 chip_erase <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -875,9 +873,9 @@ COMMAND_HANDLER(fm3_handle_chip_erase_command)
static const struct command_registration fm3_exec_command_handlers[] = {
{
.name = "chip_erase",
.usage = "<bank>",
.handler = fm3_handle_chip_erase_command,
.mode = COMMAND_EXEC,
.usage = "bank_id",
.help = "Erase entire Flash device.",
},
COMMAND_REGISTRATION_DONE
......
......@@ -70,9 +70,7 @@ FLASH_BANK_COMMAND_HANDLER(kinetis_flash_bank_command)
struct kinetis_flash_bank *bank_info;
if (CMD_ARGC < 6) {
LOG_ERROR("incomplete flash_bank kinetis configuration %d",
CMD_ARGC);
return ERROR_FLASH_OPERATION_FAILED;
return ERROR_COMMAND_SYNTAX_ERROR;
}
LOG_INFO("add flash_bank kinetis %s", bank->name);
......
......@@ -481,8 +481,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command)
if (CMD_ARGC < 8)
{
LOG_WARNING("incomplete flash_bank lpc2000 configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
lpc2000_info = malloc(sizeof(struct lpc2000_flash_bank));
......
......@@ -184,8 +184,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc288x_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank LPC288x configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
lpc288x_info = malloc(sizeof(struct lpc288x_flash_bank));
......
......@@ -542,8 +542,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
if( CMD_ARGC < 1 )
{
LOG_WARNING( "Too few arguments. Call: lpc2900 signature <bank#>" );
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -954,9 +953,9 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
static const struct command_registration lpc2900_exec_command_handlers[] = {
{
.name = "signature",
.usage = "<bank>",
.handler = lpc2900_handle_signature_command,
.mode = COMMAND_EXEC,
.usage = "bank_id",
.help = "Calculate and display signature of flash bank.",
},
{
......@@ -1017,8 +1016,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank LPC2900 configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
lpc2900_info = malloc(sizeof(struct lpc2900_flash_bank));
......
......@@ -51,8 +51,7 @@ FLASH_BANK_COMMAND_HANDLER(ocl_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank ocl configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
arm7_9 = target_to_arm7_9(bank->target);
......
......@@ -172,8 +172,7 @@ FLASH_BANK_COMMAND_HANDLER(pic32mx_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank pic32mx configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
pic32mx_info = malloc(sizeof(struct pic32mx_flash_bank));
......@@ -737,8 +736,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
if (CMD_ARGC != 3)
{
command_print(CMD_CTX, "pic32mx pgm_word <addr> <value> <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address);
......@@ -781,7 +779,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
if (CMD_ARGC < 1)
{
command_print(CMD_CTX, "pic32mx unlock <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -837,6 +835,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
static const struct command_registration pic32mx_exec_command_handlers[] = {
{
.name = "pgm_word",
.usage = "<addr> <value> <bank>",
.handler = pic32mx_handle_pgm_word_command,
.mode = COMMAND_EXEC,
.help = "program a word",
......
......@@ -438,8 +438,7 @@ FLASH_BANK_COMMAND_HANDLER(stellaris_flash_bank_command)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank stellaris configuration");
return ERROR_FLASH_BANK_INVALID;
return ERROR_COMMAND_SYNTAX_ERROR;
}
stellaris_info = calloc(sizeof(struct stellaris_flash_bank), 1);
......@@ -1351,8 +1350,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command)
if (CMD_ARGC < 1)
{
command_print(CMD_CTX, "stellaris mass_erase <bank>");
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
......@@ -1439,9 +1437,9 @@ done:
static const struct command_registration stellaris_exec_command_handlers[] = {
{
.name = "mass_erase",
.usage = "<bank>",
.handler = stellaris_handle_mass_erase_command,
.mode = COMMAND_EXEC,
.usage = "bank_id",
.help = "erase entire device",
},
{
......
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