$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;ktodo.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;