diff options
author | Felipe Balbi <felipe.balbi@linux.intel.com> | 2016-07-28 20:17:58 -0400 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2016-08-10 07:15:57 -0400 |
commit | c7de573471832dff7d31f0c13b0f143d6f017799 (patch) | |
tree | 3ca47cf8a8235647ba051e40576a6ec988f692c7 /drivers/usb | |
parent | 29b4817d4018df78086157ea3a55c1d9424a7cfc (diff) |
usb: dwc3: gadget: increment request->actual once
When using SG lists, we would end up setting
request->actual to:
num_mapped_sgs * (request->length - count)
Let's fix that up by incrementing request->actual
only once.
Cc: <stable@vger.kernel.org>
Reported-by: Brian E Rogers <brian.e.rogers@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 8f8c2157910e..863c306ebb69 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -2013,14 +2013,6 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
2013 | s_pkt = 1; | 2013 | s_pkt = 1; |
2014 | } | 2014 | } |
2015 | 2015 | ||
2016 | /* | ||
2017 | * We assume here we will always receive the entire data block | ||
2018 | * which we should receive. Meaning, if we program RX to | ||
2019 | * receive 4K but we receive only 2K, we assume that's all we | ||
2020 | * should receive and we simply bounce the request back to the | ||
2021 | * gadget driver for further processing. | ||
2022 | */ | ||
2023 | req->request.actual += req->request.length - count; | ||
2024 | if (s_pkt) | 2016 | if (s_pkt) |
2025 | return 1; | 2017 | return 1; |
2026 | if ((event->status & DEPEVT_STATUS_LST) && | 2018 | if ((event->status & DEPEVT_STATUS_LST) && |
@@ -2040,6 +2032,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
2040 | struct dwc3_trb *trb; | 2032 | struct dwc3_trb *trb; |
2041 | unsigned int slot; | 2033 | unsigned int slot; |
2042 | unsigned int i; | 2034 | unsigned int i; |
2035 | int count = 0; | ||
2043 | int ret; | 2036 | int ret; |
2044 | 2037 | ||
2045 | do { | 2038 | do { |
@@ -2054,6 +2047,8 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
2054 | slot++; | 2047 | slot++; |
2055 | slot %= DWC3_TRB_NUM; | 2048 | slot %= DWC3_TRB_NUM; |
2056 | trb = &dep->trb_pool[slot]; | 2049 | trb = &dep->trb_pool[slot]; |
2050 | count += trb->size & DWC3_TRB_SIZE_MASK; | ||
2051 | |||
2057 | 2052 | ||
2058 | ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb, | 2053 | ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb, |
2059 | event, status); | 2054 | event, status); |
@@ -2061,6 +2056,14 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
2061 | break; | 2056 | break; |
2062 | } while (++i < req->request.num_mapped_sgs); | 2057 | } while (++i < req->request.num_mapped_sgs); |
2063 | 2058 | ||
2059 | /* | ||
2060 | * We assume here we will always receive the entire data block | ||
2061 | * which we should receive. Meaning, if we program RX to | ||
2062 | * receive 4K but we receive only 2K, we assume that's all we | ||
2063 | * should receive and we simply bounce the request back to the | ||
2064 | * gadget driver for further processing. | ||
2065 | */ | ||
2066 | req->request.actual += req->request.length - count; | ||
2064 | dwc3_gadget_giveback(dep, req, status); | 2067 | dwc3_gadget_giveback(dep, req, status); |
2065 | 2068 | ||
2066 | if (ret) | 2069 | if (ret) |