Endpoint handlers need to know about endpoints, not dwc. If they really need access to dwc (e.g. for printing error messages) we have a reference to it tucked inside the endpoint. This patch has no functional changes, it's simply moving things around. Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx> --- drivers/usb/dwc3/gadget.c | 66 ++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 17d2ece96068..97ae480e4999 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -703,12 +703,12 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, return 0; } -static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum, bool force); +static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force); static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) { struct dwc3_request *req; - dwc3_stop_active_transfer(dwc, dep->number, true); + dwc3_stop_active_transfer(dep, true); /* - giveback all requests to gadget driver */ while (!list_empty(&dep->started_list)) { @@ -1250,11 +1250,10 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc) return DWC3_DSTS_SOFFN(reg); } -static void __dwc3_gadget_start_isoc(struct dwc3 *dwc, - struct dwc3_ep *dep, u32 cur_uf) +static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep, u32 cur_uf) { if (list_empty(&dep->pending_list)) { - dev_info(dwc->dev, "%s: ran out of requests\n", + dev_info(dep->dwc->dev, "%s: ran out of requests\n", dep->name); dep->flags |= DWC3_EP_PENDING_REQUEST; return; @@ -1304,13 +1303,13 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { if ((dep->flags & DWC3_EP_PENDING_REQUEST)) { if (dep->flags & DWC3_EP_TRANSFER_STARTED) { - dwc3_stop_active_transfer(dwc, dep->number, true); + dwc3_stop_active_transfer(dep, true); dep->flags = DWC3_EP_ENABLED; } else { u32 cur_uf; cur_uf = __dwc3_gadget_get_frame(dwc); - __dwc3_gadget_start_isoc(dwc, dep, cur_uf); + __dwc3_gadget_start_isoc(dep, cur_uf); dep->flags &= ~DWC3_EP_PENDING_REQUEST; } return 0; @@ -1373,7 +1372,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, } if (r == req) { /* wait until it is processed */ - dwc3_stop_active_transfer(dwc, dep->number, true); + dwc3_stop_active_transfer(dep, true); /* * If request was already started, this means we had to @@ -2206,10 +2205,9 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) /* -------------------------------------------------------------------------- */ -static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3 *dwc, - struct dwc3_ep *dep, struct dwc3_request *req, - struct dwc3_trb *trb, const struct dwc3_event_depevt *event, - int status, int chain) +static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, + struct dwc3_request *req, struct dwc3_trb *trb, + const struct dwc3_event_depevt *event, int status, int chain) { unsigned int count; unsigned int s_pkt = 0; @@ -2269,7 +2267,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3 *dwc, */ dep->flags |= DWC3_EP_MISSED_ISOC; } else { - dev_err(dwc->dev, "incomplete IN transfer %s\n", + dev_err(dep->dwc->dev, "incomplete IN transfer %s\n", dep->name); status = -ECONNRESET; } @@ -2291,9 +2289,8 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3 *dwc, return 0; } -static int dwc3_gadget_ep_cleanup_completed_requests(struct dwc3 *dwc, - struct dwc3_ep *dep, const struct dwc3_event_depevt *event, - int status) +static int dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep, + const struct dwc3_event_depevt *event, int status) { struct dwc3_request *req, *n; struct dwc3_trb *trb; @@ -2321,22 +2318,22 @@ static int dwc3_gadget_ep_cleanup_completed_requests(struct dwc3 *dwc, req->sg = sg_next(s); req->num_pending_sgs--; - ret = dwc3_gadget_ep_reclaim_completed_trb(dwc, - dep, req, trb, event, status, + ret = dwc3_gadget_ep_reclaim_completed_trb(dep, + req, trb, event, status, chain); if (ret) break; } } else { trb = &dep->trb_pool[dep->trb_dequeue]; - ret = dwc3_gadget_ep_reclaim_completed_trb(dwc, dep, - req, trb, event, status, chain); + ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req, + trb, event, status, chain); } if (req->unaligned || req->zero) { trb = &dep->trb_pool[dep->trb_dequeue]; - ret = dwc3_gadget_ep_reclaim_completed_trb(dwc, dep, - req, trb, event, status, false); + ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req, + trb, event, status, false); req->unaligned = false; req->zero = false; } @@ -2375,7 +2372,7 @@ static int dwc3_gadget_ep_cleanup_completed_requests(struct dwc3 *dwc, */ dep->flags = DWC3_EP_PENDING_REQUEST; } else { - dwc3_stop_active_transfer(dwc, dep->number, true); + dwc3_stop_active_transfer(dep, true); dep->flags = DWC3_EP_ENABLED; } return 1; @@ -2387,16 +2384,17 @@ static int dwc3_gadget_ep_cleanup_completed_requests(struct dwc3 *dwc, return 1; } -static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3 *dwc, - struct dwc3_ep *dep, const struct dwc3_event_depevt *event) +static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, + const struct dwc3_event_depevt *event) { + struct dwc3 *dwc = dep->dwc; unsigned status = 0; int clean_busy; if (event->status & DEPEVT_STATUS_BUSERR) status = -ECONNRESET; - clean_busy = dwc3_gadget_ep_cleanup_completed_requests(dwc, dep, event, + clean_busy = dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); if (clean_busy && (!dep->endpoint.desc || usb_endpoint_xfer_isoc(dep->endpoint.desc))) @@ -2428,15 +2426,15 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3 *dwc, } } -static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3 *dwc, - struct dwc3_ep *dep, const struct dwc3_event_depevt *event) +static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3_ep *dep, + const struct dwc3_event_depevt *event) { u32 cur_uf, mask; mask = ~(dep->interval - 1); cur_uf = event->parameters & mask; - __dwc3_gadget_start_isoc(dwc, dep, cur_uf); + __dwc3_gadget_start_isoc(dep, cur_uf); } static void dwc3_endpoint_interrupt(struct dwc3 *dwc, @@ -2464,10 +2462,10 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, switch (event->endpoint_event) { case DWC3_DEPEVT_XFERINPROGRESS: - dwc3_gadget_endpoint_transfer_in_progress(dwc, dep, event); + dwc3_gadget_endpoint_transfer_in_progress(dep, event); break; case DWC3_DEPEVT_XFERNOTREADY: - dwc3_gadget_endpoint_transfer_not_ready(dwc, dep, event); + dwc3_gadget_endpoint_transfer_not_ready(dep, event); break; case DWC3_DEPEVT_EPCMDCMPLT: cmd = DEPEVT_PARAMETER_CMD(event->parameters); @@ -2523,15 +2521,13 @@ static void dwc3_reset_gadget(struct dwc3 *dwc) } } -static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum, bool force) +static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force) { - struct dwc3_ep *dep; + struct dwc3 *dwc = dep->dwc; struct dwc3_gadget_ep_cmd_params params; u32 cmd; int ret; - dep = dwc->eps[epnum]; - if ((dep->flags & DWC3_EP_END_TRANSFER_PENDING) || !dep->resource_index) return; -- 2.16.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html