use CALL_COMMAND_HANDLER instead of direct calls
authorZachary T Welch <zw@superlucidity.net>
Wed, 11 Nov 2009 06:23:07 +0000 (22:23 -0800)
committerZachary T Welch <zw@superlucidity.net>
Fri, 13 Nov 2009 18:51:46 +0000 (10:51 -0800)
By using CALL_COMMAND_HANDLER, parameters can be reordered, added, or
even removed in inherited signatures, without requiring revisiting
all of the various call sites.

src/flash/flash.c
src/flash/nand.c
src/jtag/tcl.c
src/pld/pld.c
src/server/gdb_server.c
src/server/tcl_server.c
src/server/telnet_server.c
src/target/arm11.c
src/target/etm.c
src/target/target.c

index d3889b9..da43e1a 100644 (file)
@@ -259,7 +259,8 @@ COMMAND_HANDLER(handle_flash_bank_command)
                c->sectors = NULL;
                c->next = NULL;
 
-               if ((retval = flash_drivers[i]->flash_bank_command(cmd_ctx, cmd, args, argc, c)) != ERROR_OK)
+               retval = CALL_COMMAND_HANDLER(flash_drivers[i]->flash_bank_command, c);
+               if (ERROR_OK != retval)
                {
                        LOG_ERROR("'%s' driver rejected flash bank at 0x%8.8" PRIx32 , args[0], c->base);
                        free(c);
index 181700d..88d3e42 100644 (file)
@@ -241,7 +241,8 @@ COMMAND_HANDLER(handle_nand_device_command)
                        c->use_raw = 0;
                        c->next = NULL;
 
-                       if ((retval = nand_flash_controllers[i]->nand_device_command(cmd_ctx, cmd, args, argc, c)) != ERROR_OK)
+                       retval = CALL_COMMAND_HANDLER(nand_flash_controllers[i]->nand_device_command, c);
+                       if (ERROR_OK != retval)
                        {
                                LOG_ERROR("'%s' driver rejected nand flash", c->controller->name);
                                free(c);
index 653d3a7..4da8838 100644 (file)
@@ -658,7 +658,7 @@ COMMAND_HANDLER(handle_interface_command)
         * didn't match one of the compiled-in interfaces
         */
        LOG_ERROR("The specified JTAG interface was not found (%s)", args[0]);
-       handle_interface_list_command(cmd_ctx, cmd, args, argc);
+       CALL_COMMAND_HANDLER(handle_interface_list_command);
        return ERROR_JTAG_INVALID_INTERFACE;
 }
 
index c20b936..e8cd075 100644 (file)
@@ -85,7 +85,8 @@ COMMAND_HANDLER(handle_pld_device_command)
                        c->driver = pld_drivers[i];
                        c->next = NULL;
 
-                       if (pld_drivers[i]->pld_device_command(cmd_ctx, cmd, args, argc, c) != ERROR_OK)
+                       int retval = CALL_COMMAND_HANDLER(pld_drivers[i]->pld_device_command, c);
+                       if (ERROR_OK != retval)
                        {
                                LOG_ERROR("'%s' driver rejected pld device", args[0]);
                                free(c);
index c0c5d77..761ae40 100644 (file)
@@ -2271,7 +2271,7 @@ COMMAND_HANDLER(handle_gdb_sync_command)
 /* daemon configuration command gdb_port */
 COMMAND_HANDLER(handle_gdb_port_command)
 {
-       return server_port_command(cmd_ctx, cmd, args, argc, &gdb_port);
+       return CALL_COMMAND_HANDLER(server_port_command, &gdb_port);
 }
 
 COMMAND_HANDLER(handle_gdb_memory_map_command)
index 3410ca9..c8da5bc 100644 (file)
@@ -172,7 +172,7 @@ int tcl_init(void)
 
 COMMAND_HANDLER(handle_tcl_port_command)
 {
-       return server_port_command(cmd_ctx, cmd, args, argc, &tcl_port);
+       return CALL_COMMAND_HANDLER(server_port_command, &tcl_port);
 }
 
 int tcl_register_commands(command_context_t *cmd_ctx)
index c409ec0..6cb4746 100644 (file)
@@ -608,7 +608,7 @@ int telnet_init(char *banner)
 /* daemon configuration command telnet_port */
 COMMAND_HANDLER(handle_telnet_port_command)
 {
-       return server_port_command(cmd_ctx, cmd, args, argc, &telnet_port);
+       return CALL_COMMAND_HANDLER(server_port_command, &telnet_port);
 }
 
 COMMAND_HANDLER(handle_exit_command)
index 949c947..5b11f8e 100644 (file)
@@ -2029,7 +2029,8 @@ static COMMAND_HELPER(arm11_handle_bool, bool *var, char *name)
 #define BOOL_WRAPPER(name, print_name) \
 COMMAND_HANDLER(arm11_handle_bool_##name) \
 { \
-       return arm11_handle_bool(cmd_ctx, cmd, args, argc, &arm11_config_##name, print_name); \
+       return CALL_COMMAND_HANDLER(arm11_handle_bool, \
+                       &arm11_config_##name, print_name); \
 }
 
 BOOL_WRAPPER(memwrite_burst,                   "memory write burst mode")
@@ -2186,12 +2187,12 @@ static COMMAND_HELPER(arm11_handle_etm_read_write, bool read)
 
 COMMAND_HANDLER(arm11_handle_etmr)
 {
-       return arm11_handle_etm_read_write(cmd_ctx, cmd, args, argc, true);
+       return CALL_COMMAND_HANDLER(arm11_handle_etm_read_write, true);
 }
 
 COMMAND_HANDLER(arm11_handle_etmw)
 {
-       return arm11_handle_etm_read_write(cmd_ctx, cmd, args, argc, false);
+       return CALL_COMMAND_HANDLER(arm11_handle_etm_read_write, false);
 }
 
 #define ARM11_HANDLER(x)       .x = arm11_##x
index df02904..a4ff6c5 100644 (file)
@@ -1271,7 +1271,7 @@ COMMAND_HANDLER(handle_etm_tracemode_command)
        case 0:
                break;
        case 4:
-               handle_etm_tracemode_command_update(cmd_ctx, cmd, args, argc, &tracemode);
+               CALL_COMMAND_HANDLER(handle_etm_tracemode_command_update, &tracemode);
                break;
        default:
                command_print(cmd_ctx, "usage: configure trace mode "
index 26c20cf..21c0526 100644 (file)
@@ -2121,7 +2121,7 @@ COMMAND_HANDLER(handle_halt_command)
                        return ERROR_OK;
        }
 
-       return handle_wait_halt_command(cmd_ctx, cmd, args, argc);
+       return CALL_COMMAND_HANDLER(handle_wait_halt_command);
 }
 
 COMMAND_HANDLER(handle_soft_reset_halt_command)
@@ -2410,7 +2410,7 @@ COMMAND_HANDLER(handle_load_image_command)
        int i;
        image_t image;
 
-       int retval = parse_load_image_command_args(cmd_ctx, cmd, args, argc,
+       int retval = CALL_COMMAND_HANDLER(parse_load_image_command_args,
                        &image, &min_address, &max_address);
        if (ERROR_OK != retval)
                return retval;
@@ -2701,12 +2701,12 @@ done:
 
 COMMAND_HANDLER(handle_verify_image_command)
 {
-       return handle_verify_image_command_internal(cmd_ctx, cmd, args, argc, 1);
+       return CALL_COMMAND_HANDLER(handle_verify_image_command_internal, 1);
 }
 
 COMMAND_HANDLER(handle_test_image_command)
 {
-       return handle_verify_image_command_internal(cmd_ctx, cmd, args, argc, 0);
+       return CALL_COMMAND_HANDLER(handle_verify_image_command_internal, 0);
 }
 
 static int handle_bp_command_list(struct command_context_s *cmd_ctx)
@@ -4547,7 +4547,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
 
        image_t image;
 
-       int retval = parse_load_image_command_args(cmd_ctx, cmd, args, argc,
+       int retval = CALL_COMMAND_HANDLER(parse_load_image_command_args,
                        &image, &min_address, &max_address);
        if (ERROR_OK != retval)
                return retval;