Commit 7d43cd53 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (8780): v4l: replace the last uses of video_exclusive_open/release

Handle the video_exclusive_open/release functionality inside the
driver.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2f3d0025
...@@ -116,6 +116,7 @@ struct ar_device { ...@@ -116,6 +116,7 @@ struct ar_device {
int width, height; int width, height;
int frame_bytes, line_bytes; int frame_bytes, line_bytes;
wait_queue_head_t wait; wait_queue_head_t wait;
unsigned long in_use;
struct mutex lock; struct mutex lock;
}; };
...@@ -742,10 +743,23 @@ void ar_release(struct video_device *vfd) ...@@ -742,10 +743,23 @@ void ar_release(struct video_device *vfd)
* Video4Linux Module functions * Video4Linux Module functions
* *
****************************************************************************/ ****************************************************************************/
static struct ar_device ardev;
static int ar_exclusive_open(struct inode *inode, struct file *file)
{
return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0;
}
static int ar_exclusive_release(struct inode *inode, struct file *file)
{
clear_bit(0, &ardev.in_use);
return 0;
}
static const struct file_operations ar_fops = { static const struct file_operations ar_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_exclusive_open, .open = ar_exclusive_open,
.release = video_exclusive_release, .release = ar_exclusive_release,
.read = ar_read, .read = ar_read,
.ioctl = ar_ioctl, .ioctl = ar_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
...@@ -762,7 +776,6 @@ static struct video_device ar_template = { ...@@ -762,7 +776,6 @@ static struct video_device ar_template = {
}; };
#define ALIGN4(x) ((((int)(x)) & 0x3) == 0) #define ALIGN4(x) ((((int)(x)) & 0x3) == 0)
static struct ar_device ardev;
static int __init ar_init(void) static int __init ar_init(void)
{ {
......
...@@ -894,10 +894,27 @@ static ssize_t qcam_read(struct file *file, char __user *buf, ...@@ -894,10 +894,27 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
return len; 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 = { static const struct file_operations qcam_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_exclusive_open, .open = qcam_exclusive_open,
.release = video_exclusive_release, .release = qcam_exclusive_release,
.ioctl = qcam_ioctl, .ioctl = qcam_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
......
...@@ -65,4 +65,5 @@ struct qcam_device { ...@@ -65,4 +65,5 @@ struct qcam_device {
int top, left; int top, left;
int status; int status;
unsigned int saved_bits; unsigned int saved_bits;
unsigned long in_use;
}; };
...@@ -51,6 +51,7 @@ struct qcam_device { ...@@ -51,6 +51,7 @@ struct qcam_device {
int contrast, brightness, whitebal; int contrast, brightness, whitebal;
int top, left; int top, left;
unsigned int bidirectional; unsigned int bidirectional;
unsigned long in_use;
struct mutex lock; struct mutex lock;
}; };
...@@ -687,11 +688,28 @@ static ssize_t qcam_read(struct file *file, char __user *buf, ...@@ -687,11 +688,28 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
return len; 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;
}
/* video device template */ /* video device template */
static const struct file_operations qcam_fops = { static const struct file_operations qcam_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_exclusive_open, .open = qcam_exclusive_open,
.release = video_exclusive_release, .release = qcam_exclusive_release,
.ioctl = qcam_ioctl, .ioctl = qcam_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
......
...@@ -843,21 +843,16 @@ static irqreturn_t meye_irq(int irq, void *dev_id) ...@@ -843,21 +843,16 @@ static irqreturn_t meye_irq(int irq, void *dev_id)
static int meye_open(struct inode *inode, struct file *file) static int meye_open(struct inode *inode, struct file *file)
{ {
int i, err; int i;
lock_kernel(); if (test_and_set_bit(0, &meye.in_use))
err = video_exclusive_open(inode, file); return -EBUSY;
if (err < 0) {
unlock_kernel();
return err;
}
mchip_hic_stop(); mchip_hic_stop();
if (mchip_dma_alloc()) { if (mchip_dma_alloc()) {
printk(KERN_ERR "meye: mchip framebuffer allocation failed\n"); printk(KERN_ERR "meye: mchip framebuffer allocation failed\n");
video_exclusive_release(inode, file); clear_bit(0, &meye.in_use);
unlock_kernel();
return -ENOBUFS; return -ENOBUFS;
} }
...@@ -865,7 +860,6 @@ static int meye_open(struct inode *inode, struct file *file) ...@@ -865,7 +860,6 @@ static int meye_open(struct inode *inode, struct file *file)
meye.grab_buffer[i].state = MEYE_BUF_UNUSED; meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
kfifo_reset(meye.grabq); kfifo_reset(meye.grabq);
kfifo_reset(meye.doneq); kfifo_reset(meye.doneq);
unlock_kernel();
return 0; return 0;
} }
...@@ -873,7 +867,7 @@ static int meye_release(struct inode *inode, struct file *file) ...@@ -873,7 +867,7 @@ static int meye_release(struct inode *inode, struct file *file)
{ {
mchip_hic_stop(); mchip_hic_stop();
mchip_dma_free(); mchip_dma_free();
video_exclusive_release(inode, file); clear_bit(0, &meye.in_use);
return 0; return 0;
} }
......
...@@ -311,6 +311,7 @@ struct meye { ...@@ -311,6 +311,7 @@ struct meye {
struct video_device *video_dev; /* video device parameters */ struct video_device *video_dev; /* video device parameters */
struct video_picture picture; /* video picture parameters */ struct video_picture picture; /* video picture parameters */
struct meye_params params; /* additional parameters */ struct meye_params params; /* additional parameters */
unsigned long in_use; /* set to 1 if the device is in use */
#ifdef CONFIG_PM #ifdef CONFIG_PM
u8 pm_mchip_mode; /* old mchip mode */ u8 pm_mchip_mode; /* old mchip mode */
#endif #endif
......
...@@ -47,6 +47,7 @@ struct pms_device ...@@ -47,6 +47,7 @@ struct pms_device
struct video_picture picture; struct video_picture picture;
int height; int height;
int width; int width;
unsigned long in_use;
struct mutex lock; struct mutex lock;
}; };
...@@ -881,10 +882,27 @@ static ssize_t pms_read(struct file *file, char __user *buf, ...@@ -881,10 +882,27 @@ static ssize_t pms_read(struct file *file, char __user *buf,
return len; return len;
} }
static int pms_exclusive_open(struct inode *inode, struct file *file)
{
struct video_device *v = video_devdata(file);
struct pms_device *pd = (struct pms_device *)v;
return test_and_set_bit(0, &pd->in_use) ? -EBUSY : 0;
}
static int pms_exclusive_release(struct inode *inode, struct file *file)
{
struct video_device *v = video_devdata(file);
struct pms_device *pd = (struct pms_device *)v;
clear_bit(0, &pd->in_use);
return 0;
}
static const struct file_operations pms_fops = { static const struct file_operations pms_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_exclusive_open, .open = pms_exclusive_open,
.release = video_exclusive_release, .release = pms_exclusive_release,
.ioctl = pms_ioctl, .ioctl = pms_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
......
...@@ -61,6 +61,7 @@ struct saa5246a_device ...@@ -61,6 +61,7 @@ struct saa5246a_device
u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE]; u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE];
int is_searching[NUM_DAUS]; int is_searching[NUM_DAUS];
struct i2c_client *client; struct i2c_client *client;
unsigned long in_use;
struct mutex lock; struct mutex lock;
}; };
...@@ -736,22 +737,14 @@ static int saa5246a_open(struct inode *inode, struct file *file) ...@@ -736,22 +737,14 @@ static int saa5246a_open(struct inode *inode, struct file *file)
{ {
struct video_device *vd = video_devdata(file); struct video_device *vd = video_devdata(file);
struct saa5246a_device *t = vd->priv; struct saa5246a_device *t = vd->priv;
int err;
lock_kernel(); if (t->client == NULL)
err = video_exclusive_open(inode,file); return -ENODEV;
if (err < 0) {
unlock_kernel();
return err;
}
if (t->client==NULL) { if (test_and_set_bit(0, &t->in_use))
err = -ENODEV; return -EBUSY;
goto fail;
}
if (i2c_senddata(t, SAA5246A_REGISTER_R0, if (i2c_senddata(t, SAA5246A_REGISTER_R0,
R0_SELECT_R11 | R0_SELECT_R11 |
R0_PLL_TIME_CONSTANT_LONG | R0_PLL_TIME_CONSTANT_LONG |
R0_ENABLE_nODD_EVEN_OUTPUT | R0_ENABLE_nODD_EVEN_OUTPUT |
...@@ -777,17 +770,10 @@ static int saa5246a_open(struct inode *inode, struct file *file) ...@@ -777,17 +770,10 @@ static int saa5246a_open(struct inode *inode, struct file *file)
COMMAND_END)) COMMAND_END))
{ {
err = -EIO; clear_bit(0, &t->in_use);
goto fail; return -EIO;
} }
unlock_kernel();
return 0; return 0;
fail:
video_exclusive_release(inode,file);
unlock_kernel();
return err;
} }
static int saa5246a_release(struct inode *inode, struct file *file) static int saa5246a_release(struct inode *inode, struct file *file)
...@@ -806,7 +792,7 @@ static int saa5246a_release(struct inode *inode, struct file *file) ...@@ -806,7 +792,7 @@ static int saa5246a_release(struct inode *inode, struct file *file)
R1_VCS_TO_SCS, R1_VCS_TO_SCS,
COMMAND_END); COMMAND_END);
video_exclusive_release(inode,file); clear_bit(0, &t->in_use);
return 0; return 0;
} }
......
...@@ -110,6 +110,7 @@ struct saa5249_device ...@@ -110,6 +110,7 @@ struct saa5249_device
int disp_mode; int disp_mode;
int virtual_mode; int virtual_mode;
struct i2c_client *client; struct i2c_client *client;
unsigned long in_use;
struct mutex lock; struct mutex lock;
}; };
...@@ -631,34 +632,27 @@ static int saa5249_ioctl(struct inode *inode, struct file *file, ...@@ -631,34 +632,27 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
static int saa5249_open(struct inode *inode, struct file *file) static int saa5249_open(struct inode *inode, struct file *file)
{ {
struct video_device *vd = video_devdata(file); struct video_device *vd = video_devdata(file);
struct saa5249_device *t=vd->priv; struct saa5249_device *t = vd->priv;
int err,pgbuf; int pgbuf;
lock_kernel(); if (t->client == NULL)
err = video_exclusive_open(inode,file); return -ENODEV;
if (err < 0) {
unlock_kernel();
return err;
}
if (t->client==NULL) { if (test_and_set_bit(0, &t->in_use))
err = -ENODEV; return -EBUSY;
goto fail;
}
if (i2c_senddata(t, 0, 0, -1) || /* Select R11 */ if (i2c_senddata(t, 0, 0, -1) || /* Select R11 */
/* Turn off parity checks (we do this ourselves) */ /* Turn off parity checks (we do this ourselves) */
i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) || i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) ||
/* Display TV-picture, no virtual rows */ /* Display TV-picture, no virtual rows */
i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */ i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1))
/* Set display to page 4 */
{ {
err = -EIO; clear_bit(0, &t->in_use);
goto fail; return -EIO;
} }
for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) {
{
memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
memset(t->vdau[pgbuf].laststat, 0, sizeof(t->vdau[0].laststat)); memset(t->vdau[pgbuf].laststat, 0, sizeof(t->vdau[0].laststat));
...@@ -668,13 +662,7 @@ static int saa5249_open(struct inode *inode, struct file *file) ...@@ -668,13 +662,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
t->is_searching[pgbuf] = false; t->is_searching[pgbuf] = false;
} }
t->virtual_mode = false; t->virtual_mode = false;
unlock_kernel();
return 0; return 0;
fail:
video_exclusive_release(inode,file);
unlock_kernel();
return err;
} }
...@@ -682,10 +670,11 @@ static int saa5249_open(struct inode *inode, struct file *file) ...@@ -682,10 +670,11 @@ static int saa5249_open(struct inode *inode, struct file *file)
static int saa5249_release(struct inode *inode, struct file *file) static int saa5249_release(struct inode *inode, struct file *file)
{ {
struct video_device *vd = video_devdata(file); struct video_device *vd = video_devdata(file);
struct saa5249_device *t=vd->priv; struct saa5249_device *t = vd->priv;
i2c_senddata(t, 1, 0x20, -1); /* Turn off CCT */ i2c_senddata(t, 1, 0x20, -1); /* Turn off CCT */
i2c_senddata(t, 5, 3, 3, -1); /* Turn off TV-display */ i2c_senddata(t, 5, 3, 3, -1); /* Turn off TV-display */
video_exclusive_release(inode,file); clear_bit(0, &t->in_use);
return 0; return 0;
} }
......
...@@ -113,6 +113,7 @@ struct w9966_dev { ...@@ -113,6 +113,7 @@ struct w9966_dev {
signed char contrast; signed char contrast;
signed char color; signed char color;
signed char hue; signed char hue;
unsigned long in_use;
}; };
/* /*
...@@ -184,10 +185,27 @@ static int w9966_v4l_ioctl(struct inode *inode, struct file *file, ...@@ -184,10 +185,27 @@ static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
static ssize_t w9966_v4l_read(struct file *file, char __user *buf, static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos); size_t count, loff_t *ppos);
static int w9966_exclusive_open(struct inode *inode, struct file *file)
{
struct video_device *vdev = video_devdata(file);
struct w9966_dev *cam = vdev->priv;
return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0;
}
static int w9966_exclusive_release(struct inode *inode, struct file *file)
{
struct video_device *vdev = video_devdata(file);
struct w9966_dev *cam = vdev->priv;
clear_bit(0, &cam->in_use);
return 0;
}
static const struct file_operations w9966_fops = { static const struct file_operations w9966_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_exclusive_open, .open = w9966_exclusive_open,
.release = video_exclusive_release, .release = w9966_exclusive_release,
.ioctl = w9966_v4l_ioctl, .ioctl = w9966_v4l_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment