diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2011-01-08 07:38:02 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 15:37:58 -0400 |
commit | dfddb2441f39e8c0254504516be35b854addf6fa (patch) | |
tree | 7fd4bade365e394e38aee0764adca945a5bf394d /drivers/media | |
parent | 73cb42068cff419e72456940c713ceb5efa68c2a (diff) |
[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 <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/v4l2-fh.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/media/video/v4l2-fh.c b/drivers/media/video/v4l2-fh.c index 27242e5ca431..543b3fe6784e 100644 --- a/drivers/media/video/v4l2-fh.c +++ b/drivers/media/video/v4l2-fh.c | |||
@@ -109,3 +109,17 @@ int v4l2_fh_release(struct file *filp) | |||
109 | return 0; | 109 | return 0; |
110 | } | 110 | } |
111 | EXPORT_SYMBOL_GPL(v4l2_fh_release); | 111 | EXPORT_SYMBOL_GPL(v4l2_fh_release); |
112 | |||
113 | int v4l2_fh_is_singular(struct v4l2_fh *fh) | ||
114 | { | ||
115 | unsigned long flags; | ||
116 | int is_singular; | ||
117 | |||
118 | if (fh == NULL || fh->vdev == NULL) | ||
119 | return 0; | ||
120 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); | ||
121 | is_singular = list_is_singular(&fh->list); | ||
122 | spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); | ||
123 | return is_singular; | ||
124 | } | ||
125 | EXPORT_SYMBOL_GPL(v4l2_fh_is_singular); | ||