aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/w9966.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/w9966.c')
-rw-r--r--drivers/media/video/w9966.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 2ff00bc5ad64..b2dbe48a92bb 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -113,6 +113,7 @@ struct w9966_dev {
113 signed char contrast; 113 signed char contrast;
114 signed char color; 114 signed char color;
115 signed char hue; 115 signed char hue;
116 unsigned long in_use;
116}; 117};
117 118
118/* 119/*
@@ -184,10 +185,25 @@ static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
184static ssize_t w9966_v4l_read(struct file *file, char __user *buf, 185static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
185 size_t count, loff_t *ppos); 186 size_t count, loff_t *ppos);
186 187
188static int w9966_exclusive_open(struct inode *inode, struct file *file)
189{
190 struct w9966_dev *cam = video_drvdata(file);
191
192 return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0;
193}
194
195static int w9966_exclusive_release(struct inode *inode, struct file *file)
196{
197 struct w9966_dev *cam = video_drvdata(file);
198
199 clear_bit(0, &cam->in_use);
200 return 0;
201}
202
187static const struct file_operations w9966_fops = { 203static const struct file_operations w9966_fops = {
188 .owner = THIS_MODULE, 204 .owner = THIS_MODULE,
189 .open = video_exclusive_open, 205 .open = w9966_exclusive_open,
190 .release = video_exclusive_release, 206 .release = w9966_exclusive_release,
191 .ioctl = w9966_v4l_ioctl, 207 .ioctl = w9966_v4l_ioctl,
192#ifdef CONFIG_COMPAT 208#ifdef CONFIG_COMPAT
193 .compat_ioctl = v4l_compat_ioctl32, 209 .compat_ioctl = v4l_compat_ioctl32,
@@ -198,6 +214,7 @@ static const struct file_operations w9966_fops = {
198static struct video_device w9966_template = { 214static struct video_device w9966_template = {
199 .name = W9966_DRIVERNAME, 215 .name = W9966_DRIVERNAME,
200 .fops = &w9966_fops, 216 .fops = &w9966_fops,
217 .release = video_device_release_empty,
201}; 218};
202 219
203/* 220/*
@@ -332,7 +349,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
332 349
333// Fill in the video_device struct and register us to v4l 350// Fill in the video_device struct and register us to v4l
334 memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device)); 351 memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device));
335 cam->vdev.priv = cam; 352 video_set_drvdata(&cam->vdev, cam);
336 353
337 if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) < 0) 354 if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) < 0)
338 return -1; 355 return -1;
@@ -713,8 +730,7 @@ static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data)
713static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file, 730static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
714 unsigned int cmd, void *arg) 731 unsigned int cmd, void *arg)
715{ 732{
716 struct video_device *vdev = video_devdata(file); 733 struct w9966_dev *cam = video_drvdata(file);
717 struct w9966_dev *cam = vdev->priv;
718 734
719 switch(cmd) 735 switch(cmd)
720 { 736 {
@@ -872,8 +888,7 @@ static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
872static ssize_t w9966_v4l_read(struct file *file, char __user *buf, 888static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
873 size_t count, loff_t *ppos) 889 size_t count, loff_t *ppos)
874{ 890{
875 struct video_device *vdev = video_devdata(file); 891 struct w9966_dev *cam = video_drvdata(file);
876 struct w9966_dev *cam = vdev->priv;
877 unsigned char addr = 0xa0; // ECP, read, CCD-transfer, 00000 892 unsigned char addr = 0xa0; // ECP, read, CCD-transfer, 00000
878 unsigned char __user *dest = (unsigned char __user *)buf; 893 unsigned char __user *dest = (unsigned char __user *)buf;
879 unsigned long dleft = count; 894 unsigned long dleft = count;