This is an automated email from Gerrit.

Alamy Liu ([email protected]) just uploaded a new patch set to Gerrit, which 
you can find at http://openocd.zylin.com/3288

-- gerrit

commit 309802a73e0784c62c8ee3980ed1c8ed5d7cf972
Author: Alamy Liu <[email protected]>
Date:   Tue Aug 18 17:13:19 2015 -0700

    target: Remove old target field 'target_number'
    
    Note:
    There might be some other places need to be modified but I am not sure
    if they are related.
    
    "target#"
        configuration files (i.e.: at91sam7se512.cfg)
        flash drivers (i.e.: src/flash/nor/cfi.c)
    
    Change-Id: I8f42b7994d9f7e96a18d8bbc78109328e107a23a
    Signed-off-by: Alamy Liu <[email protected]>

diff --git a/src/helper/command.c b/src/helper/command.c
index 314812a..9862a2d 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -1276,7 +1276,7 @@ struct command_context *command_init(const char 
*startup_tcl, Jim_Interp *interp
 
        context->mode = COMMAND_EXEC;
        context->commands = NULL;
-       context->current_target = 0;
+       context->current_target = NULL;
        context->output_handler = NULL;
        context->output_handler_priv = NULL;
 
diff --git a/src/helper/command.h b/src/helper/command.h
index e3d122f..b962de0 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -51,7 +51,7 @@ struct command_context {
        Jim_Interp *interp;
        enum command_mode mode;
        struct command *commands;
-       int current_target;
+       struct target *current_target;
        command_output_handler_t output_handler;
        void *output_handler_priv;
 };
diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c
index 789eee8..50b883d 100644
--- a/src/server/tcl_server.c
+++ b/src/server/tcl_server.c
@@ -159,7 +159,7 @@ static int tcl_new_connection(struct connection *connection)
 
        connection->priv = tclc;
 
-       struct target *target = 
get_target_by_num(connection->cmd_ctx->current_target);
+       struct target *target = connection->cmd_ctx->current_target;
        if (target != NULL)
                tclc->tc_laststate = target->state;
 
diff --git a/src/target/nds32.c b/src/target/nds32.c
index b6c5f61..0d00bb9 100644
--- a/src/target/nds32.c
+++ b/src/target/nds32.c
@@ -1662,7 +1662,7 @@ int nds32_init_arch_info(struct target *target, struct 
nds32 *nds32)
        nds32->syscall_break.set = 0;
        nds32->syscall_break.orig_instr = NULL;
        nds32->syscall_break.next = NULL;
-       nds32->syscall_break.unique_id = 0x515CAll + target->target_number;
+       nds32->syscall_break.unique_id = 0x515CAll + (uint32_t)target;
        nds32->syscall_break.linked_BRP = 0;
 
        nds32_reg_init();
@@ -2274,9 +2274,9 @@ static int nds32_callback_event_handler(struct target 
*target,
                enum target_event event, void *priv)
 {
        int retval = ERROR_OK;
-       int target_number = *(int *)priv;
+       const char *name = (char *)priv;
 
-       if (target_number != target->target_number)
+       if (name != target_name(target))
                return ERROR_OK;
 
        struct nds32 *nds32 = target_to_nds32(target);
@@ -2302,7 +2302,7 @@ int nds32_init(struct nds32 *nds32)
 
        /* register event callback */
        target_register_event_callback(nds32_callback_event_handler,
-                       &(nds32->target->target_number));
+                       (void *)target_name(nds32->target));
 
        return ERROR_OK;
 }
diff --git a/src/target/target.c b/src/target/target.c
index 1c17fdb..4d0fc6f 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -310,23 +310,6 @@ const char *target_reset_mode_name(enum target_reset_mode 
reset_mode)
        return cp;
 }
 
-/* determine the number of the new target */
-static int new_target_number(void)
-{
-       struct target *t;
-       int x;
-
-       /* number is 0 based */
-       x = -1;
-       t = all_targets;
-       while (t) {
-               if (x < t->target_number)
-                       x = t->target_number;
-               t = t->next;
-       }
-       return x + 1;
-}
-
 /* read a uint64_t from a buffer in target memory endianness */
 uint64_t target_buffer_get_u64(struct target *target, const uint8_t *buffer)
 {
@@ -472,41 +455,12 @@ struct target *get_target(const char *id)
                        return target;
        }
 
