Skip to content

Commit

Permalink
V4L/DVB (8732): zr364xx: handle video exclusive open internaly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Antoine Jacquet authored and Mauro Carvalho Chehab committed Oct 12, 2008
1 parent 69025c9 commit 33d27a4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions drivers/media/video/zr364xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ struct zr364xx_camera {
int height;
int method;
struct mutex lock;
int users;
};


Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -700,28 +702,30 @@ 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,
0, init[i][cam->method].bytes,
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;
}


Expand Down

0 comments on commit 33d27a4

Please sign in to comment.