jtag/core: remove unused variable
[openocd.git] / src / jtag / core.c
index 51c1228a329285f2f6966798f8a36b3caa1f2787..2de5fda47b1f08531675accfd2333e8baa9e70b0 100644 (file)
@@ -128,7 +128,6 @@ static int speed_khz;
 /* speed to fallback to when RCLK is requested but not supported */
 static int rclk_fallback_speed_khz;
 static enum {CLOCK_MODE_UNSELECTED, CLOCK_MODE_KHZ, CLOCK_MODE_RCLK} clock_mode;
-static int jtag_speed;
 
 /* FIXME: change name to this variable, it is not anymore JTAG only */
 static struct adapter_driver *jtag;
@@ -243,7 +242,7 @@ struct jtag_tap *jtag_tap_by_string(const char *s)
        struct jtag_tap *t = jtag_all_taps();
 
        while (t) {
-               if (0 == strcmp(t->dotted_name, s))
+               if (strcmp(t->dotted_name, s) == 0)
                        return t;
                t = t->next_tap;
        }
@@ -1072,8 +1071,6 @@ void jtag_sleep(uint32_t us)
 
 #define JTAG_MAX_AUTO_TAPS 20
 
-#define EXTRACT_JEP106_BANK(X) (((X) & 0xf00) >> 8)
-#define EXTRACT_JEP106_ID(X)   (((X) & 0xfe) >> 1)
 #define EXTRACT_MFG(X)  (((X) & 0xffe) >> 1)
 #define EXTRACT_PART(X) (((X) & 0xffff000) >> 12)
 #define EXTRACT_VER(X)  (((X) & 0xf0000000) >> 28)
@@ -1141,7 +1138,7 @@ static void jtag_examine_chain_display(enum log_levels level, const char *msg,
                name, msg,
                (unsigned int)idcode,
                (unsigned int)EXTRACT_MFG(idcode),
-               jep106_manufacturer(EXTRACT_JEP106_BANK(idcode), EXTRACT_JEP106_ID(idcode)),
+               jep106_manufacturer(EXTRACT_MFG(idcode)),
                (unsigned int)EXTRACT_PART(idcode),
                (unsigned int)EXTRACT_VER(idcode));
 }
@@ -1197,7 +1194,7 @@ static bool jtag_examine_chain_match_tap(const struct jtag_tap *tap)
                        return true;
 
                /* treat "-expected-id 0" as a "don't-warn" wildcard */
-               if (0 == tap->expected_ids[ii])
+               if (tap->expected_ids[ii] == 0)
                        return true;
        }
 
@@ -1336,19 +1333,18 @@ out:
 static int jtag_validate_ircapture(void)
 {
        struct jtag_tap *tap;
-       int total_ir_length = 0;
        uint8_t *ir_test = NULL;
        struct scan_field field;
-       uint64_t val;
        int chain_pos = 0;
        int retval;
 
        /* when autoprobing, accommodate huge IR lengths */
-       for (tap = NULL, total_ir_length = 0;
-                       (tap = jtag_tap_next_enabled(tap)) != NULL;
-                       total_ir_length += tap->ir_length) {
+       int total_ir_length = 0;
+       for (tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
                if (tap->ir_length == 0)
                        total_ir_length += JTAG_IRLEN_MAX;
+               else
+                       total_ir_length += tap->ir_length;
        }
 
        /* increase length to add 2 bit sentinel after scan */
@@ -1398,7 +1394,7 @@ static int jtag_validate_ircapture(void)
                 */
                if (tap->ir_length == 0) {
                        tap->ir_length = 2;
-                       while ((val = buf_get_u64(ir_test, chain_pos, tap->ir_length + 1)) == 1
+                       while (buf_get_u64(ir_test, chain_pos, tap->ir_length + 1) == 1
                                        && tap->ir_length < JTAG_IRLEN_MAX) {
                                tap->ir_length++;
                        }
@@ -1414,7 +1410,7 @@ static int jtag_validate_ircapture(void)
                 * this part of the JTAG spec, so their capture mask/value
                 * attributes might disable this test.
                 */
-               val = buf_get_u64(ir_test, chain_pos, tap->ir_length);
+               uint64_t val = buf_get_u64(ir_test, chain_pos, tap->ir_length);
                if ((val & tap->ir_capture_mask) != tap->ir_capture_value) {
                        LOG_ERROR("%s: IR capture error; saw 0x%0*" PRIx64 " not 0x%0*" PRIx32,
                                jtag_tap_name(tap),
@@ -1430,7 +1426,7 @@ static int jtag_validate_ircapture(void)
        }
 
        /* verify the '11' sentinel we wrote is returned at the end */
-       val = buf_get_u64(ir_test, chain_pos, 2);
+       uint64_t val = buf_get_u64(ir_test, chain_pos, 2);
        if (val != 0x3) {
                char *cbuf = buf_to_hex_str(ir_test, total_ir_length);
 
@@ -1807,7 +1803,6 @@ static int jtag_rclk_to_speed(unsigned fallback_speed_khz, int *speed)
 
 static int jtag_set_speed(int speed)
 {
-       jtag_speed = speed;
        /* this command can be called during CONFIG,
         * in which case jtag isn't initialized */
        return jtag ? jtag->speed(speed) : ERROR_OK;
@@ -2008,7 +2003,7 @@ bool transport_is_jtag(void)
 
 int adapter_resets(int trst, int srst)
 {
-       if (get_current_transport() == NULL) {
+       if (!get_current_transport()) {
                LOG_ERROR("transport is not selected");
                return ERROR_FAIL;
        }
@@ -2065,7 +2060,7 @@ int adapter_assert_reset(void)
                           transport_is_dapdirect_jtag() || transport_is_dapdirect_swd() ||
                           transport_is_swim())
                return adapter_system_reset(1);
-       else if (get_current_transport() != NULL)
+       else if (get_current_transport())
                LOG_ERROR("reset is not supported on %s",
                        get_current_transport()->name);
        else
@@ -2082,7 +2077,7 @@ int adapter_deassert_reset(void)
                           transport_is_dapdirect_jtag() || transport_is_dapdirect_swd() ||
                           transport_is_swim())
                return adapter_system_reset(0);
-       else if (get_current_transport() != NULL)
+       else if (get_current_transport())
                LOG_ERROR("reset is not supported on %s",
                        get_current_transport()->name);
        else

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)