Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

V4L/DVB (8613): v4l: move BKL down to the driver level.



The BKL is now moved from the video_open function in v4l2-dev.c to the
various drivers. It seems about a third of the drivers already has a
lock of some sort protecting the open(), another third uses
video_exclusive_open (yuck!) and the last third required adding the
BKL in their open function.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 95f73c5b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -407,15 +407,18 @@ static int usb_dsbr100_open(struct inode *inode, struct file *file)
{
	struct dsbr100_device *radio=video_get_drvdata(video_devdata(file));

	lock_kernel();
	radio->users = 1;
	radio->muted = 1;

	if (dsbr100_start(radio)<0) {
		warn("Radio did not start up properly");
		radio->users = 0;
		unlock_kernel();
		return -EIO;
	}
	dsbr100_setfreq(radio, radio->curfreq);
	unlock_kernel();
	return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -1074,6 +1074,7 @@ static int si470x_fops_open(struct inode *inode, struct file *file)
	struct si470x_device *radio = video_get_drvdata(video_devdata(file));
	int retval;

	lock_kernel();
	radio->users++;

	retval = usb_autopm_get_interface(radio->intf);
@@ -1090,6 +1091,7 @@ static int si470x_fops_open(struct inode *inode, struct file *file)
	}

done:
	unlock_kernel();
	return retval;
}

+16 −4
Original line number Diff line number Diff line
@@ -3227,6 +3227,7 @@ static int bttv_open(struct inode *inode, struct file *file)

	dprintk(KERN_DEBUG "bttv: open minor=%d\n",minor);

	lock_kernel();
	for (i = 0; i < bttv_num; i++) {
		if (bttvs[i].video_dev &&
		    bttvs[i].video_dev->minor == minor) {
@@ -3241,16 +3242,20 @@ static int bttv_open(struct inode *inode, struct file *file)
			break;
		}
	}
	if (NULL == btv)
	if (NULL == btv) {
		unlock_kernel();
		return -ENODEV;
	}

	dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
		btv->c.nr,v4l2_type_names[type]);

	/* allocate per filehandle data */
	fh = kmalloc(sizeof(*fh),GFP_KERNEL);
	if (NULL == fh)
	if (NULL == fh) {
		unlock_kernel();
		return -ENOMEM;
	}
	file->private_data = fh;
	*fh = btv->init;
	fh->type = type;
@@ -3290,6 +3295,7 @@ static int bttv_open(struct inode *inode, struct file *file)
	bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm);

	bttv_field_count(btv);
	unlock_kernel();
	return 0;
}

@@ -3430,21 +3436,26 @@ static int radio_open(struct inode *inode, struct file *file)

	dprintk("bttv: open minor=%d\n",minor);

	lock_kernel();
	for (i = 0; i < bttv_num; i++) {
		if (bttvs[i].radio_dev && bttvs[i].radio_dev->minor == minor) {
			btv = &bttvs[i];
			break;
		}
	}
	if (NULL == btv)
	if (NULL == btv) {
		unlock_kernel();
		return -ENODEV;
	}

	dprintk("bttv%d: open called (radio)\n",btv->c.nr);

	/* allocate per filehandle data */
	fh = kmalloc(sizeof(*fh), GFP_KERNEL);
	if (NULL == fh)
	if (NULL == fh) {
		unlock_kernel();
		return -ENOMEM;
	}
	file->private_data = fh;
	*fh = btv->init;
	v4l2_prio_open(&btv->prio, &fh->prio);
@@ -3457,6 +3468,7 @@ static int radio_open(struct inode *inode, struct file *file)
	audio_input(btv,TVAUDIO_INPUT_RADIO);

	mutex_unlock(&btv->lock);
	unlock_kernel();
	return 0;
}

+5 −1
Original line number Diff line number Diff line
@@ -1476,9 +1476,12 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
{
	struct cafe_camera *cam;

	lock_kernel();
	cam = cafe_find_dev(iminor(inode));
	if (cam == NULL)
	if (cam == NULL) {
		unlock_kernel();
		return -ENODEV;
	}
	filp->private_data = cam;

	mutex_lock(&cam->s_mutex);
@@ -1490,6 +1493,7 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
	}
	(cam->users)++;
	mutex_unlock(&cam->s_mutex);
	unlock_kernel();
	return 0;
}

+8 −2
Original line number Diff line number Diff line
@@ -1583,6 +1583,7 @@ static int mpeg_open(struct inode *inode, struct file *file)

	dprintk(2, "%s()\n", __func__);

	lock_kernel();
	list_for_each(list, &cx23885_devlist) {
		h = list_entry(list, struct cx23885_dev, devlist);
		if (h->v4l_device->minor == minor) {
@@ -1591,13 +1592,17 @@ static int mpeg_open(struct inode *inode, struct file *file)
		}
	}

	if (dev == NULL)
	if (dev == NULL) {
		unlock_kernel();
		return -ENODEV;
	}

	/* allocate + initialize per filehandle data */
	fh = kzalloc(sizeof(*fh), GFP_KERNEL);
	if (NULL == fh)
	if (NULL == fh) {
		unlock_kernel();
		return -ENOMEM;
	}

	file->private_data = fh;
	fh->dev      = dev;
@@ -1608,6 +1613,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
			    V4L2_FIELD_INTERLACED,
			    sizeof(struct cx23885_buffer),
			    fh);
	unlock_kernel();

	return 0;
}
Loading