aboutsummaryrefslogtreecommitdiff
path: root/src/jtag/core.c
diff options
context:
space:
mode:
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>2014-07-30 23:21:09 +0200
committerSpencer Oliver <spen@spen-soft.co.uk>2015-01-07 23:23:14 +0000
commit1e23496f6e5eb495001a7581407719fcd511e9ac (patch)
tree8baba4e8161d7855939c1f6454bc11917977d5b8 /src/jtag/core.c
parent9330147fae3872269b08bad8edcffb5162e707a9 (diff)
downloadriscv-openocd-1e23496f6e5eb495001a7581407719fcd511e9ac.zip
riscv-openocd-1e23496f6e5eb495001a7581407719fcd511e9ac.tar.gz
riscv-openocd-1e23496f6e5eb495001a7581407719fcd511e9ac.tar.bz2
jtag: Remove unnecessary global variable
Change-Id: I96e5f13b12da2970eafc5fca24b7952d427eeca9 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/2235 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/jtag/core.c')
-rw-r--r--src/jtag/core.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 44aed30..04b0fc6 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -90,11 +90,6 @@ static int jtag_srst = -1;
* List all TAPs that have been created.
*/
static struct jtag_tap *__jtag_all_taps;
-/**
- * The number of TAPs in the __jtag_all_taps list, used to track the
- * assigned chain position to new TAPs
- */
-static unsigned jtag_num_taps;
static enum reset_types jtag_reset_config = RESET_NONE;
tap_state_t cmd_queue_cur_state = TAP_RESET;
@@ -193,7 +188,13 @@ struct jtag_tap *jtag_all_taps(void)
unsigned jtag_tap_count(void)
{
- return jtag_num_taps;
+ struct jtag_tap *t = jtag_all_taps();
+ unsigned n = 0;
+ while (t) {
+ n++;
+ t = t->next_tap;
+ }
+ return n;
}
unsigned jtag_tap_count_enabled(void)
@@ -211,12 +212,15 @@ unsigned jtag_tap_count_enabled(void)
/** Append a new TAP to the chain of all taps. */
void jtag_tap_add(struct jtag_tap *t)
{
- t->abs_chain_position = jtag_num_taps++;
+ unsigned jtag_num_taps = 0;
struct jtag_tap **tap = &__jtag_all_taps;
- while (*tap != NULL)
+ while (*tap != NULL) {
+ jtag_num_taps++;
tap = &(*tap)->next_tap;
+ }
*tap = t;
+ t->abs_chain_position = jtag_num_taps;
}
/* returns a pointer to the n-th device in the scan chain */