diff options
author | Antoine Jacquet <royale@zerezo.com> | 2008-08-18 22:14:30 +0200 |
---|---|---|
committer | Antoine Jacquet <royale@zerezo.com> | 2008-08-18 22:14:30 +0200 |
commit | 907cb68cd937317d682455610490e10b06389d22 (patch) | |
tree | 34ae4436dd234e07f224e5b3a9df02a787dc1355 /linux/drivers/media | |
parent | 677ec00d28b905a78c8fa5f623be5f29ac1e384a (diff) | |
download | mediapointer-dvb-s2-907cb68cd937317d682455610490e10b06389d22.tar.gz mediapointer-dvb-s2-907cb68cd937317d682455610490e10b06389d22.tar.bz2 |
zr364xx: handle video exclusive open internaly
From: Antoine Jacquet <royale@zerezo.com>
Count the users and do not use video_exclusive_open() anymore.
Priority: normal
Signed-off-by: Antoine Jacquet <royale@zerezo.com>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r-- | linux/drivers/media/video/zr364xx.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index 9d07e6185..a2a632534 100644 --- a/linux/drivers/media/video/zr364xx.c +++ b/linux/drivers/media/video/zr364xx.c @@ -117,6 +117,7 @@ struct zr364xx_camera { int height; int method; struct mutex lock; + int users; }; @@ -644,11 +645,10 @@ static int zr364xx_open(struct inode *inode, struct file *file) mutex_lock(&cam->lock); - cam->skip = 2; - - err = video_exclusive_open(inode, file); - if (err < 0) + if (cam->users) { + err = -EBUSY; goto out; + } if (!cam->framebuf) { cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES); @@ -670,6 +670,8 @@ static int zr364xx_open(struct inode *inode, struct file *file) } } + cam->skip = 2; + cam->users++; file->private_data = vdev; /* Added some delay here, since opening/closing the camera quickly, @@ -701,6 +703,10 @@ static int zr364xx_release(struct inode *inode, struct file *file) udev = cam->udev; mutex_lock(&cam->lock); + + cam->users--; + file->private_data = NULL; + for (i = 0; i < 2; i++) { err = send_control_msg(udev, 1, init[cam->method][i].value, @@ -708,21 +714,19 @@ static int zr364xx_release(struct inode *inode, struct file *file) init[cam->method][i].size); if (err < 0) { info("error during release sequence"); - mutex_unlock(&cam->lock); - return err; + goto out; } } - file->private_data = NULL; - video_exclusive_release(inode, file); - /* Added some delay here, since opening/closing the camera quickly, * like Ekiga does during its startup, can crash the webcam */ mdelay(100); + err = 0; +out: mutex_unlock(&cam->lock); - return 0; + return err; } |