[media] pwc: Allow multiple opens
Allow multiple opens of the /dev/video node so that control panel apps
can be open to-gether with streaming apps.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index b591b72..a6b5fde 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -678,12 +678,6 @@
if (!pdev->udev)
return -ENODEV;
- if (pdev->vopen) {
- PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n");
- return -EBUSY;
- }
-
- pdev->vopen++;
file->private_data = vdev;
PWC_DEBUG_OPEN("<< video_open() returns 0.\n");
return 0;
@@ -718,10 +712,12 @@
PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev);
pdev = video_get_drvdata(vdev);
- vb2_queue_release(&pdev->vb_queue);
- pdev->vopen--;
+ if (pdev->capt_file == file) {
+ vb2_queue_release(&pdev->vb_queue);
+ pdev->capt_file = NULL;
+ }
- PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen);
+ PWC_DEBUG_OPEN("<< video_close()\n");
return 0;
}
@@ -734,6 +730,12 @@
if (!pdev->udev)
return -ENODEV;
+ if (pdev->capt_file != NULL &&
+ pdev->capt_file != file)
+ return -EBUSY;
+
+ pdev->capt_file = file;
+
return vb2_read(&pdev->vb_queue, buf, count, ppos,
file->f_flags & O_NONBLOCK);
}
@@ -754,6 +756,9 @@
struct video_device *vdev = file->private_data;
struct pwc_device *pdev = video_get_drvdata(vdev);
+ if (pdev->capt_file != file)
+ return -EBUSY;
+
return vb2_mmap(&pdev->vb_queue, vma);
}