jtag: Remove unnecessary global variable 35/2235/2
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Wed, 30 Jul 2014 21:21:09 +0000 (23:21 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 7 Jan 2015 23:23:14 +0000 (23:23 +0000)
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>
src/jtag/core.c

index 44aed30ade6b5fecd5128f9fa53a737a6b51457c..04b0fc669e8fe06cb9e1a034596124b22e39670e 100644 (file)
@@ -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 */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)