]> git.sur5r.net Git - openocd/commitdiff
jtag_vpi: fix path move function
authorFranck Jullien <franck.jullien@gmail.com>
Thu, 3 Oct 2013 21:22:32 +0000 (23:22 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Tue, 15 Oct 2013 20:39:28 +0000 (20:39 +0000)
Change-Id: I82bf6f733e0d9cb5c86553d0827c558fa98aa247
Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-on: http://openocd.zylin.com/1672
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/jtag/drivers/jtag_vpi.c

index 84cd947064860b20b560e560e106dca53b1f2df8..d0e90e2afdaaa42145e15754d877419b95b8b452 100644 (file)
@@ -123,23 +123,17 @@ static int jtag_vpi_tms_seq(const uint8_t *bits, int nb_bits)
 
 static int jtag_vpi_path_move(struct pathmove_command *cmd)
 {
-       uint16_t trans = 0;
-       int retval;
-       int i;
+       uint8_t trans[DIV_ROUND_UP(cmd->num_states, 8)];
+
+       memset(trans, 0, DIV_ROUND_UP(cmd->num_states, 8));
 
-       for (i = 0; i < cmd->num_states; i++) {
+       for (int i = 0; i < cmd->num_states; i++) {
                if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
-                       trans = trans | 1;
-               trans = trans << 1;
+                       buf_set_u32(trans, i, 1, 1);
+               tap_set_state(cmd->path[i]);
        }
 
-       retval = jtag_vpi_tms_seq((uint8_t *)&trans, 1);
-       if (retval != ERROR_OK)
-               return retval;
-
-       tap_set_state(cmd->path[i]);
-
-       return ERROR_OK;
+       return jtag_vpi_tms_seq(trans, cmd->num_states);
 }
 
 /**