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

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
...@@ -407,15 +407,18 @@ static int usb_dsbr100_open(struct inode *inode, struct file *file) ...@@ -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)); struct dsbr100_device *radio=video_get_drvdata(video_devdata(file));
lock_kernel();
radio->users = 1; radio->users = 1;
radio->muted = 1; radio->muted = 1;
if (dsbr100_start(radio)<0) { if (dsbr100_start(radio)<0) {
warn("Radio did not start up properly"); warn("Radio did not start up properly");
radio->users = 0; radio->users = 0;
unlock_kernel();
return -EIO; return -EIO;
} }
dsbr100_setfreq(radio, radio->curfreq); dsbr100_setfreq(radio, radio->curfreq);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1074,6 +1074,7 @@ static int si470x_fops_open(struct inode *inode, struct file *file) ...@@ -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)); struct si470x_device *radio = video_get_drvdata(video_devdata(file));
int retval; int retval;
lock_kernel();
radio->users++; radio->users++;
retval = usb_autopm_get_interface(radio->intf); retval = usb_autopm_get_interface(radio->intf);
...@@ -1090,6 +1091,7 @@ static int si470x_fops_open(struct inode *inode, struct file *file) ...@@ -1090,6 +1091,7 @@ static int si470x_fops_open(struct inode *inode, struct file *file)
} }
done: done:
unlock_kernel();
return retval; return retval;
} }
......
...@@ -3227,6 +3227,7 @@ static int bttv_open(struct inode *inode, struct file *file) ...@@ -3227,6 +3227,7 @@ static int bttv_open(struct inode *inode, struct file *file)
dprintk(KERN_DEBUG "bttv: open minor=%d\n",minor); dprintk(KERN_DEBUG "bttv: open minor=%d\n",minor);
lock_kernel();
for (i = 0; i < bttv_num; i++) { for (i = 0; i < bttv_num; i++) {
if (bttvs[i].video_dev && if (bttvs[i].video_dev &&
bttvs[i].video_dev->minor == minor) { bttvs[i].video_dev->minor == minor) {
...@@ -3241,16 +3242,20 @@ static int bttv_open(struct inode *inode, struct file *file) ...@@ -3241,16 +3242,20 @@ static int bttv_open(struct inode *inode, struct file *file)
break; break;
} }
} }
if (NULL == btv) if (NULL == btv) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n", dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
btv->c.nr,v4l2_type_names[type]); btv->c.nr,v4l2_type_names[type]);
/* allocate per filehandle data */ /* allocate per filehandle data */
fh = kmalloc(sizeof(*fh),GFP_KERNEL); fh = kmalloc(sizeof(*fh),GFP_KERNEL);
if (NULL == fh) if (NULL == fh) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
file->private_data = fh; file->private_data = fh;
*fh = btv->init; *fh = btv->init;
fh->type = type; fh->type = type;
...@@ -3290,6 +3295,7 @@ static int bttv_open(struct inode *inode, struct file *file) ...@@ -3290,6 +3295,7 @@ static int bttv_open(struct inode *inode, struct file *file)
bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm);
bttv_field_count(btv); bttv_field_count(btv);
unlock_kernel();
return 0; return 0;
} }
...@@ -3430,21 +3436,26 @@ static int radio_open(struct inode *inode, struct file *file) ...@@ -3430,21 +3436,26 @@ static int radio_open(struct inode *inode, struct file *file)
dprintk("bttv: open minor=%d\n",minor); dprintk("bttv: open minor=%d\n",minor);
lock_kernel();
for (i = 0; i < bttv_num; i++) { for (i = 0; i < bttv_num; i++) {
if (bttvs[i].radio_dev && bttvs[i].radio_dev->minor == minor) { if (bttvs[i].radio_dev && bttvs[i].radio_dev->minor == minor) {
btv = &bttvs[i]; btv = &bttvs[i];
break; break;
} }
} }
if (NULL == btv) if (NULL == btv) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
dprintk("bttv%d: open called (radio)\n",btv->c.nr); dprintk("bttv%d: open called (radio)\n",btv->c.nr);
/* allocate per filehandle data */ /* allocate per filehandle data */
fh = kmalloc(sizeof(*fh), GFP_KERNEL); fh = kmalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) if (NULL == fh) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
file->private_data = fh; file->private_data = fh;
*fh = btv->init; *fh = btv->init;
v4l2_prio_open(&btv->prio, &fh->prio); v4l2_prio_open(&btv->prio, &fh->prio);
...@@ -3457,6 +3468,7 @@ static int radio_open(struct inode *inode, struct file *file) ...@@ -3457,6 +3468,7 @@ static int radio_open(struct inode *inode, struct file *file)
audio_input(btv,TVAUDIO_INPUT_RADIO); audio_input(btv,TVAUDIO_INPUT_RADIO);
mutex_unlock(&btv->lock); mutex_unlock(&btv->lock);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1476,9 +1476,12 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp) ...@@ -1476,9 +1476,12 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
{ {
struct cafe_camera *cam; struct cafe_camera *cam;
lock_kernel();
cam = cafe_find_dev(iminor(inode)); cam = cafe_find_dev(iminor(inode));
if (cam == NULL) if (cam == NULL) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
filp->private_data = cam; filp->private_data = cam;
mutex_lock(&cam->s_mutex); mutex_lock(&cam->s_mutex);
...@@ -1490,6 +1493,7 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp) ...@@ -1490,6 +1493,7 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
} }
(cam->users)++; (cam->users)++;
mutex_unlock(&cam->s_mutex); mutex_unlock(&cam->s_mutex);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1583,6 +1583,7 @@ static int mpeg_open(struct inode *inode, struct file *file) ...@@ -1583,6 +1583,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
lock_kernel();
list_for_each(list, &cx23885_devlist) { list_for_each(list, &cx23885_devlist) {
h = list_entry(list, struct cx23885_dev, devlist); h = list_entry(list, struct cx23885_dev, devlist);
if (h->v4l_device->minor == minor) { if (h->v4l_device->minor == minor) {
...@@ -1591,13 +1592,17 @@ static int mpeg_open(struct inode *inode, struct file *file) ...@@ -1591,13 +1592,17 @@ static int mpeg_open(struct inode *inode, struct file *file)
} }
} }
if (dev == NULL) if (dev == NULL) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) if (NULL == fh) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
...@@ -1608,6 +1613,7 @@ static int mpeg_open(struct inode *inode, struct file *file) ...@@ -1608,6 +1613,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx23885_buffer), sizeof(struct cx23885_buffer),
fh); fh);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -731,6 +731,7 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -731,6 +731,7 @@ static int video_open(struct inode *inode, struct file *file)
enum v4l2_buf_type type = 0; enum v4l2_buf_type type = 0;
int radio = 0; int radio = 0;
lock_kernel();
list_for_each(list, &cx23885_devlist) { list_for_each(list, &cx23885_devlist) {
h = list_entry(list, struct cx23885_dev, devlist); h = list_entry(list, struct cx23885_dev, devlist);
if (h->video_dev->minor == minor) { if (h->video_dev->minor == minor) {
...@@ -748,16 +749,20 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -748,16 +749,20 @@ static int video_open(struct inode *inode, struct file *file)
dev = h; dev = h;
} }
} }
if (NULL == dev) if (NULL == dev) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
dprintk(1, "open minor=%d radio=%d type=%s\n", dprintk(1, "open minor=%d radio=%d type=%s\n",
minor, radio, v4l2_type_names[type]); minor, radio, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) if (NULL == fh) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->radio = radio; fh->radio = radio;
...@@ -775,6 +780,7 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -775,6 +780,7 @@ static int video_open(struct inode *inode, struct file *file)
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1057,12 +1057,15 @@ static int mpeg_open(struct inode *inode, struct file *file) ...@@ -1057,12 +1057,15 @@ static int mpeg_open(struct inode *inode, struct file *file)
struct cx8802_driver *drv = NULL; struct cx8802_driver *drv = NULL;
int err; int err;
lock_kernel();
dev = cx8802_get_device(inode); dev = cx8802_get_device(inode);
dprintk( 1, "%s\n", __func__); dprintk( 1, "%s\n", __func__);
if (dev == NULL) if (dev == NULL) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
/* Make sure we can acquire the hardware */ /* Make sure we can acquire the hardware */
drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
...@@ -1077,6 +1080,7 @@ static int mpeg_open(struct inode *inode, struct file *file) ...@@ -1077,6 +1080,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
if (blackbird_initialize_codec(dev) < 0) { if (blackbird_initialize_codec(dev) < 0) {
if (drv) if (drv)
drv->request_release(drv); drv->request_release(drv);
unlock_kernel();
return -EINVAL; return -EINVAL;
} }
dprintk(1,"open minor=%d\n",minor); dprintk(1,"open minor=%d\n",minor);
...@@ -1086,6 +1090,7 @@ static int mpeg_open(struct inode *inode, struct file *file) ...@@ -1086,6 +1090,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
if (NULL == fh) { if (NULL == fh) {
if (drv) if (drv)
drv->request_release(drv); drv->request_release(drv);
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
...@@ -1101,6 +1106,7 @@ static int mpeg_open(struct inode *inode, struct file *file) ...@@ -1101,6 +1106,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
/* FIXME: locking against other video device */ /* FIXME: locking against other video device */
cx88_set_scale(dev->core, dev->width, dev->height, cx88_set_scale(dev->core, dev->width, dev->height,
fh->mpegq.field); fh->mpegq.field);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -773,6 +773,7 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -773,6 +773,7 @@ static int video_open(struct inode *inode, struct file *file)
enum v4l2_buf_type type = 0; enum v4l2_buf_type type = 0;
int radio = 0; int radio = 0;
lock_kernel();
list_for_each_entry(h, &cx8800_devlist, devlist) { list_for_each_entry(h, &cx8800_devlist, devlist) {
if (h->video_dev->minor == minor) { if (h->video_dev->minor == minor) {
dev = h; dev = h;
...@@ -788,8 +789,10 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -788,8 +789,10 @@ static int video_open(struct inode *inode, struct file *file)
dev = h; dev = h;
} }
} }
if (NULL == dev) if (NULL == dev) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
core = dev->core; core = dev->core;
...@@ -798,8 +801,10 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -798,8 +801,10 @@ static int video_open(struct inode *inode, struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh),GFP_KERNEL); fh = kzalloc(sizeof(*fh),GFP_KERNEL);
if (NULL == fh) if (NULL == fh) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->radio = radio; fh->radio = radio;
...@@ -832,6 +837,7 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -832,6 +837,7 @@ static int video_open(struct inode *inode, struct file *file)
cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1);
cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL);
} }
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1512,6 +1512,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) ...@@ -1512,6 +1512,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
struct em28xx_fh *fh; struct em28xx_fh *fh;
enum v4l2_buf_type fh_type = 0; enum v4l2_buf_type fh_type = 0;
lock_kernel();
list_for_each_entry(h, &em28xx_devlist, devlist) { list_for_each_entry(h, &em28xx_devlist, devlist) {
if (h->vdev->minor == minor) { if (h->vdev->minor == minor) {
dev = h; dev = h;
...@@ -1527,8 +1528,10 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) ...@@ -1527,8 +1528,10 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
dev = h; dev = h;
} }
} }
if (NULL == dev) if (NULL == dev) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
em28xx_videodbg("open minor=%d type=%s users=%d\n", em28xx_videodbg("open minor=%d type=%s users=%d\n",
minor, v4l2_type_names[fh_type], dev->users); minor, v4l2_type_names[fh_type], dev->users);
...@@ -1537,6 +1540,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) ...@@ -1537,6 +1540,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
if (!fh) { if (!fh) {
em28xx_errdev("em28xx-video.c: Out of memory?!\n"); em28xx_errdev("em28xx-video.c: Out of memory?!\n");
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
...@@ -1573,6 +1577,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) ...@@ -1573,6 +1577,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
sizeof(struct em28xx_buffer), fh); sizeof(struct em28xx_buffer), fh);
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
unlock_kernel();
return errCode; return errCode;
} }
......
...@@ -845,15 +845,19 @@ static int meye_open(struct inode *inode, struct file *file) ...@@ -845,15 +845,19 @@ static int meye_open(struct inode *inode, struct file *file)
{ {
int i, err; int i, err;
lock_kernel();
err = video_exclusive_open(inode, file); err = video_exclusive_open(inode, file);
if (err < 0) if (err < 0) {
unlock_kernel();
return err; 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); video_exclusive_release(inode, file);
unlock_kernel();
return -ENOBUFS; return -ENOBUFS;
} }
...@@ -861,6 +865,7 @@ static int meye_open(struct inode *inode, struct file *file) ...@@ -861,6 +865,7 @@ 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;
} }
......
...@@ -932,6 +932,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file) ...@@ -932,6 +932,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
unsigned int input_cnt,idx; unsigned int input_cnt,idx;
int ret = 0; int ret = 0;
lock_kernel();
dip = container_of(video_devdata(file),struct pvr2_v4l2_dev,devbase); dip = container_of(video_devdata(file),struct pvr2_v4l2_dev,devbase);
vp = dip->v4lp; vp = dip->v4lp;
...@@ -942,11 +943,13 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file) ...@@ -942,11 +943,13 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
if (!pvr2_hdw_dev_ok(hdw)) { if (!pvr2_hdw_dev_ok(hdw)) {
pvr2_trace(PVR2_TRACE_OPEN_CLOSE, pvr2_trace(PVR2_TRACE_OPEN_CLOSE,
"pvr2_v4l2_open: hardware not ready"); "pvr2_v4l2_open: hardware not ready");
unlock_kernel();
return -EIO; return -EIO;
} }
fhp = kzalloc(sizeof(*fhp),GFP_KERNEL); fhp = kzalloc(sizeof(*fhp),GFP_KERNEL);
if (!fhp) { if (!fhp) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
...@@ -976,6 +979,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file) ...@@ -976,6 +979,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
fhp); fhp);
kfree(fhp); kfree(fhp);
unlock_kernel();
return ret; return ret;
} }
...@@ -992,6 +996,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file) ...@@ -992,6 +996,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
"Destroying pvr_v4l2_fh id=%p (input map failure)", "Destroying pvr_v4l2_fh id=%p (input map failure)",
fhp); fhp);
kfree(fhp); kfree(fhp);
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
input_cnt = 0; input_cnt = 0;
...@@ -1015,6 +1020,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file) ...@@ -1015,6 +1020,7 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file)
v4l2_prio_open(&vp->prio,&fhp->prio); v4l2_prio_open(&vp->prio,&fhp->prio);
fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw); fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1457,6 +1457,7 @@ static int s2255_open(struct inode *inode, struct file *file) ...@@ -1457,6 +1457,7 @@ static int s2255_open(struct inode *inode, struct file *file)
int cur_channel = -1; int cur_channel = -1;
dprintk(1, "s2255: open called (minor=%d)\n", minor); dprintk(1, "s2255: open called (minor=%d)\n", minor);
lock_kernel();
list_for_each(list, &s2255_devlist) { list_for_each(list, &s2255_devlist) {
h = list_entry(list, struct s2255_dev, s2255_devlist); h = list_entry(list, struct s2255_dev, s2255_devlist);
for (i = 0; i < MAX_CHANNELS; i++) { for (i = 0; i < MAX_CHANNELS; i++) {
...@@ -1469,6 +1470,7 @@ static int s2255_open(struct inode *inode, struct file *file) ...@@ -1469,6 +1470,7 @@ static int s2255_open(struct inode *inode, struct file *file)
} }
if ((NULL == dev) || (cur_channel == -1)) { if ((NULL == dev) || (cur_channel == -1)) {
unlock_kernel();
dprintk(1, "s2255: openv4l no dev\n"); dprintk(1, "s2255: openv4l no dev\n");
return -ENODEV; return -ENODEV;
} }
...@@ -1490,6 +1492,7 @@ static int s2255_open(struct inode *inode, struct file *file) ...@@ -1490,6 +1492,7 @@ static int s2255_open(struct inode *inode, struct file *file)
printk(KERN_INFO "2255 FW load failed.\n"); printk(KERN_INFO "2255 FW load failed.\n");
dev->users[cur_channel]--; dev->users[cur_channel]--;
mutex_unlock(&dev->open_lock); mutex_unlock(&dev->open_lock);
unlock_kernel();
return -EFAULT; return -EFAULT;
} }
} else if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_NOTLOADED) { } 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) ...@@ -1506,6 +1509,7 @@ static int s2255_open(struct inode *inode, struct file *file)
"try again\n"); "try again\n");
dev->users[cur_channel]--; dev->users[cur_channel]--;
mutex_unlock(&dev->open_lock); mutex_unlock(&dev->open_lock);
unlock_kernel();
return -EBUSY; return -EBUSY;
} }
} }
...@@ -1515,6 +1519,7 @@ static int s2255_open(struct inode *inode, struct file *file) ...@@ -1515,6 +1519,7 @@ static int s2255_open(struct inode *inode, struct file *file)
if (NULL == fh) { if (NULL == fh) {
dev->users[cur_channel]--; dev->users[cur_channel]--;
mutex_unlock(&dev->open_lock); mutex_unlock(&dev->open_lock);
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
...@@ -1548,6 +1553,7 @@ static int s2255_open(struct inode *inode, struct file *file) ...@@ -1548,6 +1553,7 @@ static int s2255_open(struct inode *inode, struct file *file)
kref_get(&dev->kref); kref_get(&dev->kref);
mutex_unlock(&dev->open_lock); mutex_unlock(&dev->open_lock);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/videotext.h> #include <linux/videotext.h>
#include <linux/smp_lock.h>
#include <linux/videodev.h> #include <linux/videodev.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
...@@ -737,9 +738,12 @@ static int saa5246a_open(struct inode *inode, struct file *file) ...@@ -737,9 +738,12 @@ static int saa5246a_open(struct inode *inode, struct file *file)
struct saa5246a_device *t = vd->priv; struct saa5246a_device *t = vd->priv;
int err; int err;
lock_kernel();
err = video_exclusive_open(inode,file); err = video_exclusive_open(inode,file);
if (err < 0) if (err < 0) {
unlock_kernel();
return err; return err;
}
if (t->client==NULL) { if (t->client==NULL) {
err = -ENODEV; err = -ENODEV;
...@@ -776,11 +780,13 @@ static int saa5246a_open(struct inode *inode, struct file *file) ...@@ -776,11 +780,13 @@ static int saa5246a_open(struct inode *inode, struct file *file)
err = -EIO; err = -EIO;
goto fail; goto fail;
} }
unlock_kernel();
return 0; return 0;
fail: fail:
video_exclusive_release(inode,file); video_exclusive_release(inode,file);
unlock_kernel();
return err; return err;
} }
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/smp_lock.h>
#include <stdarg.h> #include <stdarg.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/videotext.h> #include <linux/videotext.h>
...@@ -633,9 +634,12 @@ static int saa5249_open(struct inode *inode, struct file *file) ...@@ -633,9 +634,12 @@ static int saa5249_open(struct inode *inode, struct file *file)
struct saa5249_device *t=vd->priv; struct saa5249_device *t=vd->priv;
int err,pgbuf; int err,pgbuf;
lock_kernel();
err = video_exclusive_open(inode,file); err = video_exclusive_open(inode,file);
if (err < 0) if (err < 0) {
unlock_kernel();
return err; return err;
}
if (t->client==NULL) { if (t->client==NULL) {
err = -ENODEV; err = -ENODEV;
...@@ -664,10 +668,12 @@ static int saa5249_open(struct inode *inode, struct file *file) ...@@ -664,10 +668,12 @@ 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: fail:
video_exclusive_release(inode,file); video_exclusive_release(inode,file);
unlock_kernel();
return err; return err;
} }
......
...@@ -79,9 +79,11 @@ static int ts_open(struct inode *inode, struct file *file) ...@@ -79,9 +79,11 @@ static int ts_open(struct inode *inode, struct file *file)
struct saa7134_dev *dev; struct saa7134_dev *dev;
int err; int err;
lock_kernel();
list_for_each_entry(dev, &saa7134_devlist, devlist) list_for_each_entry(dev, &saa7134_devlist, devlist)
if (dev->empress_dev && dev->empress_dev->minor == minor) if (dev->empress_dev && dev->empress_dev->minor == minor)
goto found; goto found;
unlock_kernel();
return -ENODEV; return -ENODEV;
found: found:
...@@ -103,6 +105,7 @@ static int ts_open(struct inode *inode, struct file *file) ...@@ -103,6 +105,7 @@ static int ts_open(struct inode *inode, struct file *file)
done_up: done_up:
mutex_unlock(&dev->empress_tsq.vb_lock); mutex_unlock(&dev->empress_tsq.vb_lock);
done: done:
unlock_kernel();
return err; return err;
} }
......
...@@ -1330,6 +1330,8 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -1330,6 +1330,8 @@ static int video_open(struct inode *inode, struct file *file)
struct saa7134_fh *fh; struct saa7134_fh *fh;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
int radio = 0; int radio = 0;
lock_kernel();
list_for_each_entry(dev, &saa7134_devlist, devlist) { list_for_each_entry(dev, &saa7134_devlist, devlist) {
if (dev->video_dev && (dev->video_dev->minor == minor)) if (dev->video_dev && (dev->video_dev->minor == minor))
goto found; goto found;
...@@ -1342,6 +1344,7 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -1342,6 +1344,7 @@ static int video_open(struct inode *inode, struct file *file)
goto found; goto found;
} }
} }
unlock_kernel();
return -ENODEV; return -ENODEV;
found: found:
...@@ -1350,8 +1353,10 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -1350,8 +1353,10 @@ static int video_open(struct inode *inode, struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh),GFP_KERNEL); fh = kzalloc(sizeof(*fh),GFP_KERNEL);
if (NULL == fh) if (NULL == fh) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->radio = radio; fh->radio = radio;
...@@ -1384,6 +1389,7 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -1384,6 +1389,7 @@ static int video_open(struct inode *inode, struct file *file)
/* switch to video/vbi mode */ /* switch to video/vbi mode */
video_mux(dev,dev->ctl_input); video_mux(dev,dev->ctl_input);
} }
unlock_kernel();
return 0; return 0;
} }
......
...@@ -936,14 +936,18 @@ static int se401_open(struct inode *inode, struct file *file) ...@@ -936,14 +936,18 @@ static int se401_open(struct inode *inode, struct file *file)
struct usb_se401 *se401 = (struct usb_se401 *)dev; struct usb_se401 *se401 = (struct usb_se401 *)dev;
int err = 0; int err = 0;
if (se401->user) lock_kernel();
if (se401->user) {
unlock_kernel();
return -EBUSY; return -EBUSY;
}
se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES); se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES);
if (se401->fbuf) if (se401->fbuf)
file->private_data = dev; file->private_data = dev;
else else
err = -ENOMEM; err = -ENOMEM;
se401->user = !err; se401->user = !err;
unlock_kernel();
return err; return err;
} }
......
...@@ -689,11 +689,15 @@ static int v4l_stk_open(struct inode *inode, struct file *fp) ...@@ -689,11 +689,15 @@ static int v4l_stk_open(struct inode *inode, struct file *fp)
vdev = video_devdata(fp); vdev = video_devdata(fp);
dev = vdev_to_camera(vdev); dev = vdev_to_camera(vdev);
if (dev == NULL || !is_present(dev)) lock_kernel();
if (dev == NULL || !is_present(dev)) {
unlock_kernel();
return -ENXIO; return -ENXIO;
}
fp->private_data = vdev; fp->private_data = vdev;
kref_get(&dev->kref); kref_get(&dev->kref);
usb_autopm_get_interface(dev->interface); usb_autopm_get_interface(dev->interface);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1882,12 +1882,16 @@ static int saa_open(struct inode *inode, struct file *file) ...@@ -1882,12 +1882,16 @@ static int saa_open(struct inode *inode, struct file *file)
struct video_device *vdev = video_devdata(file); struct video_device *vdev = video_devdata(file);
struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev); struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);
lock_kernel();
file->private_data = saa; file->private_data = saa;
saa->user++; saa->user++;
if (saa->user > 1) if (saa->user > 1) {
unlock_kernel();
return 0; /* device open already, don't reset */ return 0; /* device open already, don't reset */
}
saa->writemode = VID_WRITE_MPEG_VID; /* default to video */ saa->writemode = VID_WRITE_MPEG_VID; /* default to video */
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1086,6 +1086,7 @@ static int stv_open (struct inode *inode, struct file *file) ...@@ -1086,6 +1086,7 @@ static int stv_open (struct inode *inode, struct file *file)
int err = 0; int err = 0;
/* we are called with the BKL held */ /* we are called with the BKL held */
lock_kernel();
stv680->user = 1; stv680->user = 1;
err = stv_init (stv680); /* main initialization routine for camera */ err = stv_init (stv680); /* main initialization routine for camera */
...@@ -1099,6 +1100,7 @@ static int stv_open (struct inode *inode, struct file *file) ...@@ -1099,6 +1100,7 @@ static int stv_open (struct inode *inode, struct file *file)
} }
if (err) if (err)
stv680->user = 0; stv680->user = 0;
unlock_kernel();
return err; return err;
} }
......
...@@ -488,20 +488,24 @@ vicam_open(struct inode *inode, struct file *file) ...@@ -488,20 +488,24 @@ vicam_open(struct inode *inode, struct file *file)
* rely on this fact forever. * rely on this fact forever.
*/ */
lock_kernel();
if (cam->open_count > 0) { if (cam->open_count > 0) {
printk(KERN_INFO printk(KERN_INFO
"vicam_open called on already opened camera"); "vicam_open called on already opened camera");
unlock_kernel();
return -EBUSY; return -EBUSY;
} }
cam->raw_image = kmalloc(VICAM_MAX_READ_SIZE, GFP_KERNEL); cam->raw_image = kmalloc(VICAM_MAX_READ_SIZE, GFP_KERNEL);
if (!cam->raw_image) { if (!cam->raw_image) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
cam->framebuf = rvmalloc(VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); cam->framebuf = rvmalloc(VICAM_MAX_FRAME_SIZE * VICAM_FRAMES);
if (!cam->framebuf) { if (!cam->framebuf) {
kfree(cam->raw_image); kfree(cam->raw_image);
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
...@@ -509,6 +513,7 @@ vicam_open(struct inode *inode, struct file *file) ...@@ -509,6 +513,7 @@ vicam_open(struct inode *inode, struct file *file)
if (!cam->cntrlbuf) { if (!cam->cntrlbuf) {
kfree(cam->raw_image); kfree(cam->raw_image);
rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES);
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
...@@ -526,6 +531,7 @@ vicam_open(struct inode *inode, struct file *file) ...@@ -526,6 +531,7 @@ vicam_open(struct inode *inode, struct file *file)
cam->open_count++; cam->open_count++;
file->private_data = cam; file->private_data = cam;
unlock_kernel();
return 0; return 0;
} }
......
...@@ -367,6 +367,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file) ...@@ -367,6 +367,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
PDEBUG(DBG_IO, "open"); PDEBUG(DBG_IO, "open");
lock_kernel();
usbvision_reset_powerOffTimer(usbvision); usbvision_reset_powerOffTimer(usbvision);
if (usbvision->user) if (usbvision->user)
...@@ -424,6 +425,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file) ...@@ -424,6 +425,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
usbvision_empty_framequeues(usbvision); usbvision_empty_framequeues(usbvision);
PDEBUG(DBG_IO, "success"); PDEBUG(DBG_IO, "success");
unlock_kernel();
return errCode; return errCode;
} }
......
...@@ -116,7 +116,6 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -116,7 +116,6 @@ static int video_open(struct inode *inode, struct file *file)
if (minor >= VIDEO_NUM_DEVICES) if (minor >= VIDEO_NUM_DEVICES)
return -ENODEV; return -ENODEV;
lock_kernel();
mutex_lock(&videodev_lock); mutex_lock(&videodev_lock);
vfl = video_device[minor]; vfl = video_device[minor];
if (vfl == NULL) { if (vfl == NULL) {
...@@ -126,7 +125,6 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -126,7 +125,6 @@ static int video_open(struct inode *inode, struct file *file)
vfl = video_device[minor]; vfl = video_device[minor];
if (vfl == NULL) { if (vfl == NULL) {
mutex_unlock(&videodev_lock); mutex_unlock(&videodev_lock);
unlock_kernel();
return -ENODEV; return -ENODEV;
} }
} }
...@@ -140,7 +138,6 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -140,7 +138,6 @@ static int video_open(struct inode *inode, struct file *file)
} }
fops_put(old_fops); fops_put(old_fops);
mutex_unlock(&videodev_lock); mutex_unlock(&videodev_lock);
unlock_kernel();
return err; return err;
} }
......
...@@ -898,9 +898,11 @@ static int vivi_open(struct inode *inode, struct file *file) ...@@ -898,9 +898,11 @@ static int vivi_open(struct inode *inode, struct file *file)
printk(KERN_DEBUG "vivi: open called (minor=%d)\n", minor); printk(KERN_DEBUG "vivi: open called (minor=%d)\n", minor);
lock_kernel();
list_for_each_entry(dev, &vivi_devlist, vivi_devlist) list_for_each_entry(dev, &vivi_devlist, vivi_devlist)
if (dev->vfd->minor == minor) if (dev->vfd->minor == minor)
goto found; goto found;
unlock_kernel();
return -ENODEV; return -ENODEV;
found: found:
...@@ -925,8 +927,10 @@ static int vivi_open(struct inode *inode, struct file *file) ...@@ -925,8 +927,10 @@ static int vivi_open(struct inode *inode, struct file *file)
} }
unlock: unlock:
mutex_unlock(&dev->mutex); mutex_unlock(&dev->mutex);
if (retval) if (retval) {
unlock_kernel();
return retval; return retval;
}
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
...@@ -955,6 +959,7 @@ static int vivi_open(struct inode *inode, struct file *file) ...@@ -955,6 +959,7 @@ static int vivi_open(struct inode *inode, struct file *file)
sizeof(struct vivi_buffer), fh); sizeof(struct vivi_buffer), fh);
vivi_start_thread(fh); vivi_start_thread(fh);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -1211,6 +1211,7 @@ zoran_open (struct inode *inode, ...@@ -1211,6 +1211,7 @@ zoran_open (struct inode *inode,
struct zoran_fh *fh; struct zoran_fh *fh;
int i, res, first_open = 0, have_module_locks = 0; int i, res, first_open = 0, have_module_locks = 0;
lock_kernel();
/* find the device */ /* find the device */
for (i = 0; i < zoran_num; i++) { for (i = 0; i < zoran_num; i++) {
if (zoran[i]->video_dev->minor == minor) { if (zoran[i]->video_dev->minor == minor) {
...@@ -1321,6 +1322,7 @@ zoran_open (struct inode *inode, ...@@ -1321,6 +1322,7 @@ zoran_open (struct inode *inode,
file->private_data = fh; file->private_data = fh;
fh->zr = zr; fh->zr = zr;
zoran_open_init_session(file); zoran_open_init_session(file);
unlock_kernel();
return 0; return 0;
...@@ -1338,6 +1340,7 @@ zoran_open (struct inode *inode, ...@@ -1338,6 +1340,7 @@ zoran_open (struct inode *inode,
if (zr) { if (zr) {
/*mutex_unlock(&zr->resource_lock);*/ /*mutex_unlock(&zr->resource_lock);*/
} }
unlock_kernel();
return res; return res;
} }
......
...@@ -643,14 +643,18 @@ static int zr364xx_open(struct inode *inode, struct file *file) ...@@ -643,14 +643,18 @@ static int zr364xx_open(struct inode *inode, struct file *file)
cam->skip = 2; cam->skip = 2;
lock_kernel();
err = video_exclusive_open(inode, file); err = video_exclusive_open(inode, file);
if (err < 0) if (err < 0) {
unlock_kernel();
return err; return err;
}
if (!cam->framebuf) { if (!cam->framebuf) {
cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES); cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES);
if (!cam->framebuf) { if (!cam->framebuf) {
info("vmalloc_32 failed!"); info("vmalloc_32 failed!");
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
} }
...@@ -664,6 +668,7 @@ static int zr364xx_open(struct inode *inode, struct file *file) ...@@ -664,6 +668,7 @@ static int zr364xx_open(struct inode *inode, struct file *file)
if (err < 0) { if (err < 0) {
info("error during open sequence: %d", i); info("error during open sequence: %d", i);
mutex_unlock(&cam->lock); mutex_unlock(&cam->lock);
unlock_kernel();
return err; return err;
} }
} }
...@@ -676,6 +681,7 @@ static int zr364xx_open(struct inode *inode, struct file *file) ...@@ -676,6 +681,7 @@ static int zr364xx_open(struct inode *inode, struct file *file)
mdelay(100); mdelay(100);
mutex_unlock(&cam->lock); mutex_unlock(&cam->lock);
unlock_kernel();
return 0; return 0;
} }
......
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