From dfddb2441f39e8c0254504516be35b854addf6fa Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 8 Jan 2011 09:38:02 -0300 Subject: [media] v4l2-fh: add v4l2_fh_is_singular Several drivers need to do something when the first filehandle is opened or the last filehandle is closed. Most implement some use count mechanism, but if they use v4l2_fh, then you can also just check if this is the only filehandle for the device node. A simple helper function can do this. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-fh.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/media/v4l2-fh.h') diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h index 5657881cd44..0206aa55be2 100644 --- a/include/media/v4l2-fh.h +++ b/include/media/v4l2-fh.h @@ -77,5 +77,18 @@ void v4l2_fh_exit(struct v4l2_fh *fh); * v4l2_fh struct) is NULL. This function always returns 0. */ int v4l2_fh_release(struct file *filp); +/* + * Returns 1 if this filehandle is the only filehandle opened for the + * associated video_device. If fh is NULL, then it returns 0. + */ +int v4l2_fh_is_singular(struct v4l2_fh *fh); +/* + * Helper function with struct file as argument. If filp->private_data is + * NULL, then it will return 0. + */ +static inline int v4l2_fh_is_singular_file(struct file *filp) +{ + return v4l2_fh_is_singular(filp->private_data); +} #endif /* V4L2_EVENT_H */ -- cgit v1.2.3-70-g09d2