From: Johan Hovold Date: Thu, 23 Apr 2015 14:06:50 +0000 (+0200) Subject: usb: musb: fix inefficient copy of unaligned buffers X-Git-Tag: v4.2-rc1~86^2~16^2~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d72348fb5ca634583bf3f79996cc4b3ef91d9c3a;p=platform%2Fkernel%2Flinux-exynos.git usb: musb: fix inefficient copy of unaligned buffers Make sure only to copy any actual data rather than the whole buffer, when releasing the temporary buffer used for unaligned non-isochronous transfers. Signed-off-by: Johan Hovold Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index c3d5fc9..e1fb5d8 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -2512,6 +2512,7 @@ static void musb_free_temp_buffer(struct urb *urb) { enum dma_data_direction dir; struct musb_temp_buffer *temp; + size_t length; if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER)) return; @@ -2522,8 +2523,12 @@ static void musb_free_temp_buffer(struct urb *urb) data); if (dir == DMA_FROM_DEVICE) { - memcpy(temp->old_xfer_buffer, temp->data, - urb->transfer_buffer_length); + if (usb_pipeisoc(urb->pipe)) + length = urb->transfer_buffer_length; + else + length = urb->actual_length; + + memcpy(temp->old_xfer_buffer, temp->data, length); } urb->transfer_buffer = temp->old_xfer_buffer; kfree(temp->kmalloc_ptr);