]> git.sur5r.net Git - openocd/commitdiff
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 e41093de380c0a51ef85cc6b2d147a70e1c52a16..5d3c033d80b6ca3670add6a2544ffead8358f6e3 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 20efa502e84cc085c6272df65dab6e19c43ef95d..bdee53b626fea28f70f632f27a72dadf6ed6e14e 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 4651fc3664175cf4fb067f990d39990920e014b2..96a41207e04cfc5cfdcf6a3835c988e7384e2104 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 09bb13f211b045c41432ce6600f8610c3a01a8ff..79f580458f4b5780c759cdf7f61ab42f598bf138 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 35f15070a78217e7fe4e74a28b5df27b0aaf2481..b80079df00e5d8c180399ff991e5cca9ce530ccf 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 b6c4c440f4112ed99aee6317d857b4e923c11acd..51c42b59d9cce23dde6759097977de63665ea811 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 7b94675457ff39ecceca5be7604d802691cdf1d5..bbe4aef92b308401d9d2edd2492590a3657aa18a 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 70727158bbf386e1516cdfcb6bcaab1297b7314a..ab9831b981b8ad162146088ad721e75d8ff5d4e0 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 19ee160ea82116925560a499d4a3b906a25e3a5e..d8510511087911479e99d3232d06ed2ac8cbd86b 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 870871cc7a19dc165c6f4da3d726c4fe4bad23ff..4c4d8ae7ff11ce5ab0d19087cb632532e42246a2 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 d1b02c5e24e191e4ab736e0b880a90393d0f3529..4bf5bcaec49c12625af577143f50788c7460bc84 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;