aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/zr364xx.c
diff options
context:
space:
mode:
authorAntoine Jacquet <royale@zerezo.com>2008-08-18 16:14:30 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:36:51 -0400
commit33d27a45165ae9c3551e8d7c1186a5583371e5c4 (patch)
treea445470f5ae0c398bb9ee7b4567ccb6662a6c7d9 /drivers/media/video/zr364xx.c
parent69025c934b21a9ce49a76dfef59f1ebdfbe96c78 (diff)
V4L/DVB (8732): zr364xx: handle video exclusive open internaly
Count the users and do not use video_exclusive_open() anymore. Signed-off-by: Antoine Jacquet <royale@zerezo.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/zr364xx.c')
-rw-r--r--drivers/media/video/zr364xx.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 9d5d5985a7ea..93991cb9ca71 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -116,6 +116,7 @@ struct zr364xx_camera {
116 int height; 116 int height;
117 int method; 117 int method;
118 struct mutex lock; 118 struct mutex lock;
119 int users;
119}; 120};
120 121
121 122
@@ -643,11 +644,10 @@ static int zr364xx_open(struct inode *inode, struct file *file)
643 644
644 mutex_lock(&cam->lock); 645 mutex_lock(&cam->lock);
645 646
646 cam->skip = 2; 647 if (cam->users) {
647 648 err = -EBUSY;
648 err = video_exclusive_open(inode, file);
649 if (err < 0)
650 goto out; 649 goto out;
650 }
651 651
652 if (!cam->framebuf) { 652 if (!cam->framebuf) {
653 cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES); 653 cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES);
@@ -669,6 +669,8 @@ static int zr364xx_open(struct inode *inode, struct file *file)
669 } 669 }
670 } 670 }
671 671
672 cam->skip = 2;
673 cam->users++;
672 file->private_data = vdev; 674 file->private_data = vdev;
673 675
674 /* Added some delay here, since opening/closing the camera quickly, 676 /* Added some delay here, since opening/closing the camera quickly,
@@ -700,6 +702,10 @@ static int zr364xx_release(struct inode *inode, struct file *file)
700 udev = cam->udev; 702 udev = cam->udev;
701 703
702 mutex_lock(&cam->lock); 704 mutex_lock(&cam->lock);
705
706 cam->users--;
707 file->private_data = NULL;
708
703 for (i = 0; i < 2; i++) { 709 for (i = 0; i < 2; i++) {
704 err = 710 err =
705 send_control_msg(udev, 1, init[cam->method][i].value, 711 send_control_msg(udev, 1, init[cam->method][i].value,
@@ -707,21 +713,19 @@ static int zr364xx_release(struct inode *inode, struct file *file)
707 init[cam->method][i].size); 713 init[cam->method][i].size);
708 if (err < 0) { 714 if (err < 0) {
709 info("error during release sequence"); 715 info("error during release sequence");
710 mutex_unlock(&cam->lock); 716 goto out;
711 return err;
712 } 717 }
713 } 718 }
714 719
715 file->private_data = NULL;
716 video_exclusive_release(inode, file);
717
718 /* Added some delay here, since opening/closing the camera quickly, 720 /* Added some delay here, since opening/closing the camera quickly,
719 * like Ekiga does during its startup, can crash the webcam 721 * like Ekiga does during its startup, can crash the webcam
720 */ 722 */
721 mdelay(100); 723 mdelay(100);
724 err = 0;
722 725
726out:
723 mutex_unlock(&cam->lock); 727 mutex_unlock(&cam->lock);
724 return 0; 728 return err;
725} 729}
726 730
727 731