diff options
author | Antoine Jacquet <royale@zerezo.com> | 2008-08-18 17:14:30 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 09:36:51 -0200 |
commit | 33d27a45165ae9c3551e8d7c1186a5583371e5c4 (patch) | |
tree | a445470f5ae0c398bb9ee7b4567ccb6662a6c7d9 | |
parent | 69025c934b21a9ce49a76dfef59f1ebdfbe96c78 (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>
-rw-r--r-- | drivers/media/video/zr364xx.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index 9d5d5985a7e..93991cb9ca7 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c @@ -116,6 +116,7 @@ struct zr364xx_camera { int height; int method; struct mutex lock; + int users; }; @@ -643,11 +644,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); @@ -669,6 +669,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, @@ -700,6 +702,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, @@ -707,21 +713,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; } |