media: videobuf2-v4l2.c: add vb2_video_unregister_device helper function
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 13 Jul 2020 11:30:42 +0000 (13:30 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 28 Aug 2020 12:58:48 +0000 (14:58 +0200)
commitf729ef5796d82a95758d9edc7eea5879a3a12b25
tree60ccd83fdbbb0e43b9eb32412fd70999f81c4e69
parent0832e07eee668020e8ec123e7da31b54a377db3d
media: videobuf2-v4l2.c: add vb2_video_unregister_device helper function

If a driver calls (_)vb2_fop_release(), then such a driver should also
call vb2_video_unregister_device() instead of video_unregister_device().
This helper will call vb2_queue_release() if a filehandle is marked as
owner of the queue. This ensures that at unregister time any streaming
is cancelled and all buffers are returned to userspace.

This is very useful for complex drivers since this stops all streaming
in all subdevs in the pipeline controlled by this video device. Otherwise
this would be delayed until the owner filehandle is closed, which can be
quite some time later.

Bonus points for ordering the includes :-)

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/common/videobuf2/videobuf2-v4l2.c
include/media/videobuf2-v4l2.h