Commit 2079b60b authored by Avichal Rakesh's avatar Avichal Rakesh Committed by Greg Kroah-Hartman
Browse files

usb: gadget: uvc: move video disable logic to its own function



This patch refactors the video disable logic in uvcg_video_enable
into its own separate function 'uvcg_video_disable'. This function
is now used anywhere uvcg_video_enable(video, 0) was used.

Reviewed-by: default avatarDaniel Scally <dan.scally@ideasonboard.com>
Suggested-by: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: default avatarAvichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20231109004104.3467968-3-arakesh@google.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent aeb686a9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -443,7 +443,7 @@ uvc_v4l2_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
		return -EINVAL;

	/* Enable UVC video. */
	ret = uvcg_video_enable(video, 1);
	ret = uvcg_video_enable(video);
	if (ret < 0)
		return ret;

@@ -469,7 +469,7 @@ uvc_v4l2_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
		return -EINVAL;

	uvc->state = UVC_STATE_CONNECTED;
	ret = uvcg_video_enable(video, 0);
	ret = uvcg_video_disable(video);
	if (ret < 0)
		return ret;

@@ -515,7 +515,7 @@ static void uvc_v4l2_disable(struct uvc_device *uvc)
	if (uvc->state == UVC_STATE_STREAMING)
		uvc->state = UVC_STATE_CONNECTED;

	uvcg_video_enable(&uvc->video, 0);
	uvcg_video_disable(&uvc->video);
	uvcg_free_buffers(&uvc->video.queue);
	uvc->func_connected = false;
	wake_up_interruptible(&uvc->func_connected_queue);
+26 −14
Original line number Diff line number Diff line
@@ -493,20 +493,19 @@ static void uvcg_video_pump(struct work_struct *work)
}

/*
 * Enable or disable the video stream.
 * Disable the video stream
 */
int uvcg_video_enable(struct uvc_video *video, int enable)
int
uvcg_video_disable(struct uvc_video *video)
{
	int ret;
	struct uvc_request *ureq;

	if (video->ep == NULL) {
		uvcg_info(&video->uvc->func,
			  "Video enable failed, device is uninitialized.\n");
			  "Video disable failed, device is uninitialized.\n");
		return -ENODEV;
	}

	if (!enable) {
	cancel_work_sync(&video->pump);
	uvcg_queue_cancel(&video->queue, 0);

@@ -520,6 +519,19 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
	return 0;
}

/*
 * Enable the video stream.
 */
int uvcg_video_enable(struct uvc_video *video)
{
	int ret;

	if (video->ep == NULL) {
		uvcg_info(&video->uvc->func,
			  "Video enable failed, device is uninitialized.\n");
		return -ENODEV;
	}

	if ((ret = uvcg_queue_enable(&video->queue, 1)) < 0)
		return ret;

+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@

struct uvc_video;

int uvcg_video_enable(struct uvc_video *video, int enable);
int uvcg_video_enable(struct uvc_video *video);
int uvcg_video_disable(struct uvc_video *video);

int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc);