summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-07-30 13:43:36 +0200
committerHans Verkuil <hverkuil@xs4all.nl>2008-07-30 13:43:36 +0200
commitc8b5c505811fd4797e0ea35bcc60478d626a0971 (patch)
tree628f97e562257d3dc6c18269b3a520c45873de7d /linux/drivers/media
parent4381ceef6895b12019f4d55a6f5ff9629194b259 (diff)
downloadmediapointer-dvb-s2-c8b5c505811fd4797e0ea35bcc60478d626a0971.tar.gz
mediapointer-dvb-s2-c8b5c505811fd4797e0ea35bcc60478d626a0971.tar.bz2
v4l: move BKL down to the driver level.
From: Hans Verkuil <hverkuil@xs4all.nl> 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: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/radio/dsbr100.c3
-rw-r--r--linux/drivers/media/radio/radio-si470x.c2
-rw-r--r--linux/drivers/media/video/bt8xx/bttv-driver.c20
-rw-r--r--linux/drivers/media/video/cafe_ccic.c6
-rw-r--r--linux/drivers/media/video/cx23885/cx23885-417.c10
-rw-r--r--linux/drivers/media/video/cx23885/cx23885-video.c10
-rw-r--r--linux/drivers/media/video/cx88/cx88-blackbird.c8
-rw-r--r--linux/drivers/media/video/cx88/cx88-video.c10
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-video.c7
-rw-r--r--linux/drivers/media/video/meye.c7
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c6
-rw-r--r--linux/drivers/media/video/s2255drv.c6
-rw-r--r--linux/drivers/media/video/saa5246a.c8
-rw-r--r--linux/drivers/media/video/saa5249.c8
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-empress.c3
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-video.c8
-rw-r--r--linux/drivers/media/video/se401.c6
-rw-r--r--linux/drivers/media/video/stk-webcam.c6
-rw-r--r--linux/drivers/media/video/stradis.c6
-rw-r--r--linux/drivers/media/video/stv680.c2
-rw-r--r--linux/drivers/media/video/tvmixer.c6
-rw-r--r--linux/drivers/media/video/usbvideo/vicam.c6
-rw-r--r--linux/drivers/media/video/usbvision/usbvision-video.c2
-rw-r--r--linux/drivers/media/video/v4l2-dev.c3
-rw-r--r--linux/drivers/media/video/vivi.c7
-rw-r--r--linux/drivers/media/video/zoran_driver.c3
-rw-r--r--linux/drivers/media/video/zr364xx.c8
27 files changed, 151 insertions, 26 deletions
diff --git a/linux/drivers/media/radio/dsbr100.c b/linux/drivers/media/radio/dsbr100.c
index d223846d5..93a871985 100644
--- a/linux/drivers/media/radio/dsbr100.c
+++ b/linux/drivers/media/radio/dsbr100.c
@@ -408,15 +408,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;
}
diff --git a/linux/drivers/media/radio/radio-si470x.c b/linux/drivers/media/radio/radio-si470x.c
index afff1345b..3b1f630a9 100644
--- a/linux/drivers/media/radio/radio-si470x.c
+++ b/linux/drivers/media/radio/radio-si470x.c
@@ -1079,6 +1079,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);
@@ -1095,6 +1096,7 @@ static int si470x_fops_open(struct inode *inode, struct file *file)
}
done:
+ unlock_kernel();
return retval;
}
diff --git a/linux/drivers/media/video/bt8xx/bttv-driver.c b/linux/drivers/media/video/bt8xx/bttv-driver.c
index 40f8a0332..d5cb13e40 100644
--- a/linux/drivers/media/video/bt8xx/bttv-driver.c
+++ b/linux/drivers/media/video/bt8xx/bttv-driver.c
@@ -3248,6 +3248,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) {
@@ -3262,16 +3263,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;
@@ -3311,6 +3316,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;
}
@@ -3451,21 +3457,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->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);
@@ -3478,6 +3489,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;
}
diff --git a/linux/drivers/media/video/cafe_ccic.c b/linux/drivers/media/video/cafe_ccic.c
index 35ecaa0c1..4c0d44c5d 100644
--- a/linux/drivers/media/video/cafe_ccic.c
+++ b/linux/drivers/media/video/cafe_ccic.c
@@ -1482,9 +1482,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);
@@ -1496,6 +1499,7 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
}
(cam->users)++;
mutex_unlock(&cam->s_mutex);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/cx23885/cx23885-417.c b/linux/drivers/media/video/cx23885/cx23885-417.c
index a8ca3bd9f..106b594ed 100644
--- a/linux/drivers/media/video/cx23885/cx23885-417.c
+++ b/linux/drivers/media/video/cx23885/cx23885-417.c
@@ -1591,6 +1591,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) {
@@ -1599,13 +1600,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;
@@ -1616,6 +1621,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
V4L2_FIELD_INTERLACED,
sizeof(struct cx23885_buffer),
fh);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/cx23885/cx23885-video.c b/linux/drivers/media/video/cx23885/cx23885-video.c
index 3f1765de0..98a7dc1c0 100644
--- a/linux/drivers/media/video/cx23885/cx23885-video.c
+++ b/linux/drivers/media/video/cx23885/cx23885-video.c
@@ -787,6 +787,7 @@ static int video_open(struct inode *inode, struct file *file)
enum v4l2_buf_type type = 0;
int radio = 0;
+ lock_kernel();
list_for_each(list, &cx23885_devlist) {
h = list_entry(list, struct cx23885_dev, devlist);
if (h->video_dev->minor == minor) {
@@ -804,16 +805,20 @@ static int video_open(struct inode *inode, struct file *file)
dev = h;
}
}
- if (NULL == dev)
+ if (NULL == dev) {
+ unlock_kernel();
return -ENODEV;
+ }
dprintk(1, "open minor=%d radio=%d type=%s\n",
minor, radio, v4l2_type_names[type]);
/* 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;
fh->radio = radio;
@@ -846,6 +851,7 @@ static int video_open(struct inode *inode, struct file *file)
AUDC_SET_RADIO, NULL);
}
#endif
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/cx88/cx88-blackbird.c b/linux/drivers/media/video/cx88/cx88-blackbird.c
index 696a8752a..0cd510814 100644
--- a/linux/drivers/media/video/cx88/cx88-blackbird.c
+++ b/linux/drivers/media/video/cx88/cx88-blackbird.c
@@ -1076,12 +1076,15 @@ static int mpeg_open(struct inode *inode, struct file *file)
struct cx8802_driver *drv = NULL;
int err;
+ lock_kernel();
dev = cx8802_get_device(inode);
dprintk( 1, "%s\n", __func__);
- if (dev == NULL)
+ if (dev == NULL) {
+ unlock_kernel();
return -ENODEV;
+ }
/* Make sure we can acquire the hardware */
drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
@@ -1096,6 +1099,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
if (blackbird_initialize_codec(dev) < 0) {
if (drv)
drv->request_release(drv);
+ unlock_kernel();
return -EINVAL;
}
dprintk(1,"open minor=%d\n",minor);
@@ -1105,6 +1109,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
if (NULL == fh) {
if (drv)
drv->request_release(drv);
+ unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
@@ -1120,6 +1125,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
/* FIXME: locking against other video device */
cx88_set_scale(dev->core, dev->width, dev->height,
fh->mpegq.field);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/cx88/cx88-video.c b/linux/drivers/media/video/cx88/cx88-video.c
index 5dafb7d73..3a7a9ed17 100644
--- a/linux/drivers/media/video/cx88/cx88-video.c
+++ b/linux/drivers/media/video/cx88/cx88-video.c
@@ -999,6 +999,7 @@ static int video_open(struct inode *inode, struct file *file)
enum v4l2_buf_type type = 0;
int radio = 0;
+ lock_kernel();
list_for_each_entry(h, &cx8800_devlist, devlist) {
if (h->video_dev->minor == minor) {
dev = h;
@@ -1014,8 +1015,10 @@ static int video_open(struct inode *inode, struct file *file)
dev = h;
}
}
- if (NULL == dev)
+ if (NULL == dev) {
+ unlock_kernel();
return -ENODEV;
+ }
core = dev->core;
@@ -1024,8 +1027,10 @@ static int video_open(struct inode *inode, struct file *file)
/* 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;
fh->radio = radio;
@@ -1058,6 +1063,7 @@ static int video_open(struct inode *inode, struct file *file)
cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1);
cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL);
}
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/em28xx/em28xx-video.c b/linux/drivers/media/video/em28xx/em28xx-video.c
index 81d942e39..c9a2d4808 100644
--- a/linux/drivers/media/video/em28xx/em28xx-video.c
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c
@@ -1555,6 +1555,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
struct em28xx_fh *fh;
enum v4l2_buf_type fh_type = 0;
+ lock_kernel();
list_for_each_entry(h, &em28xx_devlist, devlist) {
if (h->vdev->minor == minor) {
dev = h;
@@ -1570,8 +1571,10 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
dev = h;
}
}
- if (NULL == dev)
+ if (NULL == dev) {
+ unlock_kernel();
return -ENODEV;
+ }
em28xx_videodbg("open minor=%d type=%s users=%d\n",
minor, v4l2_type_names[fh_type], dev->users);
@@ -1587,6 +1590,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
if (!fh) {
em28xx_errdev("em28xx-video.c: Out of memory?!\n");
+ unlock_kernel();
return -ENOMEM;
}
mutex_lock(&dev->lock);
@@ -1630,6 +1634,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
sizeof(struct em28xx_buffer), fh);
mutex_unlock(&dev->lock);
+ unlock_kernel();
return errCode;
}
diff --git a/linux/drivers/media/video/meye.c b/linux/drivers/media/video/meye.c
index d128a611e..a0cdae0c1 100644
--- a/linux/drivers/media/video/meye.c
+++ b/linux/drivers/media/video/meye.c
@@ -850,15 +850,19 @@ static int meye_open(struct inode *inode, struct file *file)
{
int i, err;
+ lock_kernel();
err = video_exclusive_open(inode, file);
- if (err < 0)
+ if (err < 0) {
+ unlock_kernel();
return err;
+ }
mchip_hic_stop();
if (mchip_dma_alloc()) {
printk(KERN_ERR "meye: mchip framebuffer allocation failed\n");
video_exclusive_release(inode, file);
+ unlock_kernel();
return -ENOBUFS;
}
@@ -866,6 +870,7 @@ 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;
}
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 1619c2756..c1cc0e88b 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -933,6 +933,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
unsigned int input_cnt,idx;
int ret = 0;
+ lock_kernel();
dip = container_of(video_devdata(file),struct pvr2_v4l2_dev,devbase);
vp = dip->v4lp;
@@ -943,11 +944,13 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
if (!pvr2_hdw_dev_ok(hdw)) {
pvr2_trace(PVR2_TRACE_OPEN_CLOSE,
"pvr2_v4l2_open: hardware not ready");
+ unlock_kernel();
return -EIO;
}
fhp = kzalloc(sizeof(*fhp),GFP_KERNEL);
if (!fhp) {
+ unlock_kernel();
return -ENOMEM;
}
@@ -977,6 +980,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
fhp);
kfree(fhp);
+ unlock_kernel();
return ret;
}
@@ -993,6 +997,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
"Destroying pvr_v4l2_fh id=%p (input map failure)",
fhp);
kfree(fhp);
+ unlock_kernel();
return -ENOMEM;
}
input_cnt = 0;
@@ -1016,6 +1021,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
v4l2_prio_open(&vp->prio,&fhp->prio);
fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/s2255drv.c b/linux/drivers/media/video/s2255drv.c
index 85e98c9d2..939edff48 100644
--- a/linux/drivers/media/video/s2255drv.c
+++ b/linux/drivers/media/video/s2255drv.c
@@ -1457,6 +1457,7 @@ static int s2255_open(struct inode *inode, struct file *file)
int cur_channel = -1;
dprintk(1, "s2255: open called (minor=%d)\n", minor);
+ lock_kernel();
list_for_each(list, &s2255_devlist) {
h = list_entry(list, struct s2255_dev, s2255_devlist);
for (i = 0; i < MAX_CHANNELS; i++) {
@@ -1469,6 +1470,7 @@ static int s2255_open(struct inode *inode, struct file *file)
}
if ((NULL == dev) || (cur_channel == -1)) {
+ unlock_kernel();
dprintk(1, "s2255: openv4l no dev\n");
return -ENODEV;
}
@@ -1490,6 +1492,7 @@ static int s2255_open(struct inode *inode, struct file *file)
printk(KERN_INFO "2255 FW load failed.\n");
dev->users[cur_channel]--;
mutex_unlock(&dev->open_lock);
+ unlock_kernel();
return -EFAULT;
}
} else if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_NOTLOADED) {
@@ -1506,6 +1509,7 @@ static int s2255_open(struct inode *inode, struct file *file)
"try again\n");
dev->users[cur_channel]--;
mutex_unlock(&dev->open_lock);
+ unlock_kernel();
return -EBUSY;
}
}
@@ -1515,6 +1519,7 @@ static int s2255_open(struct inode *inode, struct file *file)
if (NULL == fh) {
dev->users[cur_channel]--;
mutex_unlock(&dev->open_lock);
+ unlock_kernel();
return -ENOMEM;
}
@@ -1548,6 +1553,7 @@ static int s2255_open(struct inode *inode, struct file *file)
kref_get(&dev->kref);
mutex_unlock(&dev->open_lock);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/saa5246a.c b/linux/drivers/media/video/saa5246a.c
index 3765dcee9..1bfc49822 100644
--- a/linux/drivers/media/video/saa5246a.c
+++ b/linux/drivers/media/video/saa5246a.c
@@ -44,6 +44,7 @@
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videotext.h>
+#include <linux/smp_lock.h>
#include "compat.h"
#include <linux/videodev.h>
#include <media/v4l2-common.h>
@@ -738,9 +739,12 @@ static int saa5246a_open(struct inode *inode, struct file *file)
struct saa5246a_device *t = vd->priv;
int err;
+ lock_kernel();
err = video_exclusive_open(inode,file);
- if (err < 0)
+ if (err < 0) {
+ unlock_kernel();
return err;
+ }
if (t->client==NULL) {
err = -ENODEV;
@@ -777,11 +781,13 @@ static int saa5246a_open(struct inode *inode, struct file *file)
err = -EIO;
goto fail;
}
+ unlock_kernel();
return 0;
fail:
video_exclusive_release(inode,file);
+ unlock_kernel();
return err;
}
diff --git a/linux/drivers/media/video/saa5249.c b/linux/drivers/media/video/saa5249.c
index 662690c8b..81d341a80 100644
--- a/linux/drivers/media/video/saa5249.c
+++ b/linux/drivers/media/video/saa5249.c
@@ -52,6 +52,7 @@
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <stdarg.h>
#include <linux/i2c.h>
#include <linux/videotext.h>
@@ -634,9 +635,12 @@ static int saa5249_open(struct inode *inode, struct file *file)
struct saa5249_device *t=vd->priv;
int err,pgbuf;
+ lock_kernel();
err = video_exclusive_open(inode,file);
- if (err < 0)
+ if (err < 0) {
+ unlock_kernel();
return err;
+ }
if (t->client==NULL) {
err = -ENODEV;
@@ -665,10 +669,12 @@ static int saa5249_open(struct inode *inode, struct file *file)
t->is_searching[pgbuf] = false;
}
t->virtual_mode = false;
+ unlock_kernel();
return 0;
fail:
video_exclusive_release(inode,file);
+ unlock_kernel();
return err;
}
diff --git a/linux/drivers/media/video/saa7134/saa7134-empress.c b/linux/drivers/media/video/saa7134/saa7134-empress.c
index 45bd752a9..a454968f7 100644
--- a/linux/drivers/media/video/saa7134/saa7134-empress.c
+++ b/linux/drivers/media/video/saa7134/saa7134-empress.c
@@ -79,9 +79,11 @@ static int ts_open(struct inode *inode, struct file *file)
struct saa7134_dev *dev;
int err;
+ lock_kernel();
list_for_each_entry(dev, &saa7134_devlist, devlist)
if (dev->empress_dev && dev->empress_dev->minor == minor)
goto found;
+ unlock_kernel();
return -ENODEV;
found:
@@ -103,6 +105,7 @@ static int ts_open(struct inode *inode, struct file *file)
done_up:
mutex_unlock(&dev->empress_tsq.vb_lock);
done:
+ unlock_kernel();
return err;
}
diff --git a/linux/drivers/media/video/saa7134/saa7134-video.c b/linux/drivers/media/video/saa7134/saa7134-video.c
index 2b4d9c697..547c0401a 100644
--- a/linux/drivers/media/video/saa7134/saa7134-video.c
+++ b/linux/drivers/media/video/saa7134/saa7134-video.c
@@ -1330,6 +1330,8 @@ static int video_open(struct inode *inode, struct file *file)
struct saa7134_fh *fh;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
int radio = 0;
+
+ lock_kernel();
list_for_each_entry(dev, &saa7134_devlist, devlist) {
if (dev->video_dev && (dev->video_dev->minor == minor))
goto found;
@@ -1342,6 +1344,7 @@ static int video_open(struct inode *inode, struct file *file)
goto found;
}
}
+ unlock_kernel();
return -ENODEV;
found:
@@ -1350,8 +1353,10 @@ static int video_open(struct inode *inode, struct file *file)
/* 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;
fh->radio = radio;
@@ -1384,6 +1389,7 @@ static int video_open(struct inode *inode, struct file *file)
/* switch to video/vbi mode */
video_mux(dev,dev->ctl_input);
}
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/se401.c b/linux/drivers/media/video/se401.c
index f59d63618..04897413d 100644
--- a/linux/drivers/media/video/se401.c
+++ b/linux/drivers/media/video/se401.c
@@ -944,14 +944,18 @@ static int se401_open(struct inode *inode, struct file *file)
struct usb_se401 *se401 = (struct usb_se401 *)dev;
int err = 0;
- if (se401->user)
+ lock_kernel();
+ if (se401->user) {
+ unlock_kernel();
return -EBUSY;
+ }
se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES);
if (se401->fbuf)
file->private_data = dev;
else
err = -ENOMEM;
se401->user = !err;
+ unlock_kernel();
return err;
}
diff --git a/linux/drivers/media/video/stk-webcam.c b/linux/drivers/media/video/stk-webcam.c
index e18745a67..c6660b363 100644
--- a/linux/drivers/media/video/stk-webcam.c
+++ b/linux/drivers/media/video/stk-webcam.c
@@ -690,11 +690,15 @@ static int v4l_stk_open(struct inode *inode, struct file *fp)
vdev = video_devdata(fp);
dev = vdev_to_camera(vdev);
- if (dev == NULL || !is_present(dev))
+ lock_kernel();
+ if (dev == NULL || !is_present(dev)) {
+ unlock_kernel();
return -ENXIO;
+ }
fp->private_data = vdev;
kref_get(&dev->kref);
usb_autopm_get_interface(dev->interface);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/stradis.c b/linux/drivers/media/video/stradis.c
index 19243ac19..a081307c7 100644
--- a/linux/drivers/media/video/stradis.c
+++ b/linux/drivers/media/video/stradis.c
@@ -1887,12 +1887,16 @@ static int saa_open(struct inode *inode, struct file *file)
struct video_device *vdev = video_devdata(file);
struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);
+ lock_kernel();
file->private_data = saa;
saa->user++;
- if (saa->user > 1)
+ if (saa->user > 1) {
+ unlock_kernel();
return 0; /* device open already, don't reset */
+ }
saa->writemode = VID_WRITE_MPEG_VID; /* default to video */
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/stv680.c b/linux/drivers/media/video/stv680.c
index 34844ffec..de32a5266 100644
--- a/linux/drivers/media/video/stv680.c
+++ b/linux/drivers/media/video/stv680.c
@@ -1091,6 +1091,7 @@ static int stv_open (struct inode *inode, struct file *file)
int err = 0;
/* we are called with the BKL held */
+ lock_kernel();
stv680->user = 1;
err = stv_init (stv680); /* main initialization routine for camera */
@@ -1104,6 +1105,7 @@ static int stv_open (struct inode *inode, struct file *file)
}
if (err)
stv680->user = 0;
+ unlock_kernel();
return err;
}
diff --git a/linux/drivers/media/video/tvmixer.c b/linux/drivers/media/video/tvmixer.c
index 6233bf391..7c1e1a850 100644
--- a/linux/drivers/media/video/tvmixer.c
+++ b/linux/drivers/media/video/tvmixer.c
@@ -182,6 +182,7 @@ static int tvmixer_open(struct inode *inode, struct file *file)
struct TVMIXER *mix = NULL;
struct i2c_client *client = NULL;
+ lock_kernel();
for (i = 0; i < DEV_MAX; i++) {
if (devices[i].minor == minor) {
mix = devices+i;
@@ -190,13 +191,16 @@ static int tvmixer_open(struct inode *inode, struct file *file)
}
}
- if (NULL == client)
+ if (NULL == client) {
+ unlock_kernel();
return -ENODEV;
+ }
/* lock bttv in memory while the mixer is in use */
file->private_data = mix;
if (client->adapter->owner)
try_module_get(client->adapter->owner);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/usbvideo/vicam.c b/linux/drivers/media/video/usbvideo/vicam.c
index e31b64f17..e7330fe4f 100644
--- a/linux/drivers/media/video/usbvideo/vicam.c
+++ b/linux/drivers/media/video/usbvideo/vicam.c
@@ -798,20 +798,24 @@ vicam_open(struct inode *inode, struct file *file)
* rely on this fact forever.
*/
+ lock_kernel();
if (cam->open_count > 0) {
printk(KERN_INFO
"vicam_open called on already opened camera");
+ unlock_kernel();
return -EBUSY;
}
cam->raw_image = kmalloc(VICAM_MAX_READ_SIZE, GFP_KERNEL);
if (!cam->raw_image) {
+ unlock_kernel();
return -ENOMEM;
}
cam->framebuf = rvmalloc(VICAM_MAX_FRAME_SIZE * VICAM_FRAMES);
if (!cam->framebuf) {
kfree(cam->raw_image);
+ unlock_kernel();
return -ENOMEM;
}
@@ -819,6 +823,7 @@ vicam_open(struct inode *inode, struct file *file)
if (!cam->cntrlbuf) {
kfree(cam->raw_image);
rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES);
+ unlock_kernel();
return -ENOMEM;
}
@@ -836,6 +841,7 @@ vicam_open(struct inode *inode, struct file *file)
cam->open_count++;
file->private_data = cam;
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/usbvision/usbvision-video.c b/linux/drivers/media/video/usbvision/usbvision-video.c
index b977116a0..b76295a5b 100644
--- a/linux/drivers/media/video/usbvision/usbvision-video.c
+++ b/linux/drivers/media/video/usbvision/usbvision-video.c
@@ -367,6 +367,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
PDEBUG(DBG_IO, "open");
+ lock_kernel();
usbvision_reset_powerOffTimer(usbvision);
if (usbvision->user)
@@ -424,6 +425,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
usbvision_empty_framequeues(usbvision);
PDEBUG(DBG_IO, "success");
+ unlock_kernel();
return errCode;
}
diff --git a/linux/drivers/media/video/v4l2-dev.c b/linux/drivers/media/video/v4l2-dev.c
index d7aa8f6a4..c3d3212fd 100644
--- a/linux/drivers/media/video/v4l2-dev.c
+++ b/linux/drivers/media/video/v4l2-dev.c
@@ -150,7 +150,6 @@ static int video_open(struct inode *inode, struct file *file)
if (minor >= VIDEO_NUM_DEVICES)
return -ENODEV;
- lock_kernel();
mutex_lock(&videodev_lock);
vfl = video_device[minor];
if (vfl == NULL) {
@@ -160,7 +159,6 @@ static int video_open(struct inode *inode, struct file *file)
vfl = video_device[minor];
if (vfl == NULL) {
mutex_unlock(&videodev_lock);
- unlock_kernel();
return -ENODEV;
}
}
@@ -178,7 +176,6 @@ static int video_open(struct inode *inode, struct file *file)
}
fops_put(old_fops);
mutex_unlock(&videodev_lock);
- unlock_kernel();
return err;
}
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c
index 573149cc0..2f18381b6 100644
--- a/linux/drivers/media/video/vivi.c
+++ b/linux/drivers/media/video/vivi.c
@@ -901,9 +901,11 @@ static int vivi_open(struct inode *inode, struct file *file)
printk(KERN_DEBUG "vivi: open called (minor=%d)\n", minor);
+ lock_kernel();
list_for_each_entry(dev, &vivi_devlist, vivi_devlist)
if (dev->vfd->minor == minor)
goto found;
+ unlock_kernel();
return -ENODEV;
found:
@@ -928,8 +930,10 @@ found:
}
unlock:
mutex_unlock(&dev->mutex);
- if (retval)
+ if (retval) {
+ unlock_kernel();
return retval;
+ }
file->private_data = fh;
fh->dev = dev;
@@ -958,6 +962,7 @@ unlock:
sizeof(struct vivi_buffer), fh);
vivi_start_thread(fh);
+ unlock_kernel();
return 0;
}
diff --git a/linux/drivers/media/video/zoran_driver.c b/linux/drivers/media/video/zoran_driver.c
index 0c1c349cd..78e8430f4 100644
--- a/linux/drivers/media/video/zoran_driver.c
+++ b/linux/drivers/media/video/zoran_driver.c
@@ -1276,6 +1276,7 @@ zoran_open (struct inode *inode,
struct zoran_fh *fh;
int i, res, first_open = 0, have_module_locks = 0;
+ lock_kernel();
/* find the device */
for (i = 0; i < zoran_num; i++) {
if (zoran[i]->video_dev->minor == minor) {
@@ -1386,6 +1387,7 @@ zoran_open (struct inode *inode,
file->private_data = fh;
fh->zr = zr;
zoran_open_init_session(file);
+ unlock_kernel();
return 0;
@@ -1403,6 +1405,7 @@ open_unlock_and_return:
if (zr) {
/*mutex_unlock(&zr->resource_lock);*/
}
+ unlock_kernel();
return res;
}
diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c
index 53a934daa..dbfdd6966 100644
--- a/linux/drivers/media/video/zr364xx.c
+++ b/linux/drivers/media/video/zr364xx.c
@@ -644,14 +644,18 @@ static int zr364xx_open(struct inode *inode, struct file *file)
cam->skip = 2;
+ lock_kernel();
err = video_exclusive_open(inode, file);
- if (err < 0)
+ if (err < 0) {
+ unlock_kernel();
return err;
+ }
if (!cam->framebuf) {
cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES);
if (!cam->framebuf) {
info("vmalloc_32 failed!");
+ unlock_kernel();
return -ENOMEM;
}
}
@@ -665,6 +669,7 @@ static int zr364xx_open(struct inode *inode, struct file *file)
if (err < 0) {
info("error during open sequence: %d", i);
mutex_unlock(&cam->lock);
+ unlock_kernel();
return err;
}
}
@@ -677,6 +682,7 @@ static int zr364xx_open(struct inode *inode, struct file *file)
mdelay(100);
mutex_unlock(&cam->lock);
+ unlock_kernel();
return 0;
}