diff options
author | Andreas Fritiofson <andreas.fritiofson@gmail.com> | 2012-08-23 23:28:10 +0200 |
---|---|---|
committer | Freddie Chopin <freddie.chopin@gmail.com> | 2012-08-29 06:31:39 +0000 |
commit | d9a02fda075c466dd4a37785d886a4b1ee382242 (patch) | |
tree | 0695c6d41a3fbf645b1bc6b165b3595769c70108 /src | |
parent | d7f5a00cdceb9b1d867a3738b859dab4182038da (diff) |
mpsse: check available buffer space even for discarded data scans
When there's no data to scan in or out, we still use the clock data out
command and fill the buffer with zeroes, so make sure the buffer is
checked for available space.
Change-Id: Ia6005c40c81f7fdb89379f1b5023fe383184d210
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/793
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/jtag/drivers/mpsse.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c index 063ef2ff..d6cbc840 100644 --- a/src/jtag/drivers/mpsse.c +++ b/src/jtag/drivers/mpsse.c @@ -443,8 +443,8 @@ int mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_off while (length > 0) { /* Guarantee buffer space enough for a minimum size transfer */ - if (buffer_write_space(ctx) + (length < 8) < (out ? 4 : 3) - || (in && buffer_read_space(ctx) < 1)) + if (buffer_write_space(ctx) + (length < 8) < (out || (!out && !in) ? 4 : 3) + || (in && buffer_read_space(ctx) < 1)) retval = mpsse_flush(ctx); if (length < 8) { @@ -465,8 +465,8 @@ int mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_off if (this_bytes > 65536) this_bytes = 65536; /* Buffer space limit. We already made sure there's space for the minimum - *transfer. */ - if (out && this_bytes + 3 > buffer_write_space(ctx)) + * transfer. */ + if ((out || (!out && !in)) && this_bytes + 3 > buffer_write_space(ctx)) this_bytes = buffer_write_space(ctx) - 3; if (in && this_bytes > buffer_read_space(ctx)) this_bytes = buffer_read_space(ctx); |