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

Commit 0edf2e5e authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Mauro Carvalho Chehab
Browse files

[media] v4l: kill the BKL



All of the hard problems for BKL removal appear to be solved in the
v4l-dvb/master tree. This removes the BKL from the various open
functions that do not need it, or only use it to protect an
open count.

The zoran driver is nontrivial in this regard, so I introduce
a new mutex that locks both the open/release and the ioctl
functions. Someone with access to the hardware can probably
improve that by using the existing lock in all cases.

Finally, all drivers that still use the locked version of the
ioctl function now get called under a new mutex instead of
the BKL.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2c2742da
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ comment "Multimedia core support"

config VIDEO_DEV
	tristate "Video For Linux"
	depends on BKL # used in many drivers for ioctl handling, need to kill
	---help---
	  V4L core support for video capture and overlay devices, webcams and
	  AM/FM radio cards.
+2 −4
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <linux/smp_lock.h>
#include <linux/vmalloc.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
@@ -1927,10 +1926,9 @@ static int mpeg_open(struct file *file)
			dev = h;
	}

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

	mutex_lock(&dev->lock);

	/* allocate + initialize per filehandle data */
+1 −8
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
@@ -1576,12 +1575,8 @@ static int mpeg_open(struct file *file)

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

	lock_kernel();

	file->private_data = fh;
	fh->dev      = dev;
@@ -1592,8 +1587,6 @@ static int mpeg_open(struct file *file)
			    V4L2_FIELD_INTERLACED,
			    sizeof(struct cx23885_buffer),
			    fh, NULL);
	unlock_kernel();

	return 0;
}

+0 −5
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#include <linux/kmod.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/smp_lock.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/kthread.h>
@@ -743,8 +742,6 @@ static int video_open(struct file *file)
	if (NULL == fh)
		return -ENOMEM;

	lock_kernel();

	file->private_data = fh;
	fh->dev      = dev;
	fh->radio    = radio;
@@ -762,8 +759,6 @@ static int video_open(struct file *file)

	dprintk(1, "post videobuf_queue_init()\n");

	unlock_kernel();

	return 0;
}

+3 −4
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ static const char version[] = "0.24";
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/smp_lock.h>
#include <linux/pagemap.h>
#include <linux/usb.h>
#include "se401.h"
@@ -951,9 +950,9 @@ static int se401_open(struct file *file)
	struct usb_se401 *se401 = (struct usb_se401 *)dev;
	int err = 0;

	lock_kernel();
	mutex_lock(&se401->lock);
	if (se401->user) {
		unlock_kernel();
		mutex_unlock(&se401->lock);
		return -EBUSY;
	}
	se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES);
@@ -962,7 +961,7 @@ static int se401_open(struct file *file)
	else
		err = -ENOMEM;
	se401->user = !err;
	unlock_kernel();
	mutex_unlock(&se401->lock);

	return err;
}
Loading