- fix bug in ft2232 pathmove (thanks to Michael Bruck for the patch)
[fw/openocd] / src / jtag / ft2232.c
index 76741d9e5ad1b1b90c8097514165c8fbe805da2b..1a058675cd3b88f6c9ed8f1e256a2606012c213c 100644 (file)
@@ -459,12 +459,14 @@ void ft2232_add_pathmove(pathmove_command_t *cmd)
                tms_byte = 0x0;
                int bit_count = 0;
                
+               int num_states_batch = num_states > 7 ? 7 : num_states;
+
                /* command "Clock Data to TMS/CS Pin (no Read)" */
                BUFFER_ADD = 0x4b;
                /* number of states remaining */
-               BUFFER_ADD = (num_states % 7) - 1;
+               BUFFER_ADD = num_states_batch - 1;
                
-               while (num_states % 7)
+               while (num_states_batch--)
                {
                        if (tap_transitions[cur_state].low == cmd->path[state_count])
                                buf_set_u32(&tms_byte, bit_count++, 1, 0x0);
@@ -1402,7 +1404,7 @@ static int ft2232_init_ftd2xx(u16 vid, u16 pid, int more, int *try_more)
                }
                else
                {
-                       printf("ListDevices: NONE\n");
+                       ERROR("ListDevices: NONE\n");
                }
                return ERROR_JTAG_INIT_FAILED;
        }