diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-07-31 02:48:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-09 19:17:14 -0400 |
commit | 7224679a319fb1738f9da662287ce109d653f758 (patch) | |
tree | 056f7100d60ceed5a8a5126715de226a5ab85f5b /drivers/media/video | |
parent | 0b7286d92d43885410b7dbc55b16f658b26976f9 (diff) |
[media] vpif_capture: remove V4L2_FL_LOCK_ALL_FOPS
Add proper locking to the file operations, allowing for the removal
of the V4L2_FL_LOCK_ALL_FOPS flag.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/davinci/vpif_capture.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c index 266025e5d81d..1b625b065c32 100644 --- a/drivers/media/video/davinci/vpif_capture.c +++ b/drivers/media/video/davinci/vpif_capture.c | |||
@@ -820,10 +820,15 @@ static int vpif_mmap(struct file *filep, struct vm_area_struct *vma) | |||
820 | struct vpif_fh *fh = filep->private_data; | 820 | struct vpif_fh *fh = filep->private_data; |
821 | struct channel_obj *ch = fh->channel; | 821 | struct channel_obj *ch = fh->channel; |
822 | struct common_obj *common = &(ch->common[VPIF_VIDEO_INDEX]); | 822 | struct common_obj *common = &(ch->common[VPIF_VIDEO_INDEX]); |
823 | int ret; | ||
823 | 824 | ||
824 | vpif_dbg(2, debug, "vpif_mmap\n"); | 825 | vpif_dbg(2, debug, "vpif_mmap\n"); |
825 | 826 | ||
826 | return vb2_mmap(&common->buffer_queue, vma); | 827 | if (mutex_lock_interruptible(&common->lock)) |
828 | return -ERESTARTSYS; | ||
829 | ret = vb2_mmap(&common->buffer_queue, vma); | ||
830 | mutex_unlock(&common->lock); | ||
831 | return ret; | ||
827 | } | 832 | } |
828 | 833 | ||
829 | /** | 834 | /** |
@@ -836,12 +841,16 @@ static unsigned int vpif_poll(struct file *filep, poll_table * wait) | |||
836 | struct vpif_fh *fh = filep->private_data; | 841 | struct vpif_fh *fh = filep->private_data; |
837 | struct channel_obj *channel = fh->channel; | 842 | struct channel_obj *channel = fh->channel; |
838 | struct common_obj *common = &(channel->common[VPIF_VIDEO_INDEX]); | 843 | struct common_obj *common = &(channel->common[VPIF_VIDEO_INDEX]); |
844 | unsigned int res = 0; | ||
839 | 845 | ||
840 | vpif_dbg(2, debug, "vpif_poll\n"); | 846 | vpif_dbg(2, debug, "vpif_poll\n"); |
841 | 847 | ||
842 | if (common->started) | 848 | if (common->started) { |
843 | return vb2_poll(&common->buffer_queue, filep, wait); | 849 | mutex_lock(&common->lock); |
844 | return 0; | 850 | res = vb2_poll(&common->buffer_queue, filep, wait); |
851 | mutex_unlock(&common->lock); | ||
852 | } | ||
853 | return res; | ||
845 | } | 854 | } |
846 | 855 | ||
847 | /** | 856 | /** |
@@ -895,6 +904,10 @@ static int vpif_open(struct file *filep) | |||
895 | return -ENOMEM; | 904 | return -ENOMEM; |
896 | } | 905 | } |
897 | 906 | ||
907 | if (mutex_lock_interruptible(&common->lock)) { | ||
908 | kfree(fh); | ||
909 | return -ERESTARTSYS; | ||
910 | } | ||
898 | /* store pointer to fh in private_data member of filep */ | 911 | /* store pointer to fh in private_data member of filep */ |
899 | filep->private_data = fh; | 912 | filep->private_data = fh; |
900 | fh->channel = ch; | 913 | fh->channel = ch; |
@@ -912,6 +925,7 @@ static int vpif_open(struct file *filep) | |||
912 | /* Initialize priority of this instance to default priority */ | 925 | /* Initialize priority of this instance to default priority */ |
913 | fh->prio = V4L2_PRIORITY_UNSET; | 926 | fh->prio = V4L2_PRIORITY_UNSET; |
914 | v4l2_prio_open(&ch->prio, &fh->prio); | 927 | v4l2_prio_open(&ch->prio, &fh->prio); |
928 | mutex_unlock(&common->lock); | ||
915 | return 0; | 929 | return 0; |
916 | } | 930 | } |
917 | 931 | ||
@@ -932,6 +946,7 @@ static int vpif_release(struct file *filep) | |||
932 | 946 | ||
933 | common = &ch->common[VPIF_VIDEO_INDEX]; | 947 | common = &ch->common[VPIF_VIDEO_INDEX]; |
934 | 948 | ||
949 | mutex_lock(&common->lock); | ||
935 | /* if this instance is doing IO */ | 950 | /* if this instance is doing IO */ |
936 | if (fh->io_allowed[VPIF_VIDEO_INDEX]) { | 951 | if (fh->io_allowed[VPIF_VIDEO_INDEX]) { |
937 | /* Reset io_usrs member of channel object */ | 952 | /* Reset io_usrs member of channel object */ |
@@ -961,6 +976,7 @@ static int vpif_release(struct file *filep) | |||
961 | if (fh->initialized) | 976 | if (fh->initialized) |
962 | ch->initialized = 0; | 977 | ch->initialized = 0; |
963 | 978 | ||
979 | mutex_unlock(&common->lock); | ||
964 | filep->private_data = NULL; | 980 | filep->private_data = NULL; |
965 | kfree(fh); | 981 | kfree(fh); |
966 | return 0; | 982 | return 0; |
@@ -2208,10 +2224,6 @@ static __init int vpif_probe(struct platform_device *pdev) | |||
2208 | common = &(ch->common[VPIF_VIDEO_INDEX]); | 2224 | common = &(ch->common[VPIF_VIDEO_INDEX]); |
2209 | spin_lock_init(&common->irqlock); | 2225 | spin_lock_init(&common->irqlock); |
2210 | mutex_init(&common->lock); | 2226 | mutex_init(&common->lock); |
2211 | /* Locking in file operations other than ioctl should be done | ||
2212 | by the driver, not the V4L2 core. | ||
2213 | This driver needs auditing so that this flag can be removed. */ | ||
2214 | set_bit(V4L2_FL_LOCK_ALL_FOPS, &ch->video_dev->flags); | ||
2215 | ch->video_dev->lock = &common->lock; | 2227 | ch->video_dev->lock = &common->lock; |
2216 | /* Initialize prio member of channel object */ | 2228 | /* Initialize prio member of channel object */ |
2217 | v4l2_prio_init(&ch->prio); | 2229 | v4l2_prio_init(&ch->prio); |