Commit dc9ef588 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Felipe Balbi

usb: gadget: mv_u3d: mv_u3d_start_queue() refactoring

The patch improves readability of mv_u3d_start_queue()
by rearranging its code with two semantic modifications:
- assignment zero to ep->processing if usb_gadget_map_request() fails;
- propagation of error code from mv_u3d_req_to_trb() instead of
  hardcoded -ENOMEM.
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 6ffd6515
...@@ -493,30 +493,32 @@ mv_u3d_start_queue(struct mv_u3d_ep *ep) ...@@ -493,30 +493,32 @@ mv_u3d_start_queue(struct mv_u3d_ep *ep)
ret = usb_gadget_map_request(&u3d->gadget, &req->req, ret = usb_gadget_map_request(&u3d->gadget, &req->req,
mv_u3d_ep_dir(ep)); mv_u3d_ep_dir(ep));
if (ret) if (ret)
return ret; goto break_processing;
req->req.status = -EINPROGRESS; req->req.status = -EINPROGRESS;
req->req.actual = 0; req->req.actual = 0;
req->trb_count = 0; req->trb_count = 0;
/* build trbs and push them to device queue */ /* build trbs */
if (!mv_u3d_req_to_trb(req)) { ret = mv_u3d_req_to_trb(req);
ret = mv_u3d_queue_trb(ep, req); if (ret) {
if (ret) {
ep->processing = 0;
return ret;
}
} else {
ep->processing = 0;
dev_err(u3d->dev, "%s, mv_u3d_req_to_trb fail\n", __func__); dev_err(u3d->dev, "%s, mv_u3d_req_to_trb fail\n", __func__);
return -ENOMEM; goto break_processing;
} }
/* and push them to device queue */
ret = mv_u3d_queue_trb(ep, req);
if (ret)
goto break_processing;
/* irq handler advances the queue */ /* irq handler advances the queue */
if (req) list_add_tail(&req->queue, &ep->queue);
list_add_tail(&req->queue, &ep->queue);
return 0; return 0;
break_processing:
ep->processing = 0;
return ret;
} }
static int mv_u3d_ep_enable(struct usb_ep *_ep, static int mv_u3d_ep_enable(struct usb_ep *_ep,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment