From 28955a61568ca4ef39ef7fc814b443be24616c64 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 1 Dec 2020 13:44:43 +0100 Subject: media: v4l2-dev/event: add v4l2_event_wake_all() When unregistering a V4L2 device node, make sure any filehandles that are waiting for an event are woken up. Add v4l2_event_wake_all() to v4l2-event.c and call it from video_unregister_device(). Otherwise userspace might never know that a device node was removed. [hverkuil: checkpatch: replaced 'if (vdev == NULL)' by 'if (!vdev)'] Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-event.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h index 3f0281d06ec7..4ffa914ade3a 100644 --- a/include/media/v4l2-event.h +++ b/include/media/v4l2-event.h @@ -101,7 +101,7 @@ int v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event, * * .. note:: * The driver's only responsibility is to fill in the type and the data - * fields.The other fields will be filled in by V4L2. + * fields. The other fields will be filled in by V4L2. */ void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev); @@ -116,10 +116,19 @@ void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev); * * .. note:: * The driver's only responsibility is to fill in the type and the data - * fields.The other fields will be filled in by V4L2. + * fields. The other fields will be filled in by V4L2. */ void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev); +/** + * v4l2_event_wake_all - Wake all filehandles. + * + * Used when unregistering a video device. + * + * @vdev: pointer to &struct video_device + */ +void v4l2_event_wake_all(struct video_device *vdev); + /** * v4l2_event_pending - Check if an event is available * -- cgit v1.2.3