[media] uvcvideo: Separate video and queue enable/disable operations
[firefly-linux-kernel-4.4.55.git] / drivers / media / usb / uvc / uvc_v4l2.c
index a16fe2167976d9c88c1098a6b1f51f0a1ade24ce..e8bf4f149a26c1d64f24d308d611717c43050c51 100644 (file)
@@ -532,6 +532,7 @@ static int uvc_v4l2_release(struct file *file)
        /* Only free resources if this is a privileged handle. */
        if (uvc_has_privileges(handle)) {
                uvc_video_enable(stream, 0);
+               uvc_queue_enable(&stream->queue, 0);
                uvc_free_buffers(&stream->queue);
        }
 
@@ -766,7 +767,15 @@ static int uvc_ioctl_streamon(struct file *file, void *fh,
                return -EBUSY;
 
        mutex_lock(&stream->mutex);
+       ret = uvc_queue_enable(&stream->queue, 1);
+       if (ret < 0)
+               goto done;
+
        ret = uvc_video_enable(stream, 1);
+       if (ret < 0)
+               uvc_queue_enable(&stream->queue, 0);
+
+done:
        mutex_unlock(&stream->mutex);
 
        return ret;
@@ -777,7 +786,6 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
 {
        struct uvc_fh *handle = fh;
        struct uvc_streaming *stream = handle->stream;
-       int ret;
 
        if (type != stream->type)
                return -EINVAL;
@@ -786,10 +794,11 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
                return -EBUSY;
 
        mutex_lock(&stream->mutex);
-       ret = uvc_video_enable(stream, 0);
+       uvc_video_enable(stream, 0);
+       uvc_queue_enable(&stream->queue, 0);
        mutex_unlock(&stream->mutex);
 
-       return ret;
+       return 0;
 }
 
 static int uvc_ioctl_enum_input(struct file *file, void *fh,