diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-24 06:02:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-09 19:16:20 -0400 |
commit | 00ccdc3c3316fbe01ef810bbc52239843af5eef9 (patch) | |
tree | 6062f77ebb1097ca805088ba41ca17bbfeb083b2 | |
parent | de40cb227d1948490da7fd833100ae7a4ae7d825 (diff) |
[media] s5p-tv: 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>
-rw-r--r-- | drivers/media/video/s5p-tv/mixer_video.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/media/video/s5p-tv/mixer_video.c b/drivers/media/video/s5p-tv/mixer_video.c index 6c74b05d1f95..e0e02cce1bcb 100644 --- a/drivers/media/video/s5p-tv/mixer_video.c +++ b/drivers/media/video/s5p-tv/mixer_video.c | |||
@@ -750,18 +750,20 @@ static int mxr_video_open(struct file *file) | |||
750 | int ret = 0; | 750 | int ret = 0; |
751 | 751 | ||
752 | mxr_dbg(mdev, "%s:%d\n", __func__, __LINE__); | 752 | mxr_dbg(mdev, "%s:%d\n", __func__, __LINE__); |
753 | if (mutex_lock_interruptible(&layer->mutex)) | ||
754 | return -ERESTARTSYS; | ||
753 | /* assure device probe is finished */ | 755 | /* assure device probe is finished */ |
754 | wait_for_device_probe(); | 756 | wait_for_device_probe(); |
755 | /* creating context for file descriptor */ | 757 | /* creating context for file descriptor */ |
756 | ret = v4l2_fh_open(file); | 758 | ret = v4l2_fh_open(file); |
757 | if (ret) { | 759 | if (ret) { |
758 | mxr_err(mdev, "v4l2_fh_open failed\n"); | 760 | mxr_err(mdev, "v4l2_fh_open failed\n"); |
759 | return ret; | 761 | goto unlock; |
760 | } | 762 | } |
761 | 763 | ||
762 | /* leaving if layer is already initialized */ | 764 | /* leaving if layer is already initialized */ |
763 | if (!v4l2_fh_is_singular_file(file)) | 765 | if (!v4l2_fh_is_singular_file(file)) |
764 | return 0; | 766 | goto unlock; |
765 | 767 | ||
766 | /* FIXME: should power be enabled on open? */ | 768 | /* FIXME: should power be enabled on open? */ |
767 | ret = mxr_power_get(mdev); | 769 | ret = mxr_power_get(mdev); |
@@ -779,6 +781,7 @@ static int mxr_video_open(struct file *file) | |||
779 | layer->fmt = layer->fmt_array[0]; | 781 | layer->fmt = layer->fmt_array[0]; |
780 | /* setup default geometry */ | 782 | /* setup default geometry */ |
781 | mxr_layer_default_geo(layer); | 783 | mxr_layer_default_geo(layer); |
784 | mutex_unlock(&layer->mutex); | ||
782 | 785 | ||
783 | return 0; | 786 | return 0; |
784 | 787 | ||
@@ -788,6 +791,9 @@ fail_power: | |||
788 | fail_fh_open: | 791 | fail_fh_open: |
789 | v4l2_fh_release(file); | 792 | v4l2_fh_release(file); |
790 | 793 | ||
794 | unlock: | ||
795 | mutex_unlock(&layer->mutex); | ||
796 | |||
791 | return ret; | 797 | return ret; |
792 | } | 798 | } |
793 | 799 | ||
@@ -795,19 +801,28 @@ static unsigned int | |||
795 | mxr_video_poll(struct file *file, struct poll_table_struct *wait) | 801 | mxr_video_poll(struct file *file, struct poll_table_struct *wait) |
796 | { | 802 | { |
797 | struct mxr_layer *layer = video_drvdata(file); | 803 | struct mxr_layer *layer = video_drvdata(file); |
804 | unsigned int res; | ||
798 | 805 | ||
799 | mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__); | 806 | mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__); |
800 | 807 | ||
801 | return vb2_poll(&layer->vb_queue, file, wait); | 808 | mutex_lock(&layer->mutex); |
809 | res = vb2_poll(&layer->vb_queue, file, wait); | ||
810 | mutex_unlock(&layer->mutex); | ||
811 | return res; | ||
802 | } | 812 | } |
803 | 813 | ||
804 | static int mxr_video_mmap(struct file *file, struct vm_area_struct *vma) | 814 | static int mxr_video_mmap(struct file *file, struct vm_area_struct *vma) |
805 | { | 815 | { |
806 | struct mxr_layer *layer = video_drvdata(file); | 816 | struct mxr_layer *layer = video_drvdata(file); |
817 | int ret; | ||
807 | 818 | ||
808 | mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__); | 819 | mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__); |
809 | 820 | ||
810 | return vb2_mmap(&layer->vb_queue, vma); | 821 | if (mutex_lock_interruptible(&layer->mutex)) |
822 | return -ERESTARTSYS; | ||
823 | ret = vb2_mmap(&layer->vb_queue, vma); | ||
824 | mutex_unlock(&layer->mutex); | ||
825 | return ret; | ||
811 | } | 826 | } |
812 | 827 | ||
813 | static int mxr_video_release(struct file *file) | 828 | static int mxr_video_release(struct file *file) |
@@ -815,11 +830,13 @@ static int mxr_video_release(struct file *file) | |||
815 | struct mxr_layer *layer = video_drvdata(file); | 830 | struct mxr_layer *layer = video_drvdata(file); |
816 | 831 | ||
817 | mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__); | 832 | mxr_dbg(layer->mdev, "%s:%d\n", __func__, __LINE__); |
833 | mutex_lock(&layer->mutex); | ||
818 | if (v4l2_fh_is_singular_file(file)) { | 834 | if (v4l2_fh_is_singular_file(file)) { |
819 | vb2_queue_release(&layer->vb_queue); | 835 | vb2_queue_release(&layer->vb_queue); |
820 | mxr_power_put(layer->mdev); | 836 | mxr_power_put(layer->mdev); |
821 | } | 837 | } |
822 | v4l2_fh_release(file); | 838 | v4l2_fh_release(file); |
839 | mutex_unlock(&layer->mutex); | ||
823 | return 0; | 840 | return 0; |
824 | } | 841 | } |
825 | 842 | ||
@@ -1069,10 +1086,6 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev, | |||
1069 | set_bit(V4L2_FL_USE_FH_PRIO, &layer->vfd.flags); | 1086 | set_bit(V4L2_FL_USE_FH_PRIO, &layer->vfd.flags); |
1070 | 1087 | ||
1071 | video_set_drvdata(&layer->vfd, layer); | 1088 | video_set_drvdata(&layer->vfd, layer); |
1072 | /* Locking in file operations other than ioctl should be done | ||
1073 | by the driver, not the V4L2 core. | ||
1074 | This driver needs auditing so that this flag can be removed. */ | ||
1075 | set_bit(V4L2_FL_LOCK_ALL_FOPS, &layer->vfd.flags); | ||
1076 | layer->vfd.lock = &layer->mutex; | 1089 | layer->vfd.lock = &layer->mutex; |
1077 | layer->vfd.v4l2_dev = &mdev->v4l2_dev; | 1090 | layer->vfd.v4l2_dev = &mdev->v4l2_dev; |
1078 | 1091 | ||