diff options
| author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-08-22 13:53:04 -0300 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-08-22 13:53:04 -0300 |
| commit | b851f2792eb56fb2608fb21a486bd1e1bc90787b (patch) | |
| tree | 748a783903c29aa63c5b27d7546a25f091354e73 /linux/drivers/media/video | |
| parent | 9774032a256c5068759be0d9f4a1413caf020dd1 (diff) | |
| parent | 34764e7d93869b226c04ddac6b1daf8c93082b53 (diff) | |
| download | mediapointer-dvb-s2-b851f2792eb56fb2608fb21a486bd1e1bc90787b.tar.gz mediapointer-dvb-s2-b851f2792eb56fb2608fb21a486bd1e1bc90787b.tar.bz2 | |
merge: http://linuxtv.org/hg/~ajacquet/v4l-dvb/
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Priority: normal
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video')
| -rw-r--r-- | linux/drivers/media/video/zr364xx.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index dbfdd6966..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; }; @@ -642,25 +643,22 @@ static int zr364xx_open(struct inode *inode, struct file *file) DBG("zr364xx_open"); - cam->skip = 2; + mutex_lock(&cam->lock); - lock_kernel(); - err = video_exclusive_open(inode, file); - if (err < 0) { - unlock_kernel(); - return err; + if (cam->users) { + err = -EBUSY; + goto out; } if (!cam->framebuf) { cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES); if (!cam->framebuf) { info("vmalloc_32 failed!"); - unlock_kernel(); - return -ENOMEM; + err = -ENOMEM; + goto out; } } - mutex_lock(&cam->lock); for (i = 0; init[cam->method][i].size != -1; i++) { err = send_control_msg(udev, 1, init[cam->method][i].value, @@ -668,22 +666,23 @@ static int zr364xx_open(struct inode *inode, struct file *file) init[cam->method][i].size); if (err < 0) { info("error during open sequence: %d", i); - mutex_unlock(&cam->lock); - unlock_kernel(); - return err; + goto out; } } + cam->skip = 2; + cam->users++; file->private_data = vdev; /* 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); - unlock_kernel(); - return 0; + return err; } @@ -704,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, @@ -711,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; } |
