aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/arv.c19
-rw-r--r--drivers/media/video/bw-qcam.c21
-rw-r--r--drivers/media/video/bw-qcam.h1
-rw-r--r--drivers/media/video/c-qcam.c22
-rw-r--r--drivers/media/video/meye.c16
-rw-r--r--drivers/media/video/meye.h1
-rw-r--r--drivers/media/video/pms.c22
-rw-r--r--drivers/media/video/saa5246a.c30
-rw-r--r--drivers/media/video/saa5249.c47
-rw-r--r--drivers/media/video/w9966.c22
10 files changed, 128 insertions, 73 deletions
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 9e436ad3d34b..0d4f9b683459 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -116,6 +116,7 @@ struct ar_device {
116 int width, height; 116 int width, height;
117 int frame_bytes, line_bytes; 117 int frame_bytes, line_bytes;
118 wait_queue_head_t wait; 118 wait_queue_head_t wait;
119 unsigned long in_use;
119 struct mutex lock; 120 struct mutex lock;
120}; 121};
121 122
@@ -742,10 +743,23 @@ void ar_release(struct video_device *vfd)
742 * Video4Linux Module functions 743 * Video4Linux Module functions
743 * 744 *
744 ****************************************************************************/ 745 ****************************************************************************/
746static struct ar_device ardev;
747
748static int ar_exclusive_open(struct inode *inode, struct file *file)
749{
750 return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0;
751}
752
753static int ar_exclusive_release(struct inode *inode, struct file *file)
754{
755 clear_bit(0, &ardev.in_use);
756 return 0;
757}
758
745static const struct file_operations ar_fops = { 759static const struct file_operations ar_fops = {
746 .owner = THIS_MODULE, 760 .owner = THIS_MODULE,
747 .open = video_exclusive_open, 761 .open = ar_exclusive_open,
748 .release = video_exclusive_release, 762 .release = ar_exclusive_release,
749 .read = ar_read, 763 .read = ar_read,
750 .ioctl = ar_ioctl, 764 .ioctl = ar_ioctl,
751#ifdef CONFIG_COMPAT 765#ifdef CONFIG_COMPAT
@@ -762,7 +776,6 @@ static struct video_device ar_template = {
762}; 776};
763 777
764#define ALIGN4(x) ((((int)(x)) & 0x3) == 0) 778#define ALIGN4(x) ((((int)(x)) & 0x3) == 0)
765static struct ar_device ardev;
766 779
767static int __init ar_init(void) 780static int __init ar_init(void)
768{ 781{
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 01f07707827f..e8e1bb122b59 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -894,10 +894,27 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
894 return len; 894 return len;
895} 895}
896 896
897static int qcam_exclusive_open(struct inode *inode, struct file *file)
898{
899 struct video_device *dev = video_devdata(file);
900 struct qcam_device *qcam = (struct qcam_device *)dev;
901
902 return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0;
903}
904
905static int qcam_exclusive_release(struct inode *inode, struct file *file)
906{
907 struct video_device *dev = video_devdata(file);
908 struct qcam_device *qcam = (struct qcam_device *)dev;
909
910 clear_bit(0, &qcam->in_use);
911 return 0;
912}
913
897static const struct file_operations qcam_fops = { 914static const struct file_operations qcam_fops = {
898 .owner = THIS_MODULE, 915 .owner = THIS_MODULE,
899 .open = video_exclusive_open, 916 .open = qcam_exclusive_open,
900 .release = video_exclusive_release, 917 .release = qcam_exclusive_release,
901 .ioctl = qcam_ioctl, 918 .ioctl = qcam_ioctl,
902#ifdef CONFIG_COMPAT 919#ifdef CONFIG_COMPAT
903 .compat_ioctl = v4l_compat_ioctl32, 920 .compat_ioctl = v4l_compat_ioctl32,
diff --git a/drivers/media/video/bw-qcam.h b/drivers/media/video/bw-qcam.h
index 6701dafbc0da..8a60c5de0935 100644
--- a/drivers/media/video/bw-qcam.h
+++ b/drivers/media/video/bw-qcam.h
@@ -65,4 +65,5 @@ struct qcam_device {
65 int top, left; 65 int top, left;
66 int status; 66 int status;
67 unsigned int saved_bits; 67 unsigned int saved_bits;
68 unsigned long in_use;
68}; 69};
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 7f6c6b4bec10..2196c1dc5aee 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -51,6 +51,7 @@ struct qcam_device {
51 int contrast, brightness, whitebal; 51 int contrast, brightness, whitebal;
52 int top, left; 52 int top, left;
53 unsigned int bidirectional; 53 unsigned int bidirectional;
54 unsigned long in_use;
54 struct mutex lock; 55 struct mutex lock;
55}; 56};
56 57
@@ -687,11 +688,28 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
687 return len; 688 return len;
688} 689}
689 690
691static int qcam_exclusive_open(struct inode *inode, struct file *file)
692{
693 struct video_device *dev = video_devdata(file);
694 struct qcam_device *qcam = (struct qcam_device *)dev;
695
696 return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0;
697}
698
699static int qcam_exclusive_release(struct inode *inode, struct file *file)
700{
701 struct video_device *dev = video_devdata(file);
702 struct qcam_device *qcam = (struct qcam_device *)dev;
703
704 clear_bit(0, &qcam->in_use);
705 return 0;
706}
707
690/* video device template */ 708/* video device template */
691static const struct file_operations qcam_fops = { 709static const struct file_operations qcam_fops = {
692 .owner = THIS_MODULE, 710 .owner = THIS_MODULE,
693 .open = video_exclusive_open, 711 .open = qcam_exclusive_open,
694 .release = video_exclusive_release, 712 .release = qcam_exclusive_release,
695 .ioctl = qcam_ioctl, 713 .ioctl = qcam_ioctl,
696#ifdef CONFIG_COMPAT 714#ifdef CONFIG_COMPAT
697 .compat_ioctl = v4l_compat_ioctl32, 715 .compat_ioctl = v4l_compat_ioctl32,
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 102a5b9cfd12..6418f4a78f2a 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -843,21 +843,16 @@ again:
843 843
844static int meye_open(struct inode *inode, struct file *file) 844static int meye_open(struct inode *inode, struct file *file)
845{ 845{
846 int i, err; 846 int i;
847 847
848 lock_kernel(); 848 if (test_and_set_bit(0, &meye.in_use))
849 err = video_exclusive_open(inode, file); 849 return -EBUSY;
850 if (err < 0) {
851 unlock_kernel();
852 return err;
853 }
854 850
855 mchip_hic_stop(); 851 mchip_hic_stop();
856 852
857 if (mchip_dma_alloc()) { 853 if (mchip_dma_alloc()) {
858 printk(KERN_ERR "meye: mchip framebuffer allocation failed\n"); 854 printk(KERN_ERR "meye: mchip framebuffer allocation failed\n");
859 video_exclusive_release(inode, file); 855 clear_bit(0, &meye.in_use);
860 unlock_kernel();
861 return -ENOBUFS; 856 return -ENOBUFS;
862 } 857 }
863 858
@@ -865,7 +860,6 @@ static int meye_open(struct inode *inode, struct file *file)
865 meye.grab_buffer[i].state = MEYE_BUF_UNUSED; 860 meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
866 kfifo_reset(meye.grabq); 861 kfifo_reset(meye.grabq);
867 kfifo_reset(meye.doneq); 862 kfifo_reset(meye.doneq);
868 unlock_kernel();
869 return 0; 863 return 0;
870} 864}
871 865
@@ -873,7 +867,7 @@ static int meye_release(struct inode *inode, struct file *file)
873{ 867{
874 mchip_hic_stop(); 868 mchip_hic_stop();
875 mchip_dma_free(); 869 mchip_dma_free();
876 video_exclusive_release(inode, file); 870 clear_bit(0, &meye.in_use);
877 return 0; 871 return 0;
878} 872}
879 873
diff --git a/drivers/media/video/meye.h b/drivers/media/video/meye.h
index d535748df445..5f70a106ba2b 100644
--- a/drivers/media/video/meye.h
+++ b/drivers/media/video/meye.h
@@ -311,6 +311,7 @@ struct meye {
311 struct video_device *video_dev; /* video device parameters */ 311 struct video_device *video_dev; /* video device parameters */
312 struct video_picture picture; /* video picture parameters */ 312 struct video_picture picture; /* video picture parameters */
313 struct meye_params params; /* additional parameters */ 313 struct meye_params params; /* additional parameters */
314 unsigned long in_use; /* set to 1 if the device is in use */
314#ifdef CONFIG_PM 315#ifdef CONFIG_PM
315 u8 pm_mchip_mode; /* old mchip mode */ 316 u8 pm_mchip_mode; /* old mchip mode */
316#endif 317#endif
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 7c84f795db54..b39794f0baf5 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -47,6 +47,7 @@ struct pms_device
47 struct video_picture picture; 47 struct video_picture picture;
48 int height; 48 int height;
49 int width; 49 int width;
50 unsigned long in_use;
50 struct mutex lock; 51 struct mutex lock;
51}; 52};
52 53
@@ -881,10 +882,27 @@ static ssize_t pms_read(struct file *file, char __user *buf,
881 return len; 882 return len;
882} 883}
883 884
885static int pms_exclusive_open(struct inode *inode, struct file *file)
886{
887 struct video_device *v = video_devdata(file);
888 struct pms_device *pd = (struct pms_device *)v;
889
890 return test_and_set_bit(0, &pd->in_use) ? -EBUSY : 0;
891}
892
893static int pms_exclusive_release(struct inode *inode, struct file *file)
894{
895 struct video_device *v = video_devdata(file);
896 struct pms_device *pd = (struct pms_device *)v;
897
898 clear_bit(0, &pd->in_use);
899 return 0;
900}
901
884static const struct file_operations pms_fops = { 902static const struct file_operations pms_fops = {
885 .owner = THIS_MODULE, 903 .owner = THIS_MODULE,
886 .open = video_exclusive_open, 904 .open = pms_exclusive_open,
887 .release = video_exclusive_release, 905 .release = pms_exclusive_release,
888 .ioctl = pms_ioctl, 906 .ioctl = pms_ioctl,
889#ifdef CONFIG_COMPAT 907#ifdef CONFIG_COMPAT
890 .compat_ioctl = v4l_compat_ioctl32, 908 .compat_ioctl = v4l_compat_ioctl32,
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index e2c538ee88f2..5f5aa2063e0e 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -61,6 +61,7 @@ struct saa5246a_device
61 u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE]; 61 u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE];
62 int is_searching[NUM_DAUS]; 62 int is_searching[NUM_DAUS];
63 struct i2c_client *client; 63 struct i2c_client *client;
64 unsigned long in_use;
64 struct mutex lock; 65 struct mutex lock;
65}; 66};
66 67
@@ -736,22 +737,14 @@ static int saa5246a_open(struct inode *inode, struct file *file)
736{ 737{
737 struct video_device *vd = video_devdata(file); 738 struct video_device *vd = video_devdata(file);
738 struct saa5246a_device *t = vd->priv; 739 struct saa5246a_device *t = vd->priv;
739 int err;
740 740
741 lock_kernel(); 741 if (t->client == NULL)
742 err = video_exclusive_open(inode,file); 742 return -ENODEV;
743 if (err < 0) {
744 unlock_kernel();
745 return err;
746 }
747 743
748 if (t->client==NULL) { 744 if (test_and_set_bit(0, &t->in_use))
749 err = -ENODEV; 745 return -EBUSY;
750 goto fail;
751 }
752 746
753 if (i2c_senddata(t, SAA5246A_REGISTER_R0, 747 if (i2c_senddata(t, SAA5246A_REGISTER_R0,
754
755 R0_SELECT_R11 | 748 R0_SELECT_R11 |
756 R0_PLL_TIME_CONSTANT_LONG | 749 R0_PLL_TIME_CONSTANT_LONG |
757 R0_ENABLE_nODD_EVEN_OUTPUT | 750 R0_ENABLE_nODD_EVEN_OUTPUT |
@@ -777,17 +770,10 @@ static int saa5246a_open(struct inode *inode, struct file *file)
777 770
778 COMMAND_END)) 771 COMMAND_END))
779 { 772 {
780 err = -EIO; 773 clear_bit(0, &t->in_use);
781 goto fail; 774 return -EIO;
782 } 775 }
783 unlock_kernel();
784
785 return 0; 776 return 0;
786
787fail:
788 video_exclusive_release(inode,file);
789 unlock_kernel();
790 return err;
791} 777}
792 778
793static int saa5246a_release(struct inode *inode, struct file *file) 779static int saa5246a_release(struct inode *inode, struct file *file)
@@ -806,7 +792,7 @@ static int saa5246a_release(struct inode *inode, struct file *file)
806 R1_VCS_TO_SCS, 792 R1_VCS_TO_SCS,
807 793
808 COMMAND_END); 794 COMMAND_END);
809 video_exclusive_release(inode,file); 795 clear_bit(0, &t->in_use);
810 return 0; 796 return 0;
811} 797}
812 798
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 96c0fdf1a051..dfd8a9338c55 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -110,6 +110,7 @@ struct saa5249_device
110 int disp_mode; 110 int disp_mode;
111 int virtual_mode; 111 int virtual_mode;
112 struct i2c_client *client; 112 struct i2c_client *client;
113 unsigned long in_use;
113 struct mutex lock; 114 struct mutex lock;
114}; 115};
115 116
@@ -631,34 +632,27 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
631static int saa5249_open(struct inode *inode, struct file *file) 632static int saa5249_open(struct inode *inode, struct file *file)
632{ 633{
633 struct video_device *vd = video_devdata(file); 634 struct video_device *vd = video_devdata(file);
634 struct saa5249_device *t=vd->priv; 635 struct saa5249_device *t = vd->priv;
635 int err,pgbuf; 636 int pgbuf;
636 637
637 lock_kernel(); 638 if (t->client == NULL)
638 err = video_exclusive_open(inode,file); 639 return -ENODEV;
639 if (err < 0) {
640 unlock_kernel();
641 return err;
642 }
643 640
644 if (t->client==NULL) { 641 if (test_and_set_bit(0, &t->in_use))
645 err = -ENODEV; 642 return -EBUSY;
646 goto fail;
647 }
648 643
649 if (i2c_senddata(t, 0, 0, -1) || /* Select R11 */ 644 if (i2c_senddata(t, 0, 0, -1) || /* Select R11 */
650 /* Turn off parity checks (we do this ourselves) */ 645 /* Turn off parity checks (we do this ourselves) */
651 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) || 646 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) ||
652 /* Display TV-picture, no virtual rows */ 647 /* Display TV-picture, no virtual rows */
653 i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */ 648 i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1))
654 649 /* Set display to page 4 */
655 { 650 {
656 err = -EIO; 651 clear_bit(0, &t->in_use);
657 goto fail; 652 return -EIO;
658 } 653 }
659 654
660 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 655 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) {
661 {
662 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 656 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
663 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); 657 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
664 memset(t->vdau[pgbuf].laststat, 0, sizeof(t->vdau[0].laststat)); 658 memset(t->vdau[pgbuf].laststat, 0, sizeof(t->vdau[0].laststat));
@@ -668,13 +662,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
668 t->is_searching[pgbuf] = false; 662 t->is_searching[pgbuf] = false;
669 } 663 }
670 t->virtual_mode = false; 664 t->virtual_mode = false;
671 unlock_kernel();
672 return 0; 665 return 0;
673
674 fail:
675 video_exclusive_release(inode,file);
676 unlock_kernel();
677 return err;
678} 666}
679 667
680 668
@@ -682,10 +670,11 @@ static int saa5249_open(struct inode *inode, struct file *file)
682static int saa5249_release(struct inode *inode, struct file *file) 670static int saa5249_release(struct inode *inode, struct file *file)
683{ 671{
684 struct video_device *vd = video_devdata(file); 672 struct video_device *vd = video_devdata(file);
685 struct saa5249_device *t=vd->priv; 673 struct saa5249_device *t = vd->priv;
674
686 i2c_senddata(t, 1, 0x20, -1); /* Turn off CCT */ 675 i2c_senddata(t, 1, 0x20, -1); /* Turn off CCT */
687 i2c_senddata(t, 5, 3, 3, -1); /* Turn off TV-display */ 676 i2c_senddata(t, 5, 3, 3, -1); /* Turn off TV-display */
688 video_exclusive_release(inode,file); 677 clear_bit(0, &t->in_use);
689 return 0; 678 return 0;
690} 679}
691 680
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 2ff00bc5ad64..c635cffb1fb8 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -113,6 +113,7 @@ struct w9966_dev {
113 signed char contrast; 113 signed char contrast;
114 signed char color; 114 signed char color;
115 signed char hue; 115 signed char hue;
116 unsigned long in_use;
116}; 117};
117 118
118/* 119/*
@@ -184,10 +185,27 @@ static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
184static ssize_t w9966_v4l_read(struct file *file, char __user *buf, 185static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
185 size_t count, loff_t *ppos); 186 size_t count, loff_t *ppos);
186 187
188static int w9966_exclusive_open(struct inode *inode, struct file *file)
189{
190 struct video_device *vdev = video_devdata(file);
191 struct w9966_dev *cam = vdev->priv;
192
193 return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0;
194}
195
196static int w9966_exclusive_release(struct inode *inode, struct file *file)
197{
198 struct video_device *vdev = video_devdata(file);
199 struct w9966_dev *cam = vdev->priv;
200
201 clear_bit(0, &cam->in_use);
202 return 0;
203}
204
187static const struct file_operations w9966_fops = { 205static const struct file_operations w9966_fops = {
188 .owner = THIS_MODULE, 206 .owner = THIS_MODULE,
189 .open = video_exclusive_open, 207 .open = w9966_exclusive_open,
190 .release = video_exclusive_release, 208 .release = w9966_exclusive_release,
191 .ioctl = w9966_v4l_ioctl, 209 .ioctl = w9966_v4l_ioctl,
192#ifdef CONFIG_COMPAT 210#ifdef CONFIG_COMPAT
193 .compat_ioctl = v4l_compat_ioctl32, 211 .compat_ioctl = v4l_compat_ioctl32,