The existing code assumed that all the bytes in the
buffer are consumed in a call. This isn't the case
since the count is adjusted.
Signed-off-by: Andrew Jackson <Andrew.Jackson@arm.com>
memcpy(&dmatx->buf[0], &xmit->buf[xmit->tail], count);
else {
size_t first = UART_XMIT_SIZE - xmit->tail;
- size_t second = xmit->head;
+
+ if (first > count)
+ first = count;
+ else {
+ size_t second = count - first;
+
+ if (second)
+ memcpy(&dmatx->buf[first], &xmit->buf[0], second);
+ }
memcpy(&dmatx->buf[0], &xmit->buf[xmit->tail], first);
- if (second)
- memcpy(&dmatx->buf[first], &xmit->buf[0], second);
}
dmatx->sg.length = count;