This is an automated email from Gerrit.

"Evgeniy Naydanov <[email protected]>" just uploaded a new patch set to Gerrit, 
which you can find at https://review.openocd.org/c/openocd/+/9663

-- gerrit

commit c9502f4aa960e0760545d6ad9d598dc3e8e3b64a
Author: Evgeniy Naydanov <[email protected]>
Date:   Mon Apr 6 17:16:46 2026 +0300

    jtag: factor-out `tap_is_state_next()`
    
    The intention is to make the code a bit clearer and to simplify reuse.
    
    Change-Id: I09cb37c4643a40123b0e7a8ed2dd8b2b655b6753
    Signed-off-by: Evgeniy Naydanov <[email protected]>

diff --git a/src/jtag/core.c b/src/jtag/core.c
index 9c438a01b2..b46381f0ae 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -533,8 +533,7 @@ void jtag_add_pathmove(unsigned int num_states, const enum 
tap_state *path)
                        return;
                }
 
-               if (tap_state_transition(cur_state, true) != path[i] &&
-                               tap_state_transition(cur_state, false) != 
path[i]) {
+               if (!tap_is_state_next(cur_state, path[i])) {
                        LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
                                tap_state_name(cur_state), 
tap_state_name(path[i]));
                        jtag_set_error(ERROR_JTAG_TRANSITION_INVALID);
@@ -581,8 +580,7 @@ int jtag_add_statemove(enum tap_state goal_state)
                }
 
                jtag_add_pathmove(tms_count, moves);
-       } else if (tap_state_transition(cur_state, true)  == goal_state
-                       || tap_state_transition(cur_state, false) == goal_state)
+       } else if (tap_is_state_next(cur_state, goal_state))
                jtag_add_pathmove(1, &goal_state);
        else
                return ERROR_FAIL;
diff --git a/src/jtag/interface.h b/src/jtag/interface.h
index d5f6d747f0..7dd9847ffa 100644
--- a/src/jtag/interface.h
+++ b/src/jtag/interface.h
@@ -143,6 +143,12 @@ bool tap_is_state_stable(enum tap_state astate);
  */
 enum tap_state tap_state_transition(enum tap_state current_state, bool tms);
 
+static inline bool tap_is_state_next(enum tap_state from, enum tap_state to)
+{
+       return tap_state_transition(from, false) == to
+               || tap_state_transition(from, true) == to;
+}
+
 /** Allow switching between old and new TMS tables. @see tap_get_tms_path */
 void tap_use_new_tms_table(bool use_new);
 /** @returns True if new TMS table is active; false otherwise. */

-- 

Reply via email to