brcm2708: update linux 4.4 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0151-dcw_otg-trim-xfer-length-when-buffer-larger-than-all.patch
1 From bc7400cadff6bf33451b124eac2e8bf80ebb0197 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Fri, 12 Feb 2016 14:50:25 +0000
4 Subject: [PATCH 151/170] dcw_otg: trim xfer length when buffer larger than
5 allocated size is received
6
7 ---
8 drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c | 11 +++++++++++
9 1 file changed, 11 insertions(+)
10
11 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
12 +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
13 @@ -737,6 +737,11 @@ static int update_urb_state_xfer_comp(dw
14 DWC_OTG_HC_XFER_COMPLETE,
15 &short_read);
16
17 + if (urb->actual_length + xfer_length > urb->length) {
18 + DWC_WARN("%s(): trimming xfer length\n", __func__);
19 + xfer_length = urb->length - urb->actual_length;
20 + }
21 +
22 /* non DWORD-aligned buffer case handling. */
23 if (hc->align_buff && xfer_length && hc->ep_is_in) {
24 dwc_memcpy(urb->buf + urb->actual_length, hc->qh->dw_align_buf,
25 @@ -1423,6 +1428,12 @@ static void update_urb_state_xfer_intr(d
26 {
27 uint32_t bytes_transferred = get_actual_xfer_length(hc, hc_regs, qtd,
28 halt_status, NULL);
29 +
30 + if (urb->actual_length + bytes_transferred > urb->length) {
31 + DWC_WARN("%s(): trimming xfer length\n", __func__);
32 + bytes_transferred = urb->length - urb->actual_length;
33 + }
34 +
35 /* non DWORD-aligned buffer case handling. */
36 if (hc->align_buff && bytes_transferred && hc->ep_is_in) {
37 dwc_memcpy(urb->buf + urb->actual_length, hc->qh->dw_align_buf,