Commit 28ff0fa7 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Greg Kroah-Hartman

usb: gadget: uvc: Factor out video USB request queueing

[ Upstream commit 9d1ff5dc ]

USB requests for video data are queued from two different locations in
the driver, with the same code block occurring twice. Factor it out to a
function.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarPaul Elder <paul.elder@ideasonboard.com>
Tested-by: default avatarPaul Elder <paul.elder@ideasonboard.com>
Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 0623749e
...@@ -129,6 +129,19 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video, ...@@ -129,6 +129,19 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video,
* Request handling * Request handling
*/ */
static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req)
{
int ret;
ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
if (ret < 0) {
printk(KERN_INFO "Failed to queue request (%d).\n", ret);
usb_ep_set_halt(video->ep);
}
return ret;
}
/* /*
* I somehow feel that synchronisation won't be easy to achieve here. We have * I somehow feel that synchronisation won't be easy to achieve here. We have
* three events that control USB requests submission: * three events that control USB requests submission:
...@@ -193,14 +206,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) ...@@ -193,14 +206,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
video->encode(req, video, buf); video->encode(req, video, buf);
if ((ret = usb_ep_queue(ep, req, GFP_ATOMIC)) < 0) { ret = uvcg_video_ep_queue(video, req);
printk(KERN_INFO "Failed to queue request (%d).\n", ret); spin_unlock_irqrestore(&video->queue.irqlock, flags);
usb_ep_set_halt(ep);
spin_unlock_irqrestore(&video->queue.irqlock, flags); if (ret < 0) {
uvcg_queue_cancel(queue, 0); uvcg_queue_cancel(queue, 0);
goto requeue; goto requeue;
} }
spin_unlock_irqrestore(&video->queue.irqlock, flags);
return; return;
...@@ -320,15 +332,13 @@ int uvcg_video_pump(struct uvc_video *video) ...@@ -320,15 +332,13 @@ int uvcg_video_pump(struct uvc_video *video)
video->encode(req, video, buf); video->encode(req, video, buf);
/* Queue the USB request */ /* Queue the USB request */
ret = usb_ep_queue(video->ep, req, GFP_ATOMIC); ret = uvcg_video_ep_queue(video, req);
spin_unlock_irqrestore(&queue->irqlock, flags);
if (ret < 0) { if (ret < 0) {
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
spin_unlock_irqrestore(&queue->irqlock, flags);
uvcg_queue_cancel(queue, 0); uvcg_queue_cancel(queue, 0);
break; break;
} }
spin_unlock_irqrestore(&queue->irqlock, flags);
} }
spin_lock_irqsave(&video->req_lock, flags); spin_lock_irqsave(&video->req_lock, flags);
......
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