summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-23 08:24:02 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-24 21:37:36 -0800
commitf74e2e033a2ad082e5bef67d0ddedd1db3f58300 (patch)
tree8f0e521332a6685085a38cd70660bf8f308060a4 /src
parent66ee303456910f684244a20a0ac2e958d40b78cb (diff)
downloadopenocd_libswd-f74e2e033a2ad082e5bef67d0ddedd1db3f58300.tar.gz
openocd_libswd-f74e2e033a2ad082e5bef67d0ddedd1db3f58300.tar.bz2
openocd_libswd-f74e2e033a2ad082e5bef67d0ddedd1db3f58300.tar.xz
openocd_libswd-f74e2e033a2ad082e5bef67d0ddedd1db3f58300.zip
remove register_commands from etm_capture_driver
Converts callback to an array of command_registration records. Moves oocd_trace driver definition to end of file to eliminate useless forward declaration.
Diffstat (limited to 'src')
-rw-r--r--src/target/etb.c7
-rw-r--r--src/target/etm.c5
-rw-r--r--src/target/etm.h2
-rw-r--r--src/target/etm_dummy.c7
-rw-r--r--src/target/oocd_trace.c27
5 files changed, 17 insertions, 31 deletions
diff --git a/src/target/etb.c b/src/target/etb.c
index 63dee18b..bc0e1bf2 100644
--- a/src/target/etb.c
+++ b/src/target/etb.c
@@ -421,11 +421,6 @@ static const struct command_registration etb_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
-static int etb_register_commands(struct command_context *cmd_ctx)
-{
- return register_commands(cmd_ctx, NULL, etb_command_handlers);
-}
-
static int etb_init(struct etm_context *etm_ctx)
{
struct etb *etb = etm_ctx->capture_driver_priv;
@@ -696,7 +691,7 @@ static int etb_stop_capture(struct etm_context *etm_ctx)
struct etm_capture_driver etb_capture_driver =
{
.name = "etb",
- .register_commands = etb_register_commands,
+ .commands = etb_command_handlers,
.init = etb_init,
.status = etb_status,
.start_capture = etb_start_capture,
diff --git a/src/target/etm.c b/src/target/etm.c
index 2465d5c1..4e7f9172 100644
--- a/src/target/etm.c
+++ b/src/target/etm.c
@@ -1471,8 +1471,9 @@ COMMAND_HANDLER(handle_etm_config_command)
{
if (strcmp(CMD_ARGV[4], etm_capture_drivers[i]->name) == 0)
{
- int retval;
- if ((retval = etm_capture_drivers[i]->register_commands(CMD_CTX)) != ERROR_OK)
+ int retval = register_commands(CMD_CTX, NULL,
+ etm_capture_drivers[i]->commands);
+ if (ERROR_OK != retval)
{
free(etm_ctx);
return retval;
diff --git a/src/target/etm.h b/src/target/etm.h
index 05e54959..c8da7947 100644
--- a/src/target/etm.h
+++ b/src/target/etm.h
@@ -126,7 +126,7 @@ struct etm_context;
struct etm_capture_driver
{
char *name;
- int (*register_commands)(struct command_context *cmd_ctx);
+ const struct command_registration *commands;
int (*init)(struct etm_context *etm_ctx);
trace_status_t (*status)(struct etm_context *etm_ctx);
int (*read_trace)(struct etm_context *etm_ctx);
diff --git a/src/target/etm_dummy.c b/src/target/etm_dummy.c
index 27a8eec1..647774f2 100644
--- a/src/target/etm_dummy.c
+++ b/src/target/etm_dummy.c
@@ -77,11 +77,6 @@ static const struct command_registration etm_dummy_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
-static int etm_dummy_register_commands(struct command_context *cmd_ctx)
-{
- return register_commands(cmd_ctx, NULL, etm_dummy_command_handlers);
-}
-
static int etm_dummy_init(struct etm_context *etm_ctx)
{
return ERROR_OK;
@@ -110,7 +105,7 @@ static int etm_dummy_stop_capture(struct etm_context *etm_ctx)
struct etm_capture_driver etm_dummy_capture_driver =
{
.name = "dummy",
- .register_commands = etm_dummy_register_commands,
+ .commands = etm_dummy_command_handlers,
.init = etm_dummy_init,
.status = etm_dummy_status,
.start_capture = etm_dummy_start_capture,
diff --git a/src/target/oocd_trace.c b/src/target/oocd_trace.c
index a34c63c6..ac79f18d 100644
--- a/src/target/oocd_trace.c
+++ b/src/target/oocd_trace.c
@@ -30,8 +30,6 @@
*/
-static int oocd_trace_register_commands(struct command_context *cmd_ctx);
-
static int oocd_trace_read_reg(struct oocd_trace *oocd_trace, int reg, uint32_t *value)
{
size_t bytes_written, bytes_read, bytes_to_read;
@@ -278,17 +276,6 @@ static int oocd_trace_stop_capture(struct etm_context *etm_ctx)
return ERROR_OK;
}
-struct etm_capture_driver oocd_trace_capture_driver =
-{
- .name = "oocd_trace",
- .register_commands = oocd_trace_register_commands,
- .init = oocd_trace_init,
- .status = oocd_trace_status,
- .start_capture = oocd_trace_start_capture,
- .stop_capture = oocd_trace_stop_capture,
- .read_trace = oocd_trace_read_trace,
-};
-
COMMAND_HANDLER(handle_oocd_trace_config_command)
{
struct target *target;
@@ -438,7 +425,15 @@ static const struct command_registration oocd_trace_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
-int oocd_trace_register_commands(struct command_context *cmd_ctx)
+struct etm_capture_driver oocd_trace_capture_driver =
{
- return register_commands(cmd_ctx, NULL, oocd_trace_command_handlers);
-}
+ .name = "oocd_trace",
+ .commands = oocd_trace_command_handlers,
+ .init = oocd_trace_init,
+ .status = oocd_trace_status,
+ .start_capture = oocd_trace_start_capture,
+ .stop_capture = oocd_trace_stop_capture,
+ .read_trace = oocd_trace_read_trace,
+};
+
+