flash_command_get_bank_by_num: make COMMAND_HELPER
authorZachary T Welch <zw@superlucidity.net>
Sun, 15 Nov 2009 14:48:20 +0000 (06:48 -0800)
committerZachary T Welch <zw@superlucidity.net>
Mon, 16 Nov 2009 16:44:38 +0000 (08:44 -0800)
Use COMMAND_HELPER macro to declare flash_command_get_bank_by_num.
This is required for COMMAND_PARSE_NUMBER macro.

src/flash/avrf.c
src/flash/flash.c
src/flash/flash.h
src/flash/lpc2000.c
src/flash/lpc2900.c
src/flash/pic32mx.c
src/flash/stellaris.c
src/flash/stm32x.c
src/flash/str7x.c
src/flash/str9x.c
src/flash/str9xpec.c

index e41093d..5d3c033 100644 (file)
@@ -426,7 +426,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
        }
 
        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)
                return retval;
 
index 20efa50..bdee53b 100644 (file)
@@ -198,11 +198,11 @@ struct flash_bank *get_flash_bank_by_num(int num)
        return p;
 }
 
-int flash_command_get_bank_by_num(
-       struct command_context *cmd_ctx, const char *str, struct flash_bank **bank)
+COMMAND_HELPER(flash_command_get_bank_by_num,
+       unsigned name_index, struct flash_bank **bank)
 {
        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);
        if (!*bank)
@@ -403,7 +403,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command)
        }
 
        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)
                return retval;
 
@@ -491,7 +491,7 @@ COMMAND_HANDLER(handle_flash_protect_check_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        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)
                return retval;
 
@@ -821,7 +821,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
        duration_start(&bench);
 
        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)
                return retval;
 
index 4651fc3..96a4120 100644 (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
  * the bank identifier or retreiving the specified bank.
- * @param cmd_ctx The command context for reporting errors.
- * @param str The string containing the bank identifier.
+ * @param name_index The index to the string in args containing the
+ * bank identifier.
  * @param bank On output, contians a pointer to the bank or NULL.
  * @returns ERROR_OK on success, or an error indicating the problem.
  */
-int flash_command_get_bank_by_num(struct command_context *cmd_ctx,
-               const char *str, struct flash_bank **bank);
+COMMAND_HELPER(flash_command_get_bank_by_num, unsigned name_index,
+               struct flash_bank **bank);
 /**
  * Returns the flash bank like get_flash_bank_by_num(), without probing.
  * @param num The flash bank number.
index 09bb13f..79f5804 100644 (file)
@@ -750,7 +750,7 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command)
        }
 
        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)
                return retval;
 
index 35f1507..b80079d 100644 (file)
@@ -544,7 +544,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
        }
 
        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)
                return retval;
 
@@ -589,7 +589,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
        }
 
        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)
                return retval;
 
@@ -660,7 +660,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
        }
 
        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)
                return retval;
 
@@ -695,7 +695,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
        }
 
        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)
                return retval;
 
@@ -806,7 +806,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
 
        /* Get the bank descriptor */
        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)
                return retval;
 
@@ -905,7 +905,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
 
        /* Get the bank descriptor */
        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)
                return retval;
 
index b6c4c44..51c42b5 100644 (file)
@@ -684,7 +684,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command)
        }
 
        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)
                return retval;
 
@@ -730,7 +730,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
        }
 
        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)
                return retval;
 
@@ -820,7 +820,7 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command)
        }
 
        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)
                return retval;
 
@@ -858,7 +858,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
        COMMAND_PARSE_NUMBER(u32, args[1], value);
 
        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)
                return retval;
 
index 7b94675..bbe4aef 100644 (file)
@@ -1139,7 +1139,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command)
        }
 
        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)
                return retval;
 
index 7072715..ab9831b 100644 (file)
@@ -905,7 +905,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
        }
 
        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)
                return retval;
 
@@ -951,7 +951,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
        }
 
        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)
                return retval;
 
@@ -995,7 +995,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command)
        }
 
        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)
                return retval;
 
@@ -1051,7 +1051,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
        }
 
        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)
                return retval;
 
@@ -1160,7 +1160,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
        }
 
        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)
                return retval;
 
index 19ee160..d851051 100644 (file)
@@ -618,7 +618,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command)
        }
 
        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)
                return retval;
 
index 870871c..4c4d8ae 100644 (file)
@@ -642,7 +642,7 @@ COMMAND_HANDLER(str9x_handle_flash_config_command)
        }
 
        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)
                return retval;
 
index d1b02c5..4bf5bca 100644 (file)
@@ -738,7 +738,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        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)
                return retval;
 
@@ -789,7 +789,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
        }
 
        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)
                return retval;
 
@@ -905,7 +905,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command)
        }
 
        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)
                return retval;
 
@@ -928,7 +928,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command)
        }
 
        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)
                return retval;
 
@@ -957,7 +957,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command)
        }
 
        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)
                return retval;
 
@@ -986,7 +986,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command)
        }
 
        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)
                return retval;
 
@@ -1015,7 +1015,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command)
        }
 
        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)
                return retval;
 
@@ -1044,7 +1044,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_lock_command)
        }
 
        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)
                return retval;
 
@@ -1067,7 +1067,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command)
        }
 
        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)
                return retval;
 
@@ -1093,7 +1093,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
        }
 
        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)
                return retval;
 
@@ -1140,7 +1140,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command)
        }
 
        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)
                return retval;