Skip to content

Commit

Permalink
usb: gadget: uvc: refactor the check for a valid buffer in the pump w…
Browse files Browse the repository at this point in the history
…orker

[ Upstream commit 5e7ea65 ]

By toggling the condition check for a valid buffer, the else path
can be completely avoided.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20240214-uvc-gadget-cleanup-v1-2-de6d78780459@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
mgrzeschik authored and gregkh committed Apr 13, 2024
1 parent 598a5ff commit f3ad2c9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/usb/gadget/function/uvc_video.c
Expand Up @@ -594,10 +594,7 @@ static void uvcg_video_pump(struct work_struct *work)
*/
spin_lock_irqsave(&queue->irqlock, flags);
buf = uvcg_queue_head(queue);

if (buf != NULL) {
video->encode(req, video, buf);
} else {
if (!buf) {
/*
* Either the queue has been disconnected or no video buffer
* available for bulk transfer. Either way, stop processing
Expand All @@ -607,6 +604,8 @@ static void uvcg_video_pump(struct work_struct *work)
break;
}

video->encode(req, video, buf);

spin_unlock_irqrestore(&queue->irqlock, flags);

spin_lock_irqsave(&video->req_lock, flags);
Expand Down

0 comments on commit f3ad2c9

Please sign in to comment.