summaryrefslogtreecommitdiff
path: root/misc/urjtag/patches/patch-ae
blob: 429d1f1c0c54747ab39208855e02f016d492999b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$NetBSD: patch-ae,v 1.2 2010/08/09 19:37:45 drochner Exp $

--- src/tap/cable/generic.c.orig	2009-04-17 20:24:10.000000000 +0000
+++ src/tap/cable/generic.c
@@ -202,7 +202,7 @@ generic_flush_using_transfer( cable_t *c
 
 	do
 	{
-		int r, bits = 0, tdo = 0;
+		int r, bits = 0, savbits;
 
 #ifdef VERBOSE
 		printf("flush(%d)\n", cable->todo.num_items);
@@ -254,6 +254,7 @@ generic_flush_using_transfer( cable_t *c
 #ifdef VERBOSE
 		printf("%d combined into one (%d bits)\n", n, bits);
 #endif
+		savbits = bits;
 
 		if(bits == 0 || n <= 1)
 		{
@@ -309,17 +310,21 @@ generic_flush_using_transfer( cable_t *c
 			{
 				if(cable->todo.data[i].action == CABLE_CLOCK)
 				{
-					int k;
-					for(k=0;k<cable->todo.data[i].arg.clock.n;k++)
-						tdo = out[bits++];
+
+					bits += cable->todo.data[i].arg.clock.n;
 				}
 				else if(cable->todo.data[i].action == CABLE_GET_TDO)
 				{
+					int tdo;
 					int c = cable_add_queue_item( cable, &(cable->done) );
 #ifdef VERBOSE
 					printf("add result from transfer to %p.%d\n", &(cable->done), c);
 #endif
 					cable->done.data[c].action = CABLE_GET_TDO;
+					if (bits < savbits)
+						tdo = out[bits];
+					else
+						tdo = cable->driver->get_tdo(cable);
 					cable->done.data[c].arg.value.val = tdo;
 				}
 				else if(cable->todo.data[i].action == CABLE_TRANSFER)
@@ -340,7 +345,6 @@ generic_flush_using_transfer( cable_t *c
 						if(len > 0) memcpy(p, out+bits, len);
 					}
 					if(len>0) bits += len;
-					if(bits>0) tdo = out[bits-1];
 				}
 				i++;
 				if(i >= cable->todo.max_items) i = 0;