Change return value on error.
[fw/openocd] / src / flash / nor / stellaris.c
index 3508beabdbee5eee8711b272bb0241480dfa4eee..c855995f7d8129377f4efc0ee291f9f67bc73800 100644 (file)
@@ -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);
@@ -514,7 +513,7 @@ static int get_stellaris_info(struct flash_bank *bank, char *buf, int buf_size)
 
        if (stellaris_info->num_lockbits > 0)
        {
-               printed = snprintf(buf,
+               snprintf(buf,
                                buf_size,
                                "pagesize: %" PRIi32 ", pages: %d, "
                                "lockbits: %i, pages per lockbit: %i\n",
@@ -522,8 +521,6 @@ static int get_stellaris_info(struct flash_bank *bank, char *buf, int buf_size)
                                (unsigned) stellaris_info->num_pages,
                                stellaris_info->num_lockbits,
                                (unsigned) stellaris_info->pages_in_lockregion);
-               buf += printed;
-               buf_size -= printed;
        }
        return ERROR_OK;
 }
@@ -899,7 +896,7 @@ static int stellaris_protect(struct flash_bank *bank, int set, int first, int la
        {
                LOG_ERROR("Hardware doesn't support page-level unprotect. "
                        "Try the 'recover' command.");
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        if (stellaris_info->did1 == 0)
@@ -1353,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;
@@ -1441,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",
        },
        {