Skip to content
Snippets Groups Projects
Commit d9a02fda authored by Andreas Fritiofson's avatar Andreas Fritiofson Committed by Freddie Chopin
Browse files

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: default avatarAndreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/793


Reviewed-by: default avatarSpencer Oliver <spen@spen-soft.co.uk>
Tested-by: jenkins
Reviewed-by: default avatarFreddie Chopin <freddie.chopin@gmail.com>
parent d7f5a00c
Branches
Tags
No related merge requests found
......@@ -443,7 +443,7 @@ 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)
if (buffer_write_space(ctx) + (length < 8) < (out || (!out && !in) ? 4 : 3)
|| (in && buffer_read_space(ctx) < 1))
retval = mpsse_flush(ctx);
......@@ -466,7 +466,7 @@ int mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_off
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))
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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment