From b5f5df65c8c54f89b3064a41b369a44f1883af0e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 23 Aug 2008 10:02:07 +0200 Subject: v4l: fix more incorrect video_register_device result checks From: Hans Verkuil Priority: normal Signed-off-by: Hans Verkuil --- linux/drivers/media/video/bw-qcam.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'linux/drivers/media/video/bw-qcam.c') diff --git a/linux/drivers/media/video/bw-qcam.c b/linux/drivers/media/video/bw-qcam.c index 393113875..d0f847fcc 100644 --- a/linux/drivers/media/video/bw-qcam.c +++ b/linux/drivers/media/video/bw-qcam.c @@ -947,8 +947,7 @@ static int init_bwqcam(struct parport *port) printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name); - if(video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1) - { + if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr) < 0) { parport_unregister_device(qcam->pdev); kfree(qcam); return -ENODEV; -- cgit v1.2.3 From ebc50a51f87d69d522b94d64ec8d7da4df5bbb93 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 23 Aug 2008 10:31:47 +0200 Subject: v4l: replace the last uses of video_exclusive_open/release From: Hans Verkuil Handle the video_exclusive_open/release functionality inside the driver. Priority: normal Signed-off-by: Hans Verkuil --- linux/drivers/media/video/bw-qcam.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'linux/drivers/media/video/bw-qcam.c') diff --git a/linux/drivers/media/video/bw-qcam.c b/linux/drivers/media/video/bw-qcam.c index d0f847fcc..75036e5ec 100644 --- a/linux/drivers/media/video/bw-qcam.c +++ b/linux/drivers/media/video/bw-qcam.c @@ -895,10 +895,27 @@ static ssize_t qcam_read(struct file *file, char __user *buf, return len; } +static int qcam_exclusive_open(struct inode *inode, struct file *file) +{ + struct video_device *dev = video_devdata(file); + struct qcam_device *qcam = (struct qcam_device *)dev; + + return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0; +} + +static int qcam_exclusive_release(struct inode *inode, struct file *file) +{ + struct video_device *dev = video_devdata(file); + struct qcam_device *qcam = (struct qcam_device *)dev; + + clear_bit(0, &qcam->in_use); + return 0; +} + static const struct file_operations qcam_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = qcam_exclusive_open, + .release = qcam_exclusive_release, .ioctl = qcam_ioctl, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, -- cgit v1.2.3 From 1342dc3012002c994885d1ad6efd6c819fa2805e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 23 Aug 2008 11:23:55 +0200 Subject: v4l: add all missing video_device release callbacks From: Hans Verkuil All drivers that call video_device_register where checked to see if they set the release callback of struct video_device. Where that callback was missing it was added. Priority: normal Signed-off-by: Hans Verkuil --- linux/drivers/media/video/bw-qcam.c | 1 + 1 file changed, 1 insertion(+) (limited to 'linux/drivers/media/video/bw-qcam.c') diff --git a/linux/drivers/media/video/bw-qcam.c b/linux/drivers/media/video/bw-qcam.c index 75036e5ec..ca8fabdf3 100644 --- a/linux/drivers/media/video/bw-qcam.c +++ b/linux/drivers/media/video/bw-qcam.c @@ -927,6 +927,7 @@ static struct video_device qcam_template= { .name = "Connectix Quickcam", .fops = &qcam_fops, + .release = video_device_release_empty, }; #define MAX_CAMS 4 -- cgit v1.2.3