-       /* It's OK to remove this fallback sometime after August 2010 or so */
-
-       /* no match, try as number */
-       unsigned num;
-       if (parse_uint(id, &num) != ERROR_OK)
-               return NULL;
-
-       for (target = all_targets; target; target = target->next) {
-               if (target->target_number == (int)num) {
-                       LOG_WARNING("use '%s' as target identifier, not '%u'",
-                                       target_name(target), num);
-                       return target;
-               }
-       }
-
-       return NULL;
-}
-
-/* returns a pointer to the n-th configured target */
-struct target *get_target_by_num(int num)
-{
-       struct target *target = all_targets;
-
-       while (target) {
-               if (target->target_number == num)
-                       return target;
-               target = target->next;
-       }
-
        return NULL;
 }
 
 struct target *get_current_target(struct command_context *cmd_ctx)
 {
-       struct target *target = get_target_by_num(cmd_ctx->current_target);
+       struct target *target = cmd_ctx->current_target;
 
        if (target == NULL) {
                LOG_ERROR("BUG: current_target out of bounds");
@@ -2418,7 +2372,7 @@ static int find_target(struct command_context *cmd_ctx, 
const char *name)
                return ERROR_FAIL;
        }
 
-       cmd_ctx->current_target = target->target_number;
+       cmd_ctx->current_target = target;
        return ERROR_OK;
 }
 
@@ -2436,8 +2390,9 @@ COMMAND_HANDLER(handle_targets_command)
        }
 
        struct target *target = all_targets;
-       command_print(CMD_CTX, "    TargetName         Type       Endian 
TapName            State       ");
-       command_print(CMD_CTX, "--  ------------------ ---------- ------ 
------------------ ------------");
+       command_print(CMD_CTX, "  TargetName         Type       Endian TapName  
          State       ");
+       command_print(CMD_CTX, "  ------------------ ---------- ------ 
------------------ ------------");
+
        while (target) {
                const char *state;
                char marker = ' ';
@@ -2447,13 +2402,12 @@ COMMAND_HANDLER(handle_targets_command)
                else
                        state = "tap-disabled";
 
-               if (CMD_CTX->current_target == target->target_number)
+               if (CMD_CTX->current_target == target)
                        marker = '*';
 
                /* keep columns lined up to match the headers above */
                command_print(CMD_CTX,
-                               "%2d%c %-18s %-10s %-6s %-18s %s",
-                               target->target_number,
+                               "%c %-18s %-10s %-6s %-18s %s",
                                marker,
                                target_name(target),
                                target_type_name(target),
@@ -4330,8 +4284,7 @@ void target_handle_event(struct target *target, enum 
target_event e)
 
        for (teap = target->event_action; teap != NULL; teap = teap->next) {
                if (teap->event == e) {
-                       LOG_DEBUG("target: (%d) %s (%s) event: %d (%s) action: 
%s",
-                                          target->target_number,
+                       LOG_DEBUG("target: %s (%s) event: %d (%s) action: %s",
                                           target_name(target),
                                           target_type_name(target),
                                           e,
@@ -5092,8 +5045,7 @@ static int jim_target_event_list(Jim_Interp *interp, int 
argc, Jim_Obj *const *a
 
        struct target *target = Jim_CmdPrivData(interp);
        struct target_event_action *teap = target->event_action;
-       command_print(cmd_ctx, "Event actions for target (%d) %s\n",
-                                  target->target_number,
+       command_print(cmd_ctx, "Event actions for target %s\n",
                                   target_name(target));
        command_print(cmd_ctx, "%-25s | Body", "Event");
        command_print(cmd_ctx, "------------------------- | "
@@ -5347,9 +5299,7 @@ static int target_create(Jim_GetOptInfo *goi)
 
        /* Create it */
        target = calloc(1, sizeof(struct target));
-       /* set target number */
-       target->target_number = new_target_number();
-       cmd_ctx->current_target = target->target_number;
+       cmd_ctx->current_target = target;
 
        /* allocate memory for each unique target type */
        target->type = calloc(1, sizeof(struct target_type));
diff --git a/src/target/target.h b/src/target/target.h
index 2ebd8a8..b1edea4 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -129,7 +129,6 @@ struct target {
        struct target_type *type;                       /* target type 
definition (name, access functions) */
        struct target_type_64 *type64;          /* target type for aarch64 */
        const char *cmd_name;                           /* tcl Name of target */
-       int target_number;                                      /* DO NOT USE!  
field to be removed in 2010 */
        struct jtag_tap *tap;                           /* where on the jtag 
chain is this */
        int32_t coreid;                                         /* which device 
on the TAP? */
 
@@ -387,7 +386,6 @@ int target_call_timer_callbacks(void);
  */
 int target_call_timer_callbacks_now(void);
 
-struct target *get_target_by_num(int num);
 struct target *get_current_target(struct command_context *cmd_ctx);
 struct target *get_target(const char *id);
 

-- 

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to