aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2020-12-01 13:44:45 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-01-04 13:16:28 +0100
commit5cb0a64effe7608d6fd46f5be3106b1b73300621 (patch)
tree7de3272dfafd1afa497ef2810db4e79f64b43b7c /drivers/media/v4l2-core
parentmedia: vivid: call v4l2_event_wake_all() on disconnect (diff)
downloadlinux-dev-5cb0a64effe7608d6fd46f5be3106b1b73300621.tar.xz
linux-dev-5cb0a64effe7608d6fd46f5be3106b1b73300621.zip
media: v4l2-dev: add EPOLLPRI in v4l2_poll() when dev is unregistered
If the V4L2 device was unregistered, then add EPOLLPRI to the poll mask. Otherwise a select() that only waits for exceptions will not wake up. A select() that waits for read and/or write events *will* wake up on an EPOLLERR, but not (for some reason) if it just waits for exceptions. Strangly the epoll functionality will wakeup on EPOLLERR if you just wait for an exception, so in this respect select() and epoll differ. In the end it doesn't really matter, what matters is that polling file handles are woken up on device unregistration. It also improves the code a bit if vdev->fops->poll is NULL: this didn't check for device unregistration. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-dev.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 0ddc3554f1a4..f9cff033d0dc 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -339,12 +339,14 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
static __poll_t v4l2_poll(struct file *filp, struct poll_table_struct *poll)
{
struct video_device *vdev = video_devdata(filp);
- __poll_t res = EPOLLERR | EPOLLHUP;
+ __poll_t res = EPOLLERR | EPOLLHUP | EPOLLPRI;
- if (!vdev->fops->poll)
- return DEFAULT_POLLMASK;
- if (video_is_registered(vdev))
- res = vdev->fops->poll(filp, poll);
+ if (video_is_registered(vdev)) {
+ if (!vdev->fops->poll)
+ res = DEFAULT_POLLMASK;
+ else
+ res = vdev->fops->poll(filp, poll);
+ }
if (vdev->dev_debug & V4L2_DEV_DEBUG_POLL)
dprintk("%s: poll: %08x\n",
video_device_node_name(vdev), res);