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

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
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ struct ar_device {
	int width, height;
	int frame_bytes, line_bytes;
	wait_queue_head_t wait;
	unsigned long in_use;
	struct mutex lock;
};

@@ -742,10 +743,23 @@ void ar_release(struct video_device *vfd)
 * 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 = {
	.owner		= THIS_MODULE,
	.open		= video_exclusive_open,
	.release	= video_exclusive_release,
	.open		= ar_exclusive_open,
	.release	= ar_exclusive_release,
	.read		= ar_read,
	.ioctl		= ar_ioctl,
#ifdef CONFIG_COMPAT
@@ -762,7 +776,6 @@ static struct video_device ar_template = {
};

#define ALIGN4(x)	((((int)(x)) & 0x3) == 0)
static struct ar_device ardev;

static int __init ar_init(void)
{
+19 −2
Original line number Diff line number Diff line
@@ -894,10 +894,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,
+1 −0
Original line number Diff line number Diff line
@@ -65,4 +65,5 @@ struct qcam_device {
	int top, left;
	int status;
	unsigned int saved_bits;
	unsigned long in_use;
};
+20 −2
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ struct qcam_device {
	int contrast, brightness, whitebal;
	int top, left;
	unsigned int bidirectional;
	unsigned long in_use;
	struct mutex lock;
};

@@ -687,11 +688,28 @@ 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;
}

/* video device template */
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,
+5 −11
Original line number Diff line number Diff line
@@ -843,21 +843,16 @@ static irqreturn_t meye_irq(int irq, void *dev_id)

static int meye_open(struct inode *inode, struct file *file)
{
	int i, err;
	int i;

	lock_kernel();
	err = video_exclusive_open(inode, file);
	if (err < 0) {
		unlock_kernel();
		return err;
	}
	if (test_and_set_bit(0, &meye.in_use))
		return -EBUSY;

	mchip_hic_stop();

	if (mchip_dma_alloc()) {
		printk(KERN_ERR "meye: mchip framebuffer allocation failed\n");
		video_exclusive_release(inode, file);
		unlock_kernel();
		clear_bit(0, &meye.in_use);
		return -ENOBUFS;
	}

@@ -865,7 +860,6 @@ static int meye_open(struct inode *inode, struct file *file)
		meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
	kfifo_reset(meye.grabq);
	kfifo_reset(meye.doneq);
	unlock_kernel();
	return 0;
}

@@ -873,7 +867,7 @@ static int meye_release(struct inode *inode, struct file *file)
{
	mchip_hic_stop();
	mchip_dma_free();
	video_exclusive_release(inode, file);
	clear_bit(0, &meye.in_use);
	return 0;
}

Loading