From c765b741e9d47d16c0933baadf7ff28a6ed01eb9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 8 Jan 2011 09:38:02 -0300 Subject: [PATCH] --- yaml --- r: 242119 b: refs/heads/master c: dfddb2441f39e8c0254504516be35b854addf6fa h: refs/heads/master i: 242117: 2e1178d578b54dbd83097d45c8340206fcd38c2b 242115: 15cce80df6c3de183fe831ab1609c66160561daf 242111: bf5ced2e5fc24378ac66e46547b1240097f2ec0b v: v3 --- [refs] | 2 +- trunk/drivers/media/video/v4l2-fh.c | 14 ++++++++++++++ trunk/include/media/v4l2-fh.h | 13 +++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index b193ec07c467..86d01b344631 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 73cb42068cff419e72456940c713ceb5efa68c2a +refs/heads/master: dfddb2441f39e8c0254504516be35b854addf6fa diff --git a/trunk/drivers/media/video/v4l2-fh.c b/trunk/drivers/media/video/v4l2-fh.c index 27242e5ca431..543b3fe6784e 100644 --- a/trunk/drivers/media/video/v4l2-fh.c +++ b/trunk/drivers/media/video/v4l2-fh.c @@ -109,3 +109,17 @@ int v4l2_fh_release(struct file *filp) return 0; } EXPORT_SYMBOL_GPL(v4l2_fh_release); + +int v4l2_fh_is_singular(struct v4l2_fh *fh) +{ + unsigned long flags; + int is_singular; + + if (fh == NULL || fh->vdev == NULL) + return 0; + spin_lock_irqsave(&fh->vdev->fh_lock, flags); + is_singular = list_is_singular(&fh->list); + spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); + return is_singular; +} +EXPORT_SYMBOL_GPL(v4l2_fh_is_singular); diff --git a/trunk/include/media/v4l2-fh.h b/trunk/include/media/v4l2-fh.h index 5657881cd44e..0206aa55be24 100644 --- a/trunk/include/media/v4l2-fh.h +++ b/trunk/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 